Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar-salvi-apptware committed Dec 17, 2024
1 parent 056bf68 commit a87907e
Showing 1 changed file with 15 additions and 28 deletions.
43 changes: 15 additions & 28 deletions metadata-ingestion/src/datahub/sql_parsing/tool_meta_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,9 @@ def __init__(
def create(
cls,
graph: Optional[DataHubGraph] = None,
report: Optional[ToolMetaExtractorReport] = None,
) -> "ToolMetaExtractor":
if report is None:
report = ToolMetaExtractorReport()

report = ToolMetaExtractorReport()
looker_user_mapping = None
if graph:
query = (
ElasticPlatformResourceQuery.create_from()
Expand All @@ -98,31 +96,23 @@ def create(
)
]

if platform_resources is None:
report.failures.append(
"Looker user metadata extraction failed. No Looker user id mappings found."
)
return cls(report=report)

if len(platform_resources) > 1:
report.failures.append(
"Looker user metadata extraction failed. Found more than one looker user id mappings."
)
return cls(report)

platform_resource = platform_resources[0]

if (
platform_resource
and platform_resource.resource_info
and platform_resource.resource_info.value
):
with contextlib.suppress(ValueError, AssertionError):
value = platform_resource.resource_info.value.as_raw_json()
if value:
assert isinstance(value, dict)
return cls(report, looker_user_mapping=value)
return cls(report)
else:
platform_resource = platform_resources[0]

if (
platform_resource
and platform_resource.resource_info
and platform_resource.resource_info.value
):
with contextlib.suppress(ValueError, AssertionError):
value = platform_resource.resource_info.value.as_raw_json()
if value:
looker_user_mapping = value
return cls(report, looker_user_mapping)

def _extract_mode_query(self, entry: QueryLog) -> bool:
"""
Expand Down Expand Up @@ -193,9 +183,6 @@ def extract_bi_metadata(self, entry: QueryLog) -> bool:
self.report.num_queries_meta_extracted[tool] += 1
return True
except Exception as e:
self.report.failures.append(
f"Tool metadata extraction failed with error : {e}"
)
logger.debug(f"Tool metadata extraction failed with error : {e}")
return False

Expand Down

0 comments on commit a87907e

Please sign in to comment.