Skip to content

Commit

Permalink
refactor(redash): emit charts first and try with id based dashboard A…
Browse files Browse the repository at this point in the history
…PI first (#4991)
  • Loading branch information
anshbansal authored May 25, 2022
1 parent 049db62 commit 34f099f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions metadata-ingestion/src/datahub/ingestion/source/redash.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,14 +566,19 @@ def _emit_dashboard_mces(self) -> Iterable[MetadataWorkUnit]:
continue

# Continue producing MCE
dashboard_slug = dashboard_response["slug"]
try:
dashboard_data = self.client.dashboard(dashboard_slug)
except Exception:
# This is undocumented but checking the Redash source
# the API is id based not slug based
# Tested the same with a Redash instance
dashboard_id = dashboard_response["id"]
dashboard_data = self.client._get(
"api/dashboards/{}".format(dashboard_id)
).json()
except Exception:
# This does not work in our testing but keeping for now because
# people in community are using Redash connector successfully
dashboard_slug = dashboard_response["slug"]
dashboard_data = self.client.dashboard(dashboard_slug)
logger.debug(dashboard_data)
dashboard_snapshot = self._get_dashboard_snapshot(dashboard_data)
mce = MetadataChangeEvent(proposedSnapshot=dashboard_snapshot)
Expand Down Expand Up @@ -708,8 +713,8 @@ def _emit_chart_mces(self) -> Iterable[MetadataWorkUnit]:

def get_workunits(self) -> Iterable[MetadataWorkUnit]:
self.test_connection()
yield from self._emit_dashboard_mces()
yield from self._emit_chart_mces()
yield from self._emit_dashboard_mces()

def get_report(self) -> SourceReport:
return self.report
Expand Down

0 comments on commit 34f099f

Please sign in to comment.