Skip to content

Commit

Permalink
revert one-liner conditional for better readibility
Browse files Browse the repository at this point in the history
  • Loading branch information
andylizf committed Nov 3, 2024
1 parent 79a8089 commit c4b367c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
8 changes: 4 additions & 4 deletions sky/jobs/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,10 @@ def _cancel_all_tasks(self, task_id: int) -> None:
def run(self) -> None:
"""Run controller logic and handle exceptions."""
all_tasks_completed = lambda: self._num_tasks == len(self._task_status)
# TODO(andy): Serve has a logic to prevent from too many services running
# at the same time. We should have a similar logic here, but instead we
# should calculate the sum of the subtasks (an upper bound), instead of
# the number of jobs (dags).
# TODO(andy): Serve has a logic to prevent from too many services
# running at the same time. We should have a similar logic here, but
# instead we should calculate the sum of the subtasks (an upper bound),
# instead of the number of jobs (dags).
# Further, we could try to calculate the maximum concurrency in the dag
# (e.g. for a chain dag it is 1 instead of n), which could allow us to
# run more dags in parallel.
Expand Down
17 changes: 9 additions & 8 deletions sky/jobs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,13 @@ def update_message(msg: str):
time.sleep(1)

if managed_job_status.is_terminal():
failure_reason = (('\nFailure reason: '
f'{managed_job_state.get_failure_reason(job_id)}'
) if managed_job_status.is_failed() else '')
return (f'{colorama.Fore.YELLOW}'
f'Job {job_id} is already in terminal state '
f'{managed_job_status.value}. Logs will not be shown.'
f'{colorama.Style.RESET_ALL}') + (
('\nFailure reason: '
f'{managed_job_state.get_failure_reason(job_id)}')
if managed_job_status.is_failed() else '')
f'{colorama.Style.RESET_ALL}') + failure_reason

def get_next_task_id_status(
job_id: int, task_id: Optional[int]
Expand Down Expand Up @@ -442,10 +442,11 @@ def get_next_task_id_status(
# the next round of status check.
if (handle is None or managed_job_status !=
managed_job_state.ManagedJobStatus.RUNNING):
status_str = (
f' (status: {managed_job_status.value})'
if managed_job_status is not None and managed_job_status !=
managed_job_state.ManagedJobStatus.RUNNING else '')
status_str = ''
if (managed_job_status is not None and managed_job_status !=
managed_job_state.ManagedJobStatus.RUNNING):
status_str = (f' (status: {managed_job_status.value})')

logger.debug(
f'INFO: The log is not ready yet{status_str}. '
f'Waiting for {JOB_STATUS_CHECK_GAP_SECONDS} seconds.')
Expand Down

0 comments on commit c4b367c

Please sign in to comment.