-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ingestion/looker): ingest looks not part of dashboard #8140
Merged
anshbansal
merged 15 commits into
datahub-project:master
from
siddiquebagwan:master+ingest-look-not-part-of-dashboard
Jun 8, 2023
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6b5eebc
WIP
siddiquebagwan-gslab 000e6aa
ingest looks not part of dashboard
siddiquebagwan-gslab 41c9388
resolve merge conflict
siddiquebagwan-gslab d45b3de
Merge branch 'master' into master+ingest-look-not-part-of-dashboard
siddiquebagwan 1033eaa
Merge branch 'master' into master+ingest-look-not-part-of-dashboard
siddiquebagwan ea168b5
fix test
siddiquebagwan-gslab 316242b
Merge branch 'master' into master+ingest-look-not-part-of-dashboard
siddiquebagwan 4958f8c
resolve merge conflict
siddiquebagwan-gslab 58fcf99
Merge branch 'master' into master+ingest-look-not-part-of-dashboard
siddiquebagwan b170f86
review comments
siddiquebagwan-gslab db61f9a
Merge branch 'master' into master+ingest-look-not-part-of-dashboard
siddiquebagwan ee004b4
Merge branch 'master' into master+ingest-look-not-part-of-dashboard
siddiquebagwan 9831bb3
review comments
siddiquebagwan-gslab a77ed35
Merge branch 'master' into master+ingest-look-not-part-of-dashboard
siddiquebagwan-gslab f09547b
Merge branch 'master' into master+ingest-look-not-part-of-dashboard
siddiquebagwan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ | |
TestableSource, | ||
TestConnectionReport, | ||
) | ||
from datahub.ingestion.api.source_helpers import auto_workunit | ||
from datahub.ingestion.api.workunit import MetadataWorkUnit | ||
from datahub.ingestion.source.looker import looker_usage | ||
from datahub.ingestion.source.looker.looker_common import ( | ||
|
@@ -126,7 +127,7 @@ class LookerDashboardSource(TestableSource, StatefulIngestionSourceBase): | |
accessed_dashboards: int = 0 | ||
resolved_user_ids: int = 0 | ||
email_ids_missing: int = 0 # resolved users with missing email addresses | ||
reachable_look_registry: List[ | ||
reachable_look_registry: Set[ | ||
str | ||
] # Keep track of look-id which are reachable from Dashboard | ||
|
||
|
@@ -141,7 +142,7 @@ def __init__(self, config: LookerDashboardSourceConfig, ctx: PipelineContext): | |
) | ||
self.reporter._looker_explore_registry = self.explore_registry | ||
self.reporter._looker_api = self.looker_api | ||
self.reachable_look_registry = [] | ||
self.reachable_look_registry = set() | ||
|
||
self.explores_to_fetch_set: Dict[Tuple[str, str], List[str]] = {} | ||
|
||
|
@@ -574,7 +575,9 @@ def _get_chart_type( | |
def _make_chart_metadata_events( | ||
self, | ||
dashboard_element: LookerDashboardElement, | ||
dashboard: Optional[LookerDashboard], | ||
dashboard: Optional[ | ||
LookerDashboard | ||
], # dashboard will be None if this is a standalone look | ||
) -> List[Union[MetadataChangeEvent, MetadataChangeProposalWrapper]]: | ||
chart_urn = builder.make_chart_urn( | ||
self.source_config.platform_name, dashboard_element.get_urn_element_id() | ||
|
@@ -860,7 +863,7 @@ def _get_looker_dashboard( | |
if element.look_id is not None: | ||
# Keeping track of reachable element from Dashboard | ||
# Later we need to ingest looks which are not reachable from any dashboard | ||
self.reachable_look_registry.append(element.look_id) | ||
self.reachable_look_registry.add(element.look_id) | ||
looker_dashboard_element = self._get_looker_dashboard_element(element) | ||
if looker_dashboard_element is not None: | ||
dashboard_elements.append(looker_dashboard_element) | ||
|
@@ -1125,21 +1128,21 @@ def get_workunit_processors(self) -> List[Optional[MetadataWorkUnitProcessor]]: | |
def emit_independent_looks_mcp( | ||
self, dashboard_element: LookerDashboardElement | ||
) -> Iterable[MetadataWorkUnit]: | ||
yield from [ | ||
MetadataWorkUnit(id=f"looker-{mce.proposedSnapshot.urn}", mce=mce) | ||
if isinstance(mce, MetadataChangeEvent) | ||
else MetadataWorkUnit( | ||
id=f"looker-{mce.aspectName}-{mce.entityUrn}", mcp=mce | ||
) | ||
for mce in self._make_chart_metadata_events( | ||
dashboard_element=dashboard_element, dashboard=None | ||
|
||
yield from auto_workunit( | ||
stream=self._make_chart_metadata_events( | ||
dashboard_element=dashboard_element, | ||
dashboard=None, | ||
) | ||
] | ||
) | ||
|
||
mcp: MetadataChangeProposalWrapper = self._make_metrics_dimensions_chart_mcp( | ||
dashboard_element | ||
yield from auto_workunit( | ||
[ | ||
self._make_metrics_dimensions_chart_mcp( | ||
dashboard_element, | ||
) | ||
] | ||
) | ||
yield MetadataWorkUnit(id=f"looker-{mcp.entityUrn}", mcp=mcp) | ||
|
||
def extract_independent_looks(self) -> Iterable[MetadataWorkUnit]: | ||
""" | ||
|
@@ -1148,6 +1151,8 @@ def extract_independent_looks(self) -> Iterable[MetadataWorkUnit]: | |
if self.source_config.extract_independent_looks is False: | ||
return | ||
|
||
self.reporter.report_stage_start("extract_independent_looks") | ||
|
||
logger.debug("Extracting looks not part of Dashboard") | ||
look_fields: List[str] = [ | ||
"id", | ||
|
@@ -1165,7 +1170,9 @@ def extract_independent_looks(self) -> Iterable[MetadataWorkUnit]: | |
"slug", | ||
] | ||
|
||
all_looks: List[Look] = self.looker_api.all_looks(fields=look_fields) | ||
all_looks: List[Look] = self.looker_api.all_looks( | ||
fields=look_fields, soft_deleted=self.source_config.include_deleted | ||
) | ||
for look in all_looks: | ||
if look.id in self.reachable_look_registry: | ||
# This look is reachable from Dashboard | ||
|
@@ -1181,11 +1188,11 @@ def extract_independent_looks(self) -> Iterable[MetadataWorkUnit]: | |
LookerDashboardElement | ||
] = self._get_looker_dashboard_element( | ||
DashboardElement( | ||
id=f"looks_{look.id}", # to avoid conflict with element.id prefixing "looks_" to look.id. | ||
id=f"looks_{look.id}", # to avoid conflict with non-standalone looks (element.id prefixes), we add the "looks_" prefix to look.id. | ||
title=look.title, | ||
subtitle_text=look.description, | ||
look_id=look.id, | ||
dashboard_id="NOT AVAILABLE", | ||
dashboard_id=None, # As this is independent look | ||
look=LookWithQuery(query=query), | ||
) | ||
) | ||
|
@@ -1196,6 +1203,8 @@ def extract_independent_looks(self) -> Iterable[MetadataWorkUnit]: | |
dashboard_element=dashboard_element | ||
) | ||
|
||
self.reporter.report_stage_end("extract_independent_looks") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation is off here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
def get_workunits_internal(self) -> Iterable[MetadataWorkUnit]: | ||
self.reporter.report_stage_start("list_dashboards") | ||
dashboards = self.looker_api.all_dashboards(fields="id") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done