diff --git a/sky/cli.py b/sky/cli.py index 490749d1231..c49b692add1 100644 --- a/sky/cli.py +++ b/sky/cli.py @@ -3699,13 +3699,24 @@ 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: + if 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'Resources for managed job {dag.name!r} will be computed on the ' + 'managed jobs controller, since --yes is set.', + fg='cyan') + + else: + click.secho( + f'Managed job {dag.name!r} will be launched on (estimated):', + fg='cyan') + dag = sky.optimize(dag) + prompt = f'Launching a managed job {dag.name!r}. Proceed?' if prompt is not None: click.confirm(prompt, default=True, abort=True, show_default=True) diff --git a/sky/clouds/aws.py b/sky/clouds/aws.py index 4a9f2d63f35..22e1039f121 100644 --- a/sky/clouds/aws.py +++ b/sky/clouds/aws.py @@ -663,6 +663,7 @@ def _is_access_key_of_type(type_str: str) -> bool: return AWSIdentityType.SHARED_CREDENTIALS_FILE @classmethod + @functools.lru_cache(maxsize=1) # Cache since getting identity is slow. def get_user_identities(cls) -> Optional[List[List[str]]]: """Returns a [UserId, Account] list that uniquely identifies the user. diff --git a/sky/execution.py b/sky/execution.py index cbcfb2b99fe..350a482a418 100644 --- a/sky/execution.py +++ b/sky/execution.py @@ -267,6 +267,12 @@ def _execute( # no-credential machine should not enter optimize(), which # would directly error out ('No cloud is enabled...'). Fix # by moving `sky check` checks out of optimize()? + + controller = controller_utils.Controllers.from_name( + cluster_name) + if controller is not None: + logger.info( + f'Choosing resources for {controller.name}...') dag = sky.optimize(dag, minimize=optimize_target) task = dag.tasks[0] # Keep: dag may have been deep-copied. assert task.best_resources is not None, task