Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UX] fix the error for the first time sky launch #1405

Merged
merged 10 commits into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions sky/backends/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2061,8 +2061,20 @@ def validate_schema(obj, schema, err_msg_prefix=''):
raise ValueError(err_msg)


def is_public_cloud_disabled():
"""Checks if none of the public clouds are enabled."""
enabled_clouds = global_user_state.get_enabled_clouds()
return len(enabled_clouds) == 1 and isinstance(enabled_clouds[0],
clouds.Local)
def check_public_cloud_enabled():
"""Checks if any of the public clouds is enabled."""

def _no_public_cloud():
enabled_clouds = global_user_state.get_enabled_clouds()
return (len(enabled_clouds) == 0 or
(len(enabled_clouds) == 1 and
isinstance(enabled_clouds[0], clouds.Local)))

if not _no_public_cloud():
return

sky_check.check(quiet=True)
if _no_public_cloud():
with ux_utils.print_exception_no_traceback():
raise RuntimeError('Cloud access is not set up. '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: any easy way to remove RuntimeError being printed on the CLI? (We need it to be printed for the first sky.launch() though.) Very minor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Changed the behavior for CLI, by explicitly calling this method before the sky.optimize. Now it wil shows the following:
image

'Run: `sky check`')
Michaelvll marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 0 additions & 6 deletions sky/backends/onprem_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import rich.console as rich_console
import yaml

from sky import check
from sky import global_user_state
from sky import sky_logging
from sky.backends import backend_utils
Expand Down Expand Up @@ -493,11 +492,6 @@ def check_local_cloud_args(cloud: Optional[str] = None,
'`cloud: local` or no cloud in YAML or CLI args.')
return True
else:
if backend_utils.is_public_cloud_disabled():
check.check(quiet=True)
if backend_utils.is_public_cloud_disabled():
raise RuntimeError('Cloud access is not set up. '
'Run: `sky check`')
if cloud == 'local' or yaml_cloud == 'local':
if cluster_name is not None:
raise click.UsageError(
Expand Down
5 changes: 1 addition & 4 deletions sky/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,10 +827,7 @@ def _fill_in_launchable_resources(
) -> Tuple[Dict[resources_lib.Resources, List[resources_lib.Resources]],
_PerCloudCandidates]:
enabled_clouds = global_user_state.get_enabled_clouds()
if backend_utils.is_public_cloud_disabled() and try_fix_with_sky_check:
Michaelvll marked this conversation as resolved.
Show resolved Hide resolved
check.check(quiet=True)
return _fill_in_launchable_resources(task, blocked_launchable_resources,
False)
backend_utils.check_public_cloud_enabled()
launchable = collections.defaultdict(list)
cloud_candidates = collections.defaultdict(resources_lib.Resources)
if blocked_launchable_resources is None:
Expand Down