Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cg505 committed Dec 11, 2024
1 parent 59971bb commit 32a5e36
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
8 changes: 4 additions & 4 deletions sky/jobs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import inspect
import os
import pathlib
import psutil
import shlex
import shutil
import textwrap
Expand All @@ -19,6 +18,7 @@

import colorama
import filelock
import psutil
from typing_extensions import Literal

from sky import backends
Expand Down Expand Up @@ -591,7 +591,7 @@ def stream_logs(job_id: Optional[int],
# is not considered an exceptional case.
return ''

time.sleep(log_lib._SKY_LOG_WAITING_GAP_SECONDS)
time.sleep(log_lib.SKY_LOG_WAITING_GAP_SECONDS)

# See also log_lib.tail_logs.
with open(controller_log_path, 'r', newline='', encoding='utf-8') as f:
Expand All @@ -613,10 +613,10 @@ def stream_logs(job_id: Optional[int],
if job_status.is_terminal():
break

time.sleep(log_lib._SKY_LOG_TAILING_GAP_SECONDS)
time.sleep(log_lib.SKY_LOG_TAILING_GAP_SECONDS)

# Wait for final logs to be written.
time.sleep(1 + log_lib._SKY_LOG_TAILING_GAP_SECONDS)
time.sleep(1 + log_lib.SKY_LOG_TAILING_GAP_SECONDS)

# Print any remaining logs including incomplete line.
print(f.read(), end='', flush=True)
Expand Down
16 changes: 8 additions & 8 deletions sky/skylet/log_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from sky.utils import subprocess_utils
from sky.utils import ux_utils

_SKY_LOG_WAITING_GAP_SECONDS = 1
_SKY_LOG_WAITING_MAX_RETRY = 5
_SKY_LOG_TAILING_GAP_SECONDS = 0.2
SKY_LOG_WAITING_GAP_SECONDS = 1
SKY_LOG_WAITING_MAX_RETRY = 5
SKY_LOG_TAILING_GAP_SECONDS = 0.2
# Peek the head of the lines to check if we need to start
# streaming when tail > 0.
PEEK_HEAD_LINES_FOR_START_STREAM = 20
Expand Down Expand Up @@ -336,7 +336,7 @@ def _follow_job_logs(file,
]:
if wait_last_logs:
# Wait all the logs are printed before exit.
time.sleep(1 + _SKY_LOG_TAILING_GAP_SECONDS)
time.sleep(1 + SKY_LOG_TAILING_GAP_SECONDS)
wait_last_logs = False
continue
status_str = status.value if status is not None else 'None'
Expand All @@ -345,7 +345,7 @@ def _follow_job_logs(file,
f'Job finished (status: {status_str}).'))
return

time.sleep(_SKY_LOG_TAILING_GAP_SECONDS)
time.sleep(SKY_LOG_TAILING_GAP_SECONDS)
status = job_lib.get_status_no_lock(job_id)


Expand Down Expand Up @@ -426,15 +426,15 @@ def tail_logs(job_id: Optional[int],
retry_cnt += 1
if os.path.exists(log_path) and status != job_lib.JobStatus.INIT:
break
if retry_cnt >= _SKY_LOG_WAITING_MAX_RETRY:
if retry_cnt >= SKY_LOG_WAITING_MAX_RETRY:
print(
f'{colorama.Fore.RED}ERROR: Logs for '
f'{job_str} (status: {status.value}) does not exist '
f'after retrying {retry_cnt} times.{colorama.Style.RESET_ALL}')
return
print(f'INFO: Waiting {_SKY_LOG_WAITING_GAP_SECONDS}s for the logs '
print(f'INFO: Waiting {SKY_LOG_WAITING_GAP_SECONDS}s for the logs '
'to be written...')
time.sleep(_SKY_LOG_WAITING_GAP_SECONDS)
time.sleep(SKY_LOG_WAITING_GAP_SECONDS)
status = job_lib.update_job_status([job_id], silent=True)[0]

start_stream_at = LOG_FILE_START_STREAMING_AT
Expand Down
3 changes: 3 additions & 0 deletions sky/skylet/log_lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ from sky.skylet import constants as constants
from sky.skylet import job_lib as job_lib
from sky.utils import log_utils as log_utils

SKY_LOG_WAITING_GAP_SECONDS: int = ...
SKY_LOG_WAITING_MAX_RETRY: int = ...
SKY_LOG_TAILING_GAP_SECONDS: float = ...
LOG_FILE_START_STREAMING_AT: str = ...


Expand Down

0 comments on commit 32a5e36

Please sign in to comment.