Skip to content

Commit

Permalink
Adding a new workunit processor to check correctness of an aspect
Browse files Browse the repository at this point in the history
  • Loading branch information
skrydal committed Dec 9, 2024
1 parent 3c388a5 commit d259e91
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions metadata-ingestion/src/datahub/ingestion/api/source_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@ def create_dataset_props_patch_builder(
return patch_builder


def check_mcp_correctness(mcp: MetadataChangeProposalClass):
logger.debug(f"Processing as MCP with urn: {mcp.entityUrn} and aspect: {mcp.aspectName}, change type: {mcp.changeType}")
logger.debug(f"{mcp.aspect}")


def check_mcpw_correctness(mcp: MetadataChangeProposalWrapper):
logger.debug(f"Processing as MCP with urn: {mcp.entityUrn} and aspect: {mcp.aspectName}, change type: {mcp.changeType}")
logger.debug(f"{mcp.aspect}")


def check_workunit_correctness(stream: Iterable[MetadataWorkUnit]) -> Iterable[MetadataWorkUnit]:
for wu in stream:
logger.debug(f"Checking correctnes for workunit: {wu.id}")
if isinstance(wu.metadata, MetadataChangeProposalClass):
check_mcp_correctness(wu.metadata)
elif isinstance(wu.metadata, MetadataChangeProposalWrapper):
check_mcpw_correctness(wu.metadata)


def create_dataset_owners_patch_builder(
dataset_urn: str,
ownership: Ownership,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
)
from datahub.ingestion.api.source_helpers import (
create_dataset_owners_patch_builder,
create_dataset_props_patch_builder,
create_dataset_props_patch_builder, check_workunit_correctness,
)
from datahub.ingestion.api.workunit import MetadataWorkUnit
from datahub.ingestion.source.aws import s3_util
Expand Down Expand Up @@ -260,6 +260,7 @@ def get_workunit_processors(self) -> List[Optional[MetadataWorkUnitProcessor]]:
StaleEntityRemovalHandler.create(
self, self.config, self.ctx
).workunit_processor,
check_workunit_correctness
]

def get_workunits_internal(self) -> Iterable[MetadataWorkUnit]:
Expand Down

0 comments on commit d259e91

Please sign in to comment.