Skip to content

Commit

Permalink
feat(ingest/looker): cleanup error handling (#9135)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 committed Oct 30, 2023
1 parent 58bcedc commit 51d6d1f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
6 changes: 5 additions & 1 deletion metadata-ingestion/src/datahub/ingestion/api/workunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class MetadataWorkUnit(WorkUnit):
metadata: Union[
MetadataChangeEvent, MetadataChangeProposal, MetadataChangeProposalWrapper
]
# A workunit creator can determine if this workunit is allowed to fail

# A workunit creator can determine if this workunit is allowed to fail.
# TODO: This flag was initially added during the rollout of the subType aspect
# to improve backwards compatibility, but is not really needed anymore and so
# should be removed.
treat_errors_as_warnings: bool = False

# When this is set to false, this MWU will be ignored by automatic helpers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,12 @@ def get_user(self, id_: str, user_fields: str) -> Optional[User]:
transport_options=self.transport_options,
)
except SDKError as e:
logger.warning(f"Could not find user with id {id_}")
logger.warning(f"Failure was {e}")
if "Looker Not Found (404)" in str(e):
# User not found
logger.info(f"Could not find user with id {id_}: 404 error")
else:
logger.warning(f"Could not find user with id {id_}")
logger.warning(f"Failure was {e}")
# User not found
return None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,14 +926,7 @@ def process_metrics_dimensions_and_fields_for_dashboard(
mcps = chart_mcps
mcps.append(dashboard_mcp)

workunits = [
MetadataWorkUnit(
id=f"looker-{mcp.aspectName}-{mcp.entityUrn}",
mcp=mcp,
treat_errors_as_warnings=True,
)
for mcp in mcps
]
workunits = [mcp.as_workunit() for mcp in mcps]

return workunits

Expand Down Expand Up @@ -1320,10 +1313,7 @@ def get_workunits_internal(self) -> Iterable[MetadataWorkUnit]:
id=f"looker-{event.proposedSnapshot.urn}", mce=event
)
elif isinstance(event, MetadataChangeProposalWrapper):
# We want to treat subtype aspects as optional, so allowing failures in this aspect to be treated as warnings rather than failures
yield event.as_workunit(
treat_errors_as_warnings=event.aspectName in ["subTypes"]
)
yield event.as_workunit()
else:
raise Exception(f"Unexpected type of event {event}")
self.reporter.report_stage_end("explore_metadata")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2171,10 +2171,7 @@ def get_internal_workunits(self) -> Iterable[MetadataWorkUnit]: # noqa: C901
for mcp in self._build_dataset_mcps(
maybe_looker_view
):
# We want to treat mcp aspects as optional, so allowing failures in this aspect to be treated as warnings rather than failures
yield mcp.as_workunit(
treat_errors_as_warnings=True
)
yield mcp.as_workunit()
else:
(
prev_model_name,
Expand Down

0 comments on commit 51d6d1f

Please sign in to comment.