Skip to content

Commit

Permalink
feat(ingest): generate urn types for all entities (#11676)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 authored Oct 22, 2024
1 parent cdb23ac commit 7f6f18c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
3 changes: 0 additions & 3 deletions metadata-ingestion/scripts/avro_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,6 @@ def write_urn_classes(key_aspects: List[dict], urn_dir: Path) -> None:

for aspect in key_aspects:
entity_type = aspect["Aspect"]["keyForEntity"]
if aspect["Aspect"]["entityCategory"] == "internal":
continue

code += generate_urn_class(entity_type, aspect)

(urn_dir / "urn_defs.py").write_text(code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
from datahub.emitter.mcp import MetadataChangeProposalWrapper
from datahub.emitter.mcp_builder import DatahubKey
from datahub.ingestion.graph.client import DataHubGraph
from datahub.metadata.urns import DataPlatformUrn, PlatformResourceUrn, Urn
from datahub.metadata.urns import (
DataPlatformInstanceUrn,
DataPlatformUrn,
PlatformResourceUrn,
Urn,
)
from datahub.utilities.openapi_utils import OpenAPIGraphClient
from datahub.utilities.search_utils import (
ElasticDocumentQuery,
Expand Down Expand Up @@ -76,21 +81,6 @@ def to_resource_info(self) -> models.PlatformResourceInfoClass:
)


class DataPlatformInstanceUrn:
"""
A simple implementation of a URN class for DataPlatformInstance.
Since this is not present in the URN registry, we need to implement it here.
"""

@staticmethod
def create_from_id(platform_instance_urn: str) -> Urn:
if platform_instance_urn.startswith("urn:li:platformInstance:"):
string_urn = platform_instance_urn
else:
string_urn = f"urn:li:platformInstance:{platform_instance_urn}"
return Urn.from_string(string_urn)


class UrnSearchField(SearchField):
"""
A search field that supports URN values.
Expand Down Expand Up @@ -130,7 +120,7 @@ class PlatformResourceSearchFields:
PLATFORM_INSTANCE = PlatformResourceSearchField.from_search_field(
UrnSearchField(
field_name="platformInstance.keyword",
urn_value_extractor=DataPlatformInstanceUrn.create_from_id,
urn_value_extractor=DataPlatformInstanceUrn.from_string,
)
)

Expand Down

0 comments on commit 7f6f18c

Please sign in to comment.