From 2986d616b718bd3109a899cadb14e873b6073538 Mon Sep 17 00:00:00 2001 From: Mayur Singal <39544459+ulixius9@users.noreply.github.com> Date: Fri, 6 Oct 2023 12:31:46 +0530 Subject: [PATCH] Fix superset owner issue for db (#13451) --- .../source/dashboard/dashboard_service.py | 19 ++++++++++--------- .../source/dashboard/superset/mixin.py | 17 ++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ingestion/src/metadata/ingestion/source/dashboard/dashboard_service.py b/ingestion/src/metadata/ingestion/source/dashboard/dashboard_service.py index 1d5a2acf3ae..f74a56c074e 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/dashboard_service.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/dashboard_service.py @@ -349,16 +349,17 @@ class DashboardServiceSource(TopologyRunnerMixin, Source, ABC): def process_owner(self, dashboard_details): try: - owner = self.get_owner_details( # pylint: disable=assignment-from-none - dashboard_details=dashboard_details - ) - if owner and self.source_config.includeOwners: - self.metadata.patch_owner( - entity=Dashboard, - source=self.context.dashboard, - owner=owner, - force=False, + if self.source_config.includeOwners: + owner = self.get_owner_details( # pylint: disable=assignment-from-none + dashboard_details=dashboard_details ) + if owner: + self.metadata.patch_owner( + entity=Dashboard, + source=self.context.dashboard, + owner=owner, + force=False, + ) except Exception as exc: logger.debug(traceback.format_exc()) logger.warning(f"Error processing owner for {dashboard_details}: {exc}") diff --git a/ingestion/src/metadata/ingestion/source/dashboard/superset/mixin.py b/ingestion/src/metadata/ingestion/source/dashboard/superset/mixin.py index 6b76c9f5a9d..6350a236191 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/superset/mixin.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/superset/mixin.py @@ -92,9 +92,7 @@ class SupersetSourceMixin(DashboardServiceSource): """ return dashboard - def _get_user_by_email( - self, email: Union[FetchDashboard, DashboardResult] - ) -> EntityReference: + def _get_user_by_email(self, email: Optional[str]) -> Optional[EntityReference]: if email: user = self.metadata.get_user_by_email(email) if user: @@ -105,11 +103,12 @@ class SupersetSourceMixin(DashboardServiceSource): def get_owner_details( self, dashboard_details: Union[DashboardResult, FetchDashboard] ) -> EntityReference: - for owner in dashboard_details.owners: - if owner.email: - user = self._get_user_by_email(owner.email) - if user: - return user + if hasattr(dashboard_details, "owner"): + for owner in dashboard_details.owners or []: + if owner.email: + user = self._get_user_by_email(owner.email) + if user: + return user if dashboard_details.email: user = self._get_user_by_email(dashboard_details.email) if user: @@ -204,7 +203,7 @@ class SupersetSourceMixin(DashboardServiceSource): return None def get_column_info( - self, data_source: Union[DataSourceResult, FetchColumn] + self, data_source: List[Union[DataSourceResult, FetchColumn]] ) -> Optional[List[Column]]: """ Args: