From 4a53763f816bc9ff100a9ded22c507e49d26ac83 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Tue, 23 Jul 2024 17:21:40 -0400 Subject: [PATCH] Check cluster exists --- sky/cli.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sky/cli.py b/sky/cli.py index 670f5db7f23..d8ccc6351f4 100644 --- a/sky/cli.py +++ b/sky/cli.py @@ -5260,9 +5260,14 @@ def code( if not cluster: raise click.UsageError('Please specify a cluster with ---cluster/-c.') + handle = global_user_state.get_handle_from_cluster_name(cluster) + if handle is None: + raise click.BadParameter(f'Cluster {cluster!r} not found. ' + 'Use `sky launch` to provision first.') + code_bin = shutil.which("code") if not code_bin: - raise RuntimeError( + raise click.UsageError( '"code" is not available in your path. Ensure VSCode in installed and the shell command is available on ' 'your path https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line' )