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] Support checking user specified cloud(s) with sky check from CLI #3229

Merged
merged 14 commits into from
May 16, 2024
17 changes: 15 additions & 2 deletions sky/check.py
romilbhardwaj marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@


# TODO(zhwu): add check for a single cloud to improve performance
def check(quiet: bool = False, verbose: bool = False) -> None:
def check(
dtran24 marked this conversation as resolved.
Show resolved Hide resolved
romilbhardwaj marked this conversation as resolved.
Show resolved Hide resolved
quiet: bool = False,
verbose: bool = False,
user_specified_clouds: Optional[Tuple[str]] = None,
dtran24 marked this conversation as resolved.
Show resolved Hide resolved
) -> None:
echo = (lambda *_args, **_kwargs: None) if quiet else click.echo
echo('Checking credentials to enable clouds for SkyPilot.')

user_specified_clouds_set = set()
dtran24 marked this conversation as resolved.
Show resolved Hide resolved
if user_specified_clouds is not None:
for cloud in user_specified_clouds:
clouds.CLOUD_REGISTRY.from_str(cloud) # verify cloud
user_specified_clouds_set.add(cloud.lower())

enabled_clouds = []
dtran24 marked this conversation as resolved.
Show resolved Hide resolved

def check_one_cloud(cloud_tuple: Tuple[str, clouds.Cloud]) -> None:
Expand Down Expand Up @@ -42,7 +52,10 @@ def check_one_cloud(cloud_tuple: Tuple[str, clouds.Cloud]) -> None:
clouds_to_check.append(('Cloudflare, for R2 object store', cloudflare))

for cloud_tuple in sorted(clouds_to_check):
check_one_cloud(cloud_tuple)
cloud_repr = cloud_tuple[0].lower()
if (user_specified_clouds is None or
cloud_repr in user_specified_clouds_set):
check_one_cloud(cloud_tuple)

# Cloudflare is not a real cloud in clouds.CLOUD_REGISTRY, and should not be
# inserted into the DB (otherwise `sky launch` and other code would error
Expand Down
8 changes: 6 additions & 2 deletions sky/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3452,13 +3452,14 @@ def tpunode(cluster: str, yes: bool, port_forward: Optional[List[int]],


@cli.command()
@click.argument('user_specified_clouds', required=False, type=str, nargs=-1)
dtran24 marked this conversation as resolved.
Show resolved Hide resolved
@click.option('--verbose',
'-v',
is_flag=True,
default=False,
help='Show the activated account for each cloud.')
@usage_lib.entrypoint
def check(verbose: bool):
def check(user_specified_clouds: Tuple[str], verbose: bool):
"""Check which clouds are available to use.

This checks access credentials for all clouds supported by SkyPilot. If a
Expand All @@ -3468,7 +3469,10 @@ def check(verbose: bool):
The enabled clouds are cached and form the "search space" to be considered
dtran24 marked this conversation as resolved.
Show resolved Hide resolved
for each task.
"""
romilbhardwaj marked this conversation as resolved.
Show resolved Hide resolved
sky_check.check(verbose=verbose)
user_specified_clouds_arg = user_specified_clouds if len(
user_specified_clouds) > 0 else None
sky_check.check(verbose=verbose,
user_specified_clouds=user_specified_clouds_arg)


@cli.command()
Expand Down
Loading