Skip to content

Commit

Permalink
Fix Logging for sky launch on new machine (#1382)
Browse files Browse the repository at this point in the history
* ok

* ok

* Ok

* ok

* Unify methods

* ok

* fix
  • Loading branch information
michaelzhiluo authored Nov 11, 2022
1 parent d323b05 commit fb31876
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions sky/backends/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2059,3 +2059,10 @@ def validate_schema(obj, schema, err_msg_prefix=''):
if err_msg:
with ux_utils.print_exception_no_traceback():
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)
6 changes: 6 additions & 0 deletions sky/backends/onprem_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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 @@ -492,6 +493,11 @@ 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
3 changes: 2 additions & 1 deletion sky/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from sky import resources as resources_lib
from sky import sky_logging
from sky import task as task_lib
from sky.backends import backend_utils
from sky.utils import env_options
from sky.utils import ux_utils
from sky.utils import log_utils
Expand Down Expand Up @@ -826,7 +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 len(enabled_clouds) == 0 and try_fix_with_sky_check:
if backend_utils.is_public_cloud_disabled() and try_fix_with_sky_check:
check.check(quiet=True)
return _fill_in_launchable_resources(task, blocked_launchable_resources,
False)
Expand Down

0 comments on commit fb31876

Please sign in to comment.