diff --git a/metadata-ingestion/examples/recipes/mlflow_to_datahub.dhub.yaml b/metadata-ingestion/examples/recipes/mlflow_to_datahub.dhub.yaml new file mode 100644 index 0000000000000..07e9ed5d786cd --- /dev/null +++ b/metadata-ingestion/examples/recipes/mlflow_to_datahub.dhub.yaml @@ -0,0 +1,9 @@ +source: + type: mlflow + config: + tracking_uri: "http://127.0.0.1:5000" + +sink: + type: datahub-rest + config: + server: "http://localhost:8080" \ No newline at end of file diff --git a/metadata-ingestion/src/datahub/emitter/mcp.py b/metadata-ingestion/src/datahub/emitter/mcp.py index c6fcfad2e0aba..75a7dc4e8740c 100644 --- a/metadata-ingestion/src/datahub/emitter/mcp.py +++ b/metadata-ingestion/src/datahub/emitter/mcp.py @@ -14,7 +14,7 @@ SystemMetadataClass, _Aspect, ) -from datahub.utilities.urns.urn import guess_entity_type +from datahub.utilities.urns.urn import Urn, guess_entity_type if TYPE_CHECKING: from datahub.ingestion.api.workunit import MetadataWorkUnit @@ -71,7 +71,11 @@ class MetadataChangeProposalWrapper: systemMetadata: Union[None, SystemMetadataClass] = None def __post_init__(self) -> None: - if self.entityUrn and self.entityType == _ENTITY_TYPE_UNSET: + if isinstance(self.entityUrn, Urn): + if self.entityType == _ENTITY_TYPE_UNSET: + self.entityType = self.entityUrn.entity_type + self.entityUrn = str(self.entityUrn) + elif self.entityUrn and self.entityType == _ENTITY_TYPE_UNSET: self.entityType = guess_entity_type(self.entityUrn) elif self.entityUrn and self.entityType: guessed_entity_type = guess_entity_type(self.entityUrn).lower() @@ -105,6 +109,7 @@ def construct_many( return [cls(entityUrn=entityUrn, aspect=aspect) for aspect in aspects if aspect] def _make_mcp_without_aspects(self) -> MetadataChangeProposalClass: + assert self.entityUrn is None or isinstance(self.entityUrn, str) return MetadataChangeProposalClass( entityType=self.entityType, entityUrn=self.entityUrn,