Skip to content

Commit c948e39

Browse files
committed
Added metadata spec
1 parent 1677af5 commit c948e39

File tree

18 files changed

+322
-46
lines changed

18 files changed

+322
-46
lines changed

deployments/templates/deployment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ spec:
4545
- name: AZURE_REDIRECT_URI
4646
value: "$AZURE_REDIRECT_URI"
4747
- name: AZURE_AUTHORITY
48-
value: "$AZURE_AUTHORITY"
48+
value: "$AZURE_AUTHORITY"
4949
- name: SECRET_KEY
5050
valueFrom:
5151
secretKeyRef:

home/forms/domain_model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from typing import NamedTuple
21
import os
2+
from typing import NamedTuple
33

44

55
class Domain(NamedTuple):

home/forms/search.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from copy import deepcopy
22
from urllib.parse import urlencode
33

4+
from data_platform_catalogue.search_types import ResultType
45
from django import forms
56

67
from .domain_model import Domain, DomainModel
7-
from data_platform_catalogue.search_types import ResultType
88

99

1010
def get_domain_choices() -> list[Domain]:
@@ -35,10 +35,13 @@ def get_where_to_access_choices():
3535

3636

3737
def get_entity_types():
38-
return sorted([
39-
(entity.name, entity.name.replace("_", " ").lower().title())
40-
for entity in ResultType if entity.name != "GLOSSARY_TERM"
41-
])
38+
return sorted(
39+
[
40+
(entity.name, entity.name.replace("_", " ").lower().title())
41+
for entity in ResultType
42+
if entity.name != "GLOSSARY_TERM"
43+
]
44+
)
4245

4346

4447
class SelectWithOptionAttribute(forms.Select):
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from data_platform_catalogue.entities import (
2+
AccessInformation,
3+
Chart,
4+
Column,
5+
ColumnRef,
6+
CustomEntityProperties,
7+
Database,
8+
DataSummary,
9+
DomainRef,
10+
Entity,
11+
EntityRef,
12+
Governance,
13+
OwnerRef,
14+
Table,
15+
TagRef,
16+
UsageRestrictions,
17+
)
18+
19+
20+
class MetadataSpecificationService:
21+
def __init__(self):
22+
self.context = self._get_context()
23+
24+
def _get_context(self):
25+
return {
26+
"h1_value": "Metadata Specification",
27+
"entities": {
28+
"Table": Table.model_json_schema(),
29+
"Database": Database.model_json_schema(),
30+
"Chart": Chart.model_json_schema(),
31+
"CustomEntityProperties": CustomEntityProperties.model_json_schema(),
32+
"UsageRestrictions": UsageRestrictions.model_json_schema(),
33+
"AccessInformation": AccessInformation.model_json_schema(),
34+
"EntityRef": EntityRef.model_json_schema(),
35+
"Governance": Governance.model_json_schema(),
36+
"OwnerRef": OwnerRef.model_json_schema(),
37+
"DomainRef": DomainRef.model_json_schema(),
38+
"Column": Column.model_json_schema(),
39+
"ColumnRef": ColumnRef.model_json_schema(),
40+
"TagRef": TagRef.model_json_schema(),
41+
"DataSummary": DataSummary.model_json_schema(),
42+
"Entity": Entity.model_json_schema(),
43+
},
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from django import template
2+
3+
register = template.Library()
4+
5+
6+
@register.filter
7+
def format_metadata_field_type(value: dict) -> str:
8+
if value.get("title"):
9+
title = value["title"]
10+
if value.get("type"):
11+
type_string = value["type"]
12+
if value.get("anyOf"):
13+
type_string = " or ".join(item["type"] for item in value["anyOf"])
14+
output = f"{title} ({type_string})"
15+
if value.get("allOf"):
16+
linked_entity = value["allOf"][0]["$ref"].split("/")[2]
17+
output = f"{linked_entity} (object)"
18+
return output

home/templatetags/snippets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _align_snippet(snippet, max_chars):
5454
Align a snippet to a few words before start_mark_idx
5555
"""
5656
start_mark_idx = snippet.find("<mark>")
57-
end_mark_idx = snippet[start_mark_idx + 1 :].find("</mark>")
57+
end_mark_idx = snippet[start_mark_idx + 1:].find("</mark>")
5858

5959
# If the mark is at the beginning of the first remaining paragraph,
6060
# no further alignment is required.

home/urls.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
path("", views.home_view, name="home"),
99
path("search", views.search_view, name="search"),
1010
path("glossary", views.glossary_view, name="glossary"),
11-
path("details/<str:result_type>/<str:urn>", views.details_view, name="details"),
11+
path(
12+
"metadata_specification",
13+
views.metadata_specification_view,
14+
name="metadata_specification",
15+
),
16+
path(
17+
"details/<str:result_type>/<str:urn>",
18+
views.details_view,
19+
name="details",
20+
),
1221
path("pagination/<str:page>", views.search_view, name="pagination"),
1322
]

home/views.py

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
DatasetDetailsService,
1010
)
1111
from home.service.glossary import GlossaryService
12+
from home.service.metadata_specification import MetadataSpecificationService
1213
from home.service.search import SearchService
1314

1415

@@ -83,3 +84,10 @@ def search_view(request, page: str = "1"):
8384
def glossary_view(request):
8485
glossary_service = GlossaryService()
8586
return render(request, "glossary.html", glossary_service.context)
87+
88+
89+
def metadata_specification_view(request):
90+
metadata_specification = MetadataSpecificationService()
91+
return render(
92+
request, "metadata_specification.html", metadata_specification.context
93+
)

lib/datahub-client/data_platform_catalogue/client/datahub_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def get_table_details(self, urn) -> Table:
235235
else:
236236
relations = {}
237237
return Table(
238-
urn=None,
238+
urn=urn,
239239
display_name=display_name,
240240
name=name,
241241
fully_qualified_name=qualified_name,

0 commit comments

Comments
 (0)