From ce6474df5a554e2462afe8d48374d51db02dce97 Mon Sep 17 00:00:00 2001 From: Harshal Sheth Date: Mon, 2 Dec 2024 12:53:13 -0500 Subject: [PATCH] chore(ingest): remove deprecated calls to Urn.create_from_string (#11983) --- .../structuredproperties.py | 2 +- metadata-ingestion/src/datahub/cli/put_cli.py | 2 +- .../datahub/cli/specific/dataproduct_cli.py | 2 +- .../src/datahub/emitter/mcp_patch_builder.py | 43 ++++++++++++++++ .../source/bigquery_v2/bigquery_audit.py | 2 +- .../datahub/ingestion/source/csv_enricher.py | 2 +- .../ingestion/source/elastic_search.py | 2 +- .../source/gc/soft_deleted_entity_cleanup.py | 2 +- .../ingestion/transformer/add_dataset_tags.py | 2 +- .../transformer/generic_aspect_transformer.py | 2 +- .../datahub/integrations/assertion/common.py | 2 +- .../src/datahub/lite/duckdb_lite.py | 29 +++++------ .../src/datahub/specific/chart.py | 39 --------------- .../src/datahub/specific/dashboard.py | 39 --------------- .../src/datahub/specific/datajob.py | 50 ++----------------- .../src/datahub/utilities/urns/_urn_base.py | 2 +- .../urns/structured_properties_urn.py | 2 +- .../tests/test_helpers/mce_helpers.py | 4 +- .../unit/test_generic_aspect_transformer.py | 4 +- .../tests/unit/test_transform_dataset.py | 4 +- 20 files changed, 76 insertions(+), 160 deletions(-) diff --git a/metadata-ingestion/src/datahub/api/entities/structuredproperties/structuredproperties.py b/metadata-ingestion/src/datahub/api/entities/structuredproperties/structuredproperties.py index 56e02e4329055a..181c70adc640a6 100644 --- a/metadata-ingestion/src/datahub/api/entities/structuredproperties/structuredproperties.py +++ b/metadata-ingestion/src/datahub/api/entities/structuredproperties/structuredproperties.py @@ -121,7 +121,7 @@ def fqn(self) -> str: return ( self.qualified_name or self.id - or Urn.create_from_string(self.urn).get_entity_id()[0] + or Urn.from_string(self.urn).get_entity_id()[0] ) @validator("urn", pre=True, always=True) diff --git a/metadata-ingestion/src/datahub/cli/put_cli.py b/metadata-ingestion/src/datahub/cli/put_cli.py index 0a40a9f4ccf92d..d3a6fb5caaf197 100644 --- a/metadata-ingestion/src/datahub/cli/put_cli.py +++ b/metadata-ingestion/src/datahub/cli/put_cli.py @@ -105,7 +105,7 @@ def platform( """ if name.startswith(f"urn:li:{DataPlatformUrn.ENTITY_TYPE}"): - platform_urn = DataPlatformUrn.create_from_string(name) + platform_urn = DataPlatformUrn.from_string(name) platform_name = platform_urn.get_entity_id_as_string() else: platform_name = name.lower() diff --git a/metadata-ingestion/src/datahub/cli/specific/dataproduct_cli.py b/metadata-ingestion/src/datahub/cli/specific/dataproduct_cli.py index 8ec4d3ad249376..857a6fbb4e18e5 100644 --- a/metadata-ingestion/src/datahub/cli/specific/dataproduct_cli.py +++ b/metadata-ingestion/src/datahub/cli/specific/dataproduct_cli.py @@ -45,7 +45,7 @@ def _get_owner_urn(maybe_urn: str) -> str: def _abort_if_non_existent_urn(graph: DataHubGraph, urn: str, operation: str) -> None: try: - parsed_urn: Urn = Urn.create_from_string(urn) + parsed_urn: Urn = Urn.from_string(urn) entity_type = parsed_urn.get_type() except Exception: click.secho(f"Provided urn {urn} does not seem valid", fg="red") diff --git a/metadata-ingestion/src/datahub/emitter/mcp_patch_builder.py b/metadata-ingestion/src/datahub/emitter/mcp_patch_builder.py index 37903995394379..779b42e1e1ee99 100644 --- a/metadata-ingestion/src/datahub/emitter/mcp_patch_builder.py +++ b/metadata-ingestion/src/datahub/emitter/mcp_patch_builder.py @@ -1,4 +1,5 @@ import json +import time from collections import defaultdict from dataclasses import dataclass from typing import Any, Dict, Iterable, List, Optional, Sequence, Union @@ -6,12 +7,15 @@ from datahub.emitter.aspect import JSON_PATCH_CONTENT_TYPE from datahub.emitter.serialization_helper import pre_json_transform from datahub.metadata.schema_classes import ( + AuditStampClass, ChangeTypeClass, + EdgeClass, GenericAspectClass, KafkaAuditHeaderClass, MetadataChangeProposalClass, SystemMetadataClass, ) +from datahub.metadata.urns import Urn from datahub.utilities.urns.urn import guess_entity_type @@ -89,3 +93,42 @@ def build(self) -> Iterable[MetadataChangeProposalClass]: ) for aspect_name, patches in self.patches.items() ] + + @classmethod + def _mint_auditstamp(cls, message: Optional[str] = None) -> AuditStampClass: + """ + Creates an AuditStampClass instance with the current timestamp and other default values. + + Args: + message: The message associated with the audit stamp (optional). + + Returns: + An instance of AuditStampClass. + """ + return AuditStampClass( + time=int(time.time() * 1000.0), + actor="urn:li:corpuser:datahub", + message=message, + ) + + @classmethod + def _ensure_urn_type( + cls, entity_type: str, edges: List[EdgeClass], context: str + ) -> None: + """ + Ensures that the destination URNs in the given edges have the specified entity type. + + Args: + entity_type: The entity type to check against. + edges: A list of Edge objects. + context: The context or description of the operation. + + Raises: + ValueError: If any of the destination URNs is not of the specified entity type. + """ + for e in edges: + urn = Urn.from_string(e.destinationUrn) + if not urn.entity_type == entity_type: + raise ValueError( + f"{context}: {e.destinationUrn} is not of type {entity_type}" + ) diff --git a/metadata-ingestion/src/datahub/ingestion/source/bigquery_v2/bigquery_audit.py b/metadata-ingestion/src/datahub/ingestion/source/bigquery_v2/bigquery_audit.py index 319c838d2658ad..42f82704c81b99 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/bigquery_v2/bigquery_audit.py +++ b/metadata-ingestion/src/datahub/ingestion/source/bigquery_v2/bigquery_audit.py @@ -190,7 +190,7 @@ def from_string_name(cls, ref: str) -> "BigQueryTableRef": @classmethod def from_urn(cls, urn: str) -> "BigQueryTableRef": """Raises: ValueError if urn is not a valid BigQuery table URN.""" - dataset_urn = DatasetUrn.create_from_string(urn) + dataset_urn = DatasetUrn.from_string(urn) split = dataset_urn.name.rsplit(".", 3) if len(split) == 3: project, dataset, table = split diff --git a/metadata-ingestion/src/datahub/ingestion/source/csv_enricher.py b/metadata-ingestion/src/datahub/ingestion/source/csv_enricher.py index e4829f8713cf76..42e025073b534e 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/csv_enricher.py +++ b/metadata-ingestion/src/datahub/ingestion/source/csv_enricher.py @@ -653,7 +653,7 @@ def get_workunits_internal(self) -> Iterable[MetadataWorkUnit]: is_resource_row: bool = not row["subresource"] entity_urn = row["resource"] - entity_type = Urn.create_from_string(row["resource"]).get_type() + entity_type = Urn.from_string(row["resource"]).get_type() term_associations: List[ GlossaryTermAssociationClass diff --git a/metadata-ingestion/src/datahub/ingestion/source/elastic_search.py b/metadata-ingestion/src/datahub/ingestion/source/elastic_search.py index aa5913f5dc66b1..99aa5f54f6a576 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/elastic_search.py +++ b/metadata-ingestion/src/datahub/ingestion/source/elastic_search.py @@ -227,7 +227,7 @@ def collapse_name(name: str, collapse_urns: CollapseUrns) -> str: def collapse_urn(urn: str, collapse_urns: CollapseUrns) -> str: if len(collapse_urns.urns_suffix_regex) == 0: return urn - urn_obj = DatasetUrn.create_from_string(urn) + urn_obj = DatasetUrn.from_string(urn) name = collapse_name(name=urn_obj.get_dataset_name(), collapse_urns=collapse_urns) data_platform_urn = urn_obj.get_data_platform_urn() return str( diff --git a/metadata-ingestion/src/datahub/ingestion/source/gc/soft_deleted_entity_cleanup.py b/metadata-ingestion/src/datahub/ingestion/source/gc/soft_deleted_entity_cleanup.py index 7ec7bb7e589d63..3b367cdea58134 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/gc/soft_deleted_entity_cleanup.py +++ b/metadata-ingestion/src/datahub/ingestion/source/gc/soft_deleted_entity_cleanup.py @@ -104,7 +104,7 @@ def __init__( def delete_entity(self, urn: str) -> None: assert self.ctx.graph - entity_urn = Urn.create_from_string(urn) + entity_urn = Urn.from_string(urn) self.report.num_soft_deleted_entity_removed += 1 self.report.num_soft_deleted_entity_removed_by_type[entity_urn.entity_type] = ( self.report.num_soft_deleted_entity_removed_by_type.get( diff --git a/metadata-ingestion/src/datahub/ingestion/transformer/add_dataset_tags.py b/metadata-ingestion/src/datahub/ingestion/transformer/add_dataset_tags.py index c60f4dca28882d..355ca7a373653f 100644 --- a/metadata-ingestion/src/datahub/ingestion/transformer/add_dataset_tags.py +++ b/metadata-ingestion/src/datahub/ingestion/transformer/add_dataset_tags.py @@ -74,7 +74,7 @@ def handle_end_of_stream( logger.debug("Generating tags") for tag_association in self.processed_tags.values(): - tag_urn = TagUrn.create_from_string(tag_association.tag) + tag_urn = TagUrn.from_string(tag_association.tag) mcps.append( MetadataChangeProposalWrapper( entityUrn=tag_urn.urn(), diff --git a/metadata-ingestion/src/datahub/ingestion/transformer/generic_aspect_transformer.py b/metadata-ingestion/src/datahub/ingestion/transformer/generic_aspect_transformer.py index 3c0bc00633e7cb..5bf70274dce89d 100644 --- a/metadata-ingestion/src/datahub/ingestion/transformer/generic_aspect_transformer.py +++ b/metadata-ingestion/src/datahub/ingestion/transformer/generic_aspect_transformer.py @@ -100,7 +100,7 @@ def transform( ) if transformed_aspect: # for end of stream records, we modify the workunit-id - structured_urn = Urn.create_from_string(urn) + structured_urn = Urn.from_string(urn) simple_name = "-".join(structured_urn.get_entity_id()) record_metadata = envelope.metadata.copy() record_metadata.update( diff --git a/metadata-ingestion/src/datahub/integrations/assertion/common.py b/metadata-ingestion/src/datahub/integrations/assertion/common.py index 9ffad5cf66640a..f0b7510df14a35 100644 --- a/metadata-ingestion/src/datahub/integrations/assertion/common.py +++ b/metadata-ingestion/src/datahub/integrations/assertion/common.py @@ -42,7 +42,7 @@ def get_entity_name(assertion: BaseEntityAssertion) -> Tuple[str, str, str]: if qualified_name is not None: parts = qualified_name.split(".") else: - urn_id = Urn.create_from_string(assertion.entity).entity_ids[1] + urn_id = Urn.from_string(assertion.entity).entity_ids[1] parts = urn_id.split(".") if len(parts) > 3: parts = parts[-3:] diff --git a/metadata-ingestion/src/datahub/lite/duckdb_lite.py b/metadata-ingestion/src/datahub/lite/duckdb_lite.py index f40a2e9498e62c..89317383520923 100644 --- a/metadata-ingestion/src/datahub/lite/duckdb_lite.py +++ b/metadata-ingestion/src/datahub/lite/duckdb_lite.py @@ -609,7 +609,7 @@ def get_typed_aspect( aspect_map, DataPlatformInstanceClass ) # type: ignore - needs_platform = Urn.create_from_string(entity_urn).get_type() in [ + needs_platform = Urn.from_string(entity_urn).get_type() in [ "dataset", "container", "chart", @@ -617,7 +617,7 @@ def get_typed_aspect( "dataFlow", "dataJob", ] - entity_urn_parsed = Urn.create_from_string(entity_urn) + entity_urn_parsed = Urn.from_string(entity_urn) if entity_urn_parsed.get_type() in ["dataFlow", "dataJob"]: self.add_edge( entity_urn, @@ -630,15 +630,12 @@ def get_typed_aspect( # this is a top-level entity if not dpi: logger.debug(f"No data platform instance for {entity_urn}") - maybe_parent_urn = Urn.create_from_string(entity_urn).get_entity_id()[0] + maybe_parent_urn = Urn.from_string(entity_urn).get_entity_id()[0] needs_dpi = False if maybe_parent_urn.startswith(Urn.URN_PREFIX): parent_urn = maybe_parent_urn - if ( - Urn.create_from_string(maybe_parent_urn).get_type() - == "dataPlatform" - ): - data_platform_urn = DataPlatformUrn.create_from_string( + if Urn.from_string(maybe_parent_urn).get_type() == "dataPlatform": + data_platform_urn = DataPlatformUrn.from_string( maybe_parent_urn ) needs_dpi = True @@ -660,7 +657,7 @@ def get_typed_aspect( logger.error(f"Failed to generate edges entity {entity_urn}", e) parent_urn = str(data_platform_instance_urn) else: - data_platform_urn = DataPlatformUrn.create_from_string(dpi.platform) + data_platform_urn = DataPlatformUrn.from_string(dpi.platform) data_platform_instance = dpi.instance or "default" data_platform_instance_urn = Urn( entity_type="dataPlatformInstance", @@ -673,9 +670,7 @@ def get_typed_aspect( parent_urn = "__root__" types = ( - subtypes.typeNames - if subtypes - else [Urn.create_from_string(entity_urn).get_type()] + subtypes.typeNames if subtypes else [Urn.from_string(entity_urn).get_type()] ) for t in types: type_urn = Urn(entity_type="systemNode", entity_id=[parent_urn, t]) @@ -686,7 +681,7 @@ def get_typed_aspect( def _create_edges_from_data_platform_instance( self, data_platform_instance_urn: Urn ) -> None: - data_platform_urn = DataPlatformUrn.create_from_string( + data_platform_urn = DataPlatformUrn.from_string( data_platform_instance_urn.get_entity_id()[0] ) data_platform_instances_urn = Urn( @@ -735,7 +730,7 @@ def post_update_hook( if isinstance(aspect, DatasetPropertiesClass): dp: DatasetPropertiesClass = aspect if dp.name: - specific_urn = DatasetUrn.create_from_string(entity_urn) + specific_urn = DatasetUrn.from_string(entity_urn) if ( specific_urn.get_data_platform_urn().get_entity_id_as_string() == "looker" @@ -755,7 +750,7 @@ def post_update_hook( self.add_edge(entity_urn, "name", cp.name, remove_existing=True) elif isinstance(aspect, DataPlatformInstanceClass): dpi: DataPlatformInstanceClass = aspect - data_platform_urn = DataPlatformUrn.create_from_string(dpi.platform) + data_platform_urn = DataPlatformUrn.from_string(dpi.platform) data_platform_instance = dpi.instance or "default" data_platform_instance_urn = Urn( entity_type="dataPlatformInstance", @@ -763,7 +758,7 @@ def post_update_hook( ) self._create_edges_from_data_platform_instance(data_platform_instance_urn) elif isinstance(aspect, ChartInfoClass): - urn = Urn.create_from_string(entity_urn) + urn = Urn.from_string(entity_urn) self.add_edge( entity_urn, "name", @@ -771,7 +766,7 @@ def post_update_hook( remove_existing=True, ) elif isinstance(aspect, DashboardInfoClass): - urn = Urn.create_from_string(entity_urn) + urn = Urn.from_string(entity_urn) self.add_edge( entity_urn, "name", diff --git a/metadata-ingestion/src/datahub/specific/chart.py b/metadata-ingestion/src/datahub/specific/chart.py index cc68168b68db7e..104a7c21a07e2f 100644 --- a/metadata-ingestion/src/datahub/specific/chart.py +++ b/metadata-ingestion/src/datahub/specific/chart.py @@ -1,10 +1,8 @@ -import time from typing import Dict, List, Optional, Union from datahub.emitter.mcp_patch_builder import MetadataPatchProposal from datahub.metadata.schema_classes import ( AccessLevelClass, - AuditStampClass, ChangeAuditStampsClass, ChartInfoClass as ChartInfo, ChartTypeClass, @@ -47,43 +45,6 @@ def __init__( ) self.ownership_patch_helper = OwnershipPatchHelper(self) - def _mint_auditstamp(self, message: Optional[str] = None) -> AuditStampClass: - """ - Creates an AuditStampClass instance with the current timestamp and other default values. - - Args: - message: The message associated with the audit stamp (optional). - - Returns: - An instance of AuditStampClass. - """ - return AuditStampClass( - time=int(time.time() * 1000.0), - actor="urn:li:corpuser:datahub", - message=message, - ) - - def _ensure_urn_type( - self, entity_type: str, edges: List[Edge], context: str - ) -> None: - """ - Ensures that the destination URNs in the given edges have the specified entity type. - - Args: - entity_type: The entity type to check against. - edges: A list of Edge objects. - context: The context or description of the operation. - - Raises: - ValueError: If any of the destination URNs is not of the specified entity type. - """ - for e in edges: - urn = Urn.create_from_string(e.destinationUrn) - if not urn.get_type() == entity_type: - raise ValueError( - f"{context}: {e.destinationUrn} is not of type {entity_type}" - ) - def add_owner(self, owner: Owner) -> "ChartPatchBuilder": """ Adds an owner to the ChartPatchBuilder. diff --git a/metadata-ingestion/src/datahub/specific/dashboard.py b/metadata-ingestion/src/datahub/specific/dashboard.py index f57df15914369c..da5abbfd1dc129 100644 --- a/metadata-ingestion/src/datahub/specific/dashboard.py +++ b/metadata-ingestion/src/datahub/specific/dashboard.py @@ -1,10 +1,8 @@ -import time from typing import Dict, List, Optional, Union from datahub.emitter.mcp_patch_builder import MetadataPatchProposal from datahub.metadata.schema_classes import ( AccessLevelClass, - AuditStampClass, ChangeAuditStampsClass, DashboardInfoClass as DashboardInfo, EdgeClass as Edge, @@ -46,43 +44,6 @@ def __init__( ) self.ownership_patch_helper = OwnershipPatchHelper(self) - def _mint_auditstamp(self, message: Optional[str] = None) -> AuditStampClass: - """ - Creates an AuditStampClass instance with the current timestamp and other default values. - - Args: - message: The message associated with the audit stamp (optional). - - Returns: - An instance of AuditStampClass. - """ - return AuditStampClass( - time=int(time.time() * 1000.0), - actor="urn:li:corpuser:datahub", - message=message, - ) - - def _ensure_urn_type( - self, entity_type: str, edges: List[Edge], context: str - ) -> None: - """ - Ensures that the destination URNs in the given edges have the specified entity type. - - Args: - entity_type: The entity type to check against. - edges: A list of Edge objects. - context: The context or description of the operation. - - Raises: - ValueError: If any of the destination URNs is not of the specified entity type. - """ - for e in edges: - urn = Urn.create_from_string(e.destinationUrn) - if not urn.get_type() == entity_type: - raise ValueError( - f"{context}: {e.destinationUrn} is not of type {entity_type}" - ) - def add_owner(self, owner: Owner) -> "DashboardPatchBuilder": """ Adds an owner to the DashboardPatchBuilder. diff --git a/metadata-ingestion/src/datahub/specific/datajob.py b/metadata-ingestion/src/datahub/specific/datajob.py index 8da8edc8ef0f22..fb7b0ae7816f17 100644 --- a/metadata-ingestion/src/datahub/specific/datajob.py +++ b/metadata-ingestion/src/datahub/specific/datajob.py @@ -1,9 +1,7 @@ -import time from typing import Dict, List, Optional, Union from datahub.emitter.mcp_patch_builder import MetadataPatchProposal from datahub.metadata.schema_classes import ( - AuditStampClass, DataJobInfoClass as DataJobInfo, DataJobInputOutputClass as DataJobInputOutput, EdgeClass as Edge, @@ -16,10 +14,9 @@ SystemMetadataClass, TagAssociationClass as Tag, ) +from datahub.metadata.urns import SchemaFieldUrn, TagUrn, Urn from datahub.specific.custom_properties import CustomPropertiesPatchHelper from datahub.specific.ownership import OwnershipPatchHelper -from datahub.utilities.urns.tag_urn import TagUrn -from datahub.utilities.urns.urn import Urn class DataJobPatchBuilder(MetadataPatchProposal): @@ -45,43 +42,6 @@ def __init__( ) self.ownership_patch_helper = OwnershipPatchHelper(self) - def _mint_auditstamp(self, message: Optional[str] = None) -> AuditStampClass: - """ - Creates an AuditStampClass instance with the current timestamp and other default values. - - Args: - message: The message associated with the audit stamp (optional). - - Returns: - An instance of AuditStampClass. - """ - return AuditStampClass( - time=int(time.time() * 1000.0), - actor="urn:li:corpuser:datahub", - message=message, - ) - - def _ensure_urn_type( - self, entity_type: str, edges: List[Edge], context: str - ) -> None: - """ - Ensures that the destination URNs in the given edges have the specified entity type. - - Args: - entity_type: The entity type to check against. - edges: A list of Edge objects. - context: The context or description of the operation. - - Raises: - ValueError: If any of the destination URNs is not of the specified entity type. - """ - for e in edges: - urn = Urn.create_from_string(e.destinationUrn) - if not urn.get_type() == entity_type: - raise ValueError( - f"{context}: {e.destinationUrn} is not of type {entity_type}" - ) - def add_owner(self, owner: Owner) -> "DataJobPatchBuilder": """ Adds an owner to the DataJobPatchBuilder. @@ -392,9 +352,7 @@ def add_input_dataset_field(self, input: Union[Urn, str]) -> "DataJobPatchBuilde ValueError: If the input is not a Schema Field urn. """ input_urn = str(input) - urn = Urn.create_from_string(input_urn) - if not urn.get_type() == "schemaField": - raise ValueError(f"Input {input} is not a Schema Field urn") + assert SchemaFieldUrn.from_string(input_urn) self._add_patch( DataJobInputOutput.ASPECT_NAME, @@ -466,9 +424,7 @@ def add_output_dataset_field( ValueError: If the output is not a Schema Field urn. """ output_urn = str(output) - urn = Urn.create_from_string(output_urn) - if not urn.get_type() == "schemaField": - raise ValueError(f"Input {output} is not a Schema Field urn") + assert SchemaFieldUrn.from_string(output_urn) self._add_patch( DataJobInputOutput.ASPECT_NAME, diff --git a/metadata-ingestion/src/datahub/utilities/urns/_urn_base.py b/metadata-ingestion/src/datahub/utilities/urns/_urn_base.py index 1b50d4b2fe810c..7dadd16fb7f1c2 100644 --- a/metadata-ingestion/src/datahub/utilities/urns/_urn_base.py +++ b/metadata-ingestion/src/datahub/utilities/urns/_urn_base.py @@ -200,7 +200,7 @@ def get_entity_id_as_string(self) -> str: @classmethod @deprecated(reason="no longer needed") def validate(cls, urn_str: str) -> None: - Urn.create_from_string(urn_str) + Urn.from_string(urn_str) @staticmethod def url_encode(urn: str) -> str: diff --git a/metadata-ingestion/src/datahub/utilities/urns/structured_properties_urn.py b/metadata-ingestion/src/datahub/utilities/urns/structured_properties_urn.py index 6774978c7a76d9..748d5519f14773 100644 --- a/metadata-ingestion/src/datahub/utilities/urns/structured_properties_urn.py +++ b/metadata-ingestion/src/datahub/utilities/urns/structured_properties_urn.py @@ -4,4 +4,4 @@ def make_structured_property_urn(structured_property_id: str) -> str: - return str(StructuredPropertyUrn.create_from_string(structured_property_id)) + return str(StructuredPropertyUrn.from_string(structured_property_id)) diff --git a/metadata-ingestion/tests/test_helpers/mce_helpers.py b/metadata-ingestion/tests/test_helpers/mce_helpers.py index f4c629df7dba4e..0105e6d596970b 100644 --- a/metadata-ingestion/tests/test_helpers/mce_helpers.py +++ b/metadata-ingestion/tests/test_helpers/mce_helpers.py @@ -323,7 +323,7 @@ def assert_entity_mce_aspect( ) -> int: # TODO: Replace with read_metadata_file() test_output = load_json_file(file) - entity_type = Urn.create_from_string(entity_urn).get_type() + entity_type = Urn.from_string(entity_urn).get_type() assert isinstance(test_output, list) # mce urns mces: List[MetadataChangeEventClass] = [ @@ -346,7 +346,7 @@ def assert_entity_mcp_aspect( ) -> int: # TODO: Replace with read_metadata_file() test_output = load_json_file(file) - entity_type = Urn.create_from_string(entity_urn).get_type() + entity_type = Urn.from_string(entity_urn).get_type() assert isinstance(test_output, list) # mcps that match entity_urn mcps: List[MetadataChangeProposalWrapper] = [ diff --git a/metadata-ingestion/tests/unit/test_generic_aspect_transformer.py b/metadata-ingestion/tests/unit/test_generic_aspect_transformer.py index 18b0d9fd400412..52d7aa7f509c9e 100644 --- a/metadata-ingestion/tests/unit/test_generic_aspect_transformer.py +++ b/metadata-ingestion/tests/unit/test_generic_aspect_transformer.py @@ -51,7 +51,7 @@ def make_mcpw( ) -> MetadataChangeProposalWrapper: return MetadataChangeProposalWrapper( entityUrn=entity_urn, - entityType=Urn.create_from_string(entity_urn).get_type(), + entityType=Urn.from_string(entity_urn).get_type(), aspectName=aspect_name, changeType="UPSERT", aspect=aspect, @@ -65,7 +65,7 @@ def make_mcpc( ) -> MetadataChangeProposalClass: return MetadataChangeProposalClass( entityUrn=entity_urn, - entityType=Urn.create_from_string(entity_urn).get_type(), + entityType=Urn.from_string(entity_urn).get_type(), aspectName=aspect_name, changeType="UPSERT", aspect=aspect, diff --git a/metadata-ingestion/tests/unit/test_transform_dataset.py b/metadata-ingestion/tests/unit/test_transform_dataset.py index 389f7b70b3311e..5151be9c8b1997 100644 --- a/metadata-ingestion/tests/unit/test_transform_dataset.py +++ b/metadata-ingestion/tests/unit/test_transform_dataset.py @@ -122,7 +122,7 @@ def make_generic_dataset_mcp( ) -> MetadataChangeProposalWrapper: return MetadataChangeProposalWrapper( entityUrn=entity_urn, - entityType=Urn.create_from_string(entity_urn).get_type(), + entityType=Urn.from_string(entity_urn).get_type(), aspectName=aspect_name, changeType="UPSERT", aspect=aspect, @@ -138,7 +138,7 @@ def make_generic_container_mcp( aspect = models.StatusClass(removed=False) return MetadataChangeProposalWrapper( entityUrn=entity_urn, - entityType=Urn.create_from_string(entity_urn).get_type(), + entityType=Urn.from_string(entity_urn).get_type(), aspectName=aspect_name, changeType="UPSERT", aspect=aspect,