From 3f20cc64b9d7d24dbab5d66dd4450243b2f7fbc2 Mon Sep 17 00:00:00 2001 From: Harshal Sheth Date: Wed, 31 Jul 2024 12:18:27 -0700 Subject: [PATCH 1/3] fix(ingest/tableau): prevent empty site content urls Mainly a fix for instances that only have a default "" tableau site. --- .../src/datahub/ingestion/source/tableau.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/tableau.py b/metadata-ingestion/src/datahub/ingestion/source/tableau.py index 1655724f2d402..148af78fae960 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/tableau.py +++ b/metadata-ingestion/src/datahub/ingestion/source/tableau.py @@ -740,6 +740,12 @@ def _re_authenticate(self): ] = self.config.get_tableau_auth(self.site.content_url) self.server.auth.sign_in(tableau_auth) + @property + def site_content_url(self) -> str: + if self.site and self.site.content_url: + return self.site.content_url + return None + def _populate_usage_stat_registry(self) -> None: if self.server is None: return @@ -2478,7 +2484,9 @@ def emit_sheets_as_charts( last_modified = self.get_last_modified(creator, created_at, updated_at) if sheet.get(c.PATH): - site_part = f"/site/{self.site.content_url}" if self.site else "" + site_part = ( + f"/site/{self.site_content_url}" if self.site_content_url else "" + ) sheet_external_url = ( f"{self.config.connect_uri}/#{site_part}/views/{sheet.get(c.PATH)}" ) @@ -2489,7 +2497,7 @@ def emit_sheets_as_charts( and sheet[c.CONTAINED_IN_DASHBOARDS][0].get(c.PATH) ): # sheet contained in dashboard - site_part = f"/t/{self.site.content_url}" if self.site else "" + site_part = f"/t/{self.site_content_url}" if self.site_content_url else "" dashboard_path = sheet[c.CONTAINED_IN_DASHBOARDS][0][c.PATH] sheet_external_url = f"{self.config.connect_uri}{site_part}/authoring/{dashboard_path}/{quote(sheet.get(c.NAME, ''), safe='')}" else: @@ -2621,7 +2629,7 @@ def emit_workbook_as_container(self, workbook: Dict) -> Iterable[MetadataWorkUni else None ) - site_part = f"/site/{self.site.content_url}" if self.site else "" + site_part = f"/site/{self.site_content_url}" if self.site_content_url else "" workbook_uri = workbook.get("uri") workbook_part = ( workbook_uri[workbook_uri.index("/workbooks/") :] if workbook_uri else None @@ -2780,7 +2788,7 @@ def emit_dashboard( updated_at = dashboard.get(c.UPDATED_AT, datetime.now()) last_modified = self.get_last_modified(creator, created_at, updated_at) - site_part = f"/site/{self.site.content_url}" if self.site else "" + site_part = f"/site/{self.site_content_url}" if self.site_content_url else "" dashboard_external_url = ( f"{self.config.connect_uri}/#{site_part}/views/{dashboard.get(c.PATH, '')}" ) From 9c7407644cecc5ac561e160d408642e170cde0da Mon Sep 17 00:00:00 2001 From: Harshal Sheth Date: Wed, 31 Jul 2024 12:38:53 -0700 Subject: [PATCH 2/3] Update metadata-ingestion/src/datahub/ingestion/source/tableau.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- metadata-ingestion/src/datahub/ingestion/source/tableau.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/tableau.py b/metadata-ingestion/src/datahub/ingestion/source/tableau.py index 4a1bf278f119a..00a230900af94 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/tableau.py +++ b/metadata-ingestion/src/datahub/ingestion/source/tableau.py @@ -758,11 +758,10 @@ def _re_authenticate(self): self.server.auth.sign_in(tableau_auth) @property - def site_content_url(self) -> str: + def site_content_url(self) -> Optional[str]: if self.site and self.site.content_url: return self.site.content_url return None - def _populate_usage_stat_registry(self) -> None: if self.server is None: return From e150791826ae3dbfc2287f2429abe469f5665e83 Mon Sep 17 00:00:00 2001 From: Harshal Sheth Date: Fri, 2 Aug 2024 10:51:35 -0700 Subject: [PATCH 3/3] fix lint --- metadata-ingestion/src/datahub/ingestion/source/tableau.py | 1 + 1 file changed, 1 insertion(+) diff --git a/metadata-ingestion/src/datahub/ingestion/source/tableau.py b/metadata-ingestion/src/datahub/ingestion/source/tableau.py index 00a230900af94..510cb6c96d1f2 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/tableau.py +++ b/metadata-ingestion/src/datahub/ingestion/source/tableau.py @@ -762,6 +762,7 @@ def site_content_url(self) -> Optional[str]: if self.site and self.site.content_url: return self.site.content_url return None + def _populate_usage_stat_registry(self) -> None: if self.server is None: return