Skip to content

Commit

Permalink
refactoring: speed up working with dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov-aws committed Dec 23, 2024
1 parent ead505e commit 141bb8a
Show file tree
Hide file tree
Showing 4 changed files with 285 additions and 242 deletions.
18 changes: 9 additions & 9 deletions cid/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def _deploy(self, dashboard_id: str=None, recursive=True, update=False, **kwargs
dashboard_definition = self.get_definition("dashboard", id=dashboard_id)
dashboard = None
try:
dashboard = self.qs.discover_dashboard(dashboardId=dashboard_id)
dashboard = self.qs.discover_dashboard(dashboard_id)
except CidCritical:
pass

Expand Down Expand Up @@ -653,7 +653,7 @@ def open(self, dashboard_id, **kwargs):
if not dashboard_id:
dashboard_id = self.qs.select_dashboard(force=True)

dashboard = self.qs.discover_dashboard(dashboardId=dashboard_id)
dashboard = self.qs.discover_dashboard(dashboard_id)

click.echo('Getting dashboard status...', nl=False)
if dashboard is not None:
Expand Down Expand Up @@ -682,7 +682,7 @@ def status(self, dashboard_id, **kwargs):
if not dashboard_id:
print('No dashboard selected')
return
dashboard = self.qs.discover_dashboard(dashboardId=dashboard_id)
dashboard = self.qs.discover_dashboard(dashboard_id)

if dashboard is not None:
dashboard.display_status()
Expand Down Expand Up @@ -747,7 +747,7 @@ def delete(self, dashboard_id, **kwargs):
return

if self.qs.dashboards and dashboard_id in self.qs.dashboards:
datasets = self.qs.discover_dashboard(dashboardId=dashboard_id).datasets # save for later
datasets = self.qs.discover_dashboard(dashboard_id).datasets # save for later
else:
dashboard_definition = self.get_definition("dashboard", id=dashboard_id)
datasets = {d: None for d in (dashboard_definition or {}).get('dependsOn', {}).get('datasets', [])}
Expand Down Expand Up @@ -854,7 +854,7 @@ def delete_view(self, view_name):
def cleanup(self, **kwargs):
"""Delete unused resources (QuickSight datasets not used in Dashboards)"""

self.qs.discover_dashboards()
self.qs.pre_discover()
self.qs.discover_datasets()
references = {}
for dashboard in self.qs.dashboards.values():
Expand Down Expand Up @@ -892,9 +892,9 @@ def _share(self, dashboard_id, **kwargs):
return
else:
# Describe dashboard by the ID given, no discovery
self.qs.discover_dashboard(dashboardId=dashboard_id)
self.qs.discover_dashboard(dashboard_id)

dashboard = self.qs.discover_dashboard(dashboardId=dashboard_id)
dashboard = self.qs.discover_dashboard(dashboard_id)

if dashboard is None:
print('not deployed.')
Expand Down Expand Up @@ -1065,7 +1065,7 @@ def update(self, dashboard_id, recursive=False, force=False, **kwargs):
def check_dashboard_version_compatibility(self, dashboard_id):
""" Returns True | False | None if could not check """
try:
dashboard = self.qs.discover_dashboard(dashboardId=dashboard_id)
dashboard = self.qs.discover_dashboard(dashboard_id)
except CidCritical:
print(f'Dashboard "{dashboard_id}" is not deployed')
return None
Expand All @@ -1085,7 +1085,7 @@ def check_dashboard_version_compatibility(self, dashboard_id):

def update_dashboard(self, dashboard_id, dashboard_definition):

dashboard = self.qs.discover_dashboard(dashboardId=dashboard_id)
dashboard = self.qs.discover_dashboard(dashboard_id)
if not dashboard:
print(f'Dashboard "{dashboard_id}" is not deployed')
return
Expand Down
Loading

0 comments on commit 141bb8a

Please sign in to comment.