Skip to content

Commit

Permalink
get rid of click
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov-aws committed Dec 27, 2024
1 parent 141bb8a commit 5cc0956
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
28 changes: 11 additions & 17 deletions cid/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import urllib
import logging
import functools
import webbrowser
from string import Template
from typing import Dict
from pkg_resources import resource_string
from importlib.metadata import entry_points
from functools import cached_property

import yaml
import click
import requests
from botocore.exceptions import ClientError, NoCredentialsError, CredentialRetrievalError

Expand Down Expand Up @@ -655,17 +655,15 @@ def open(self, dashboard_id, **kwargs):

dashboard = self.qs.discover_dashboard(dashboard_id)

click.echo('Getting dashboard status...', nl=False)
if dashboard is not None:
if dashboard.version.get('Status') not in ['CREATION_SUCCESSFUL']:
print(json.dumps(dashboard.version.get('Errors'),
indent=4, sort_keys=True, default=str))
click.echo(
f'\nDashboard is unhealthy, please check errors above.')
click.echo('healthy, opening...')
click.launch(self.qs_url.format(dashboard_id=dashboard_id, **self.qs_url_params))
else:
click.echo('not deployed.')
logger.info('Getting dashboard status...')
if not dashboard:
logger.error(f'{dashboard_id} is not deployed.')
return None
if dashboard.version.get('Status') not in ['CREATION_SUCCESSFUL', 'UPDATE_IN_PROGRESS', 'UPDATE_SUCCESSFUL']:
cid_print(json.dumps(dashboard.version.get('Errors'), indent=4, sort_keys=True, default=str))
cid_print(f'Dashboard {dashboard_id} is unhealthy, please check errors above.')
logger.info('healthy, opening...')
webbrowser.open(self.qs_url.format(dashboard_id=dashboard_id, **self.qs_url_params))

return dashboard_id

Expand Down Expand Up @@ -724,11 +722,7 @@ def status(self, dashboard_id, **kwargs):
logger.info(f'Updating dashboard: {dashboard.id} with Recursive = {recursive}')
self._deploy(dashboard_id, recursive=recursive, update=True)
logger.info('Rediscover dashboards after update')

refresh_overrides = [
dashboard.id
]
self.qs.discover_dashboards(refresh_overrides = refresh_overrides)
self.qs.discover_dashboards(refresh_overrides=[dashboard.id])
self.qs.clear_dashboard_selection()
dashboard_id = None
else:
Expand Down
1 change: 0 additions & 1 deletion cid/helpers/quicksight/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import Dict

import yaml
import click

from cid.helpers.quicksight.resource import CidQsResource
from cid.helpers.quicksight.definition import Definition as CidQsDefinition
Expand Down

0 comments on commit 5cc0956

Please sign in to comment.