Skip to content

Commit

Permalink
small refactoring of hidden asset check
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanik Häni authored and Yanik Häni committed Nov 14, 2024
1 parent ca876f5 commit 249ca09
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions metadata-ingestion/src/datahub/ingestion/source/tableau/tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,11 @@ def get_data_platform_instance(self) -> DataPlatformInstanceClass:
),
)

def _is_hidden_view(self, dashboard_or_view: Dict):
# LUID is blank if the view is hidden in the workbook.
# More info here: https://help.tableau.com/current/api/metadata_api/en-us/reference/view.doc.html
return not dashboard_or_view.get(c.LUID)

def get_connection_object_page(
self,
query: str,
Expand Down Expand Up @@ -2622,9 +2627,7 @@ def emit_sheets(self) -> Iterable[MetadataWorkUnit]:
c.SHEETS_CONNECTION,
sheets_filter,
):
# LUID is blank if the view is hidden in the workbook.
# More info here: https://help.tableau.com/current/api/metadata_api/en-us/reference/view.doc.html
if self.config.ingest_hidden_assets or sheet.get(c.LUID):
if self.config.ingest_hidden_assets or not self._is_hidden_view(sheet):
yield from self.emit_sheets_as_charts(sheet, sheet.get(c.WORKBOOK))
else:
logger.debug(
Expand Down Expand Up @@ -2721,8 +2724,7 @@ def emit_sheets_as_charts(

# Tags
tags = self.get_tags(sheet)
if len(self.config.tags_for_hidden_assets) > 0 and not sheet.get(c.LUID):
# Add hidden tags if sheet is hidden (blank luid)
if len(self.config.tags_for_hidden_assets) > 0 and self._is_hidden_view(sheet):
tags.extend(self.config.tags_for_hidden_assets)

chart_snapshot.aspects.append(
Expand Down Expand Up @@ -2928,9 +2930,8 @@ def emit_dashboards(self) -> Iterable[MetadataWorkUnit]:
c.DASHBOARDS_CONNECTION,
dashboards_filter,
):
# LUID is blank if the dashboard is hidden in the workbook.
# More info here: https://help.tableau.com/current/api/metadata_api/en-us/reference/dashboard.doc.html
if self.config.ingest_hidden_assets or dashboard.get(c.LUID):

if self.config.ingest_hidden_assets or not self._is_hidden_view(dashboard):
yield from self.emit_dashboard(dashboard, dashboard.get(c.WORKBOOK))
else:
logger.debug(
Expand Down Expand Up @@ -2997,8 +2998,7 @@ def emit_dashboard(
dashboard_snapshot.aspects.append(dashboard_info_class)

tags = self.get_tags(dashboard)
if len(self.config.tags_for_hidden_assets) > 0 and not dashboard.get(c.LUID):
# Add hidden tags if dashboard is hidden (blank luid)
if len(self.config.tags_for_hidden_assets) > 0 and self._is_hidden_view(dashboard):
tags.extend(self.config.tags_for_hidden_assets)

dashboard_snapshot.aspects.append(
Expand Down

0 comments on commit 249ca09

Please sign in to comment.