From 0a5e8b45384934df00c32c8ec9ce13501271ab83 Mon Sep 17 00:00:00 2001 From: Zongheng Yang Date: Sun, 27 Nov 2022 15:24:24 +0800 Subject: [PATCH] Logging fixes. (#1452) * Logging fixes. * yapf * sys.exit(1) --- sky/cli.py | 13 ++++++++++--- sky/spot/recovery_strategy.py | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sky/cli.py b/sky/cli.py index 97dac68846b..f9381eee8f1 100644 --- a/sky/cli.py +++ b/sky/cli.py @@ -1025,8 +1025,11 @@ def _add_command_alias_to_group(group, command, name, hidden): new_command = copy.deepcopy(command) new_command.hidden = hidden new_command.name = name - new_command.invoke = _with_deprecation_warning(new_command.invoke, - command.name, name) + + orig = f'sky {group.name} {command.name}' + alias = f'sky {group.name} {name}' + new_command.invoke = _with_deprecation_warning(new_command.invoke, orig, + alias) group.add_command(new_command, name=name) @@ -3078,7 +3081,11 @@ def spot_cancel(name: Optional[str], job_ids: Tuple[int], all: bool, yes: bool): @usage_lib.entrypoint def spot_logs(name: Optional[str], job_id: Optional[int], follow: bool): """Tail the log of a managed spot job.""" - core.spot_tail_logs(name=name, job_id=job_id, follow=follow) + try: + core.spot_tail_logs(name=name, job_id=job_id, follow=follow) + except exceptions.ClusterNotUpError: + # Hint messages already printed by the call above. + sys.exit(1) # ============================== diff --git a/sky/spot/recovery_strategy.py b/sky/spot/recovery_strategy.py index 534d2d38c9f..17d870ecfcc 100644 --- a/sky/spot/recovery_strategy.py +++ b/sky/spot/recovery_strategy.py @@ -123,9 +123,9 @@ def _try_cancel_all_jobs(self): except Exception as e: # pylint: disable=broad-except # Ignore the failure as the cluster can be totally stopped, and the # job canceling can get connection error. - logger.info( - f'Ignoring the job cancellation failure (Exception: {e}); ' - 'the spot cluster is likely completely stopped.') + logger.info('Ignoring the job cancellation failure; ' + 'the spot cluster is likely completely stopped.' + f'\n Detailed exception: {e}') def _launch(self, max_retry=3, raise_on_failure=True) -> Optional[float]: """Implementation of launch().