From 5d61df58205f9c78094e2a6f52ffa71a5f49a8da Mon Sep 17 00:00:00 2001 From: Christopher Cooper Date: Tue, 12 Nov 2024 13:10:21 -0800 Subject: [PATCH] skip optimization for sky jobs launch --yes The only reason we call optimize for jobs_launch is to give a preview of the resources we expect to use, and give the user an opportunity to back out if it's not what they expect. If you use --yes or -y, you don't have a chance to back out and you're probably running from a script, where you don't care. Optimization can take ~2 seconds, so just skip it. --- sky/cli.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sky/cli.py b/sky/cli.py index 230f43d6f90..2fa23a723a0 100644 --- a/sky/cli.py +++ b/sky/cli.py @@ -3687,11 +3687,17 @@ def jobs_launch( dag_utils.maybe_infer_and_fill_dag_and_task_names(dag) dag_utils.fill_default_config_in_dag_for_job_launch(dag) - click.secho(f'Managed job {dag.name!r} will be launched on (estimated):', - fg='cyan') dag, _ = admin_policy_utils.apply( dag, use_mutated_config_in_current_request=False) - dag = sky.optimize(dag) + + if not yes: + # Skip resource preview if -y is set, since we are probably running in + # a script and the user won't have a chance to review it anyway. + # This can save a couple of seconds. + click.secho( + f'Managed job {dag.name!r} will be launched on (estimated):', + fg='cyan') + dag = sky.optimize(dag) if not yes: prompt = f'Launching a managed job {dag.name!r}. Proceed?'