Fix superset owner issue for db (#13451)

This commit is contained in:
Mayur Singal 2023-10-06 12:31:46 +05:30 committed by GitHub
parent 518fedd3fd
commit 2986d616b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 18 deletions

View File

@ -349,16 +349,17 @@ class DashboardServiceSource(TopologyRunnerMixin, Source, ABC):
def process_owner(self, dashboard_details): def process_owner(self, dashboard_details):
try: try:
owner = self.get_owner_details( # pylint: disable=assignment-from-none if self.source_config.includeOwners:
dashboard_details=dashboard_details 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 owner:
self.metadata.patch_owner(
entity=Dashboard,
source=self.context.dashboard,
owner=owner,
force=False,
)
except Exception as exc: except Exception as exc:
logger.debug(traceback.format_exc()) logger.debug(traceback.format_exc())
logger.warning(f"Error processing owner for {dashboard_details}: {exc}") logger.warning(f"Error processing owner for {dashboard_details}: {exc}")

View File

@ -92,9 +92,7 @@ class SupersetSourceMixin(DashboardServiceSource):
""" """
return dashboard return dashboard
def _get_user_by_email( def _get_user_by_email(self, email: Optional[str]) -> Optional[EntityReference]:
self, email: Union[FetchDashboard, DashboardResult]
) -> EntityReference:
if email: if email:
user = self.metadata.get_user_by_email(email) user = self.metadata.get_user_by_email(email)
if user: if user:
@ -105,11 +103,12 @@ class SupersetSourceMixin(DashboardServiceSource):
def get_owner_details( def get_owner_details(
self, dashboard_details: Union[DashboardResult, FetchDashboard] self, dashboard_details: Union[DashboardResult, FetchDashboard]
) -> EntityReference: ) -> EntityReference:
for owner in dashboard_details.owners: if hasattr(dashboard_details, "owner"):
if owner.email: for owner in dashboard_details.owners or []:
user = self._get_user_by_email(owner.email) if owner.email:
if user: user = self._get_user_by_email(owner.email)
return user if user:
return user
if dashboard_details.email: if dashboard_details.email:
user = self._get_user_by_email(dashboard_details.email) user = self._get_user_by_email(dashboard_details.email)
if user: if user:
@ -204,7 +203,7 @@ class SupersetSourceMixin(DashboardServiceSource):
return None return None
def get_column_info( def get_column_info(
self, data_source: Union[DataSourceResult, FetchColumn] self, data_source: List[Union[DataSourceResult, FetchColumn]]
) -> Optional[List[Column]]: ) -> Optional[List[Column]]:
""" """
Args: Args: