Skip to content

Commit

Permalink
fix: error if makedirs fails and update smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
ShreyasKallingal committed Jul 26, 2024
1 parent 39cd385 commit 384d3d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
7 changes: 1 addition & 6 deletions sky/utils/log_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,7 @@ def create_and_symlink_log_dir(log_dir: str):
Args:
log_dir (str): Expanded log directory path.
"""
try:
os.makedirs(log_dir, exist_ok=True)
except OSError:
logger.warning(f'Failed to create log directory at {log_dir!r}.'
'Check if there is a file with the same name.')
return
os.makedirs(log_dir, exist_ok=True)
symlink_path = os.path.join(os.path.dirname(os.path.abspath(log_dir)),
constants.SKY_LATEST_LINK)
if os.path.exists(symlink_path):
Expand Down
10 changes: 6 additions & 4 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -1322,15 +1322,17 @@ def test_symlink_latest_logs():
test = Test(
'symlink_latest_logs',
[
'sky launch -c test2 --cloud kubernetes -- echo hi || true',
'sky launch -c test1 --cloud kubernetes -- echo hi > log1.txt || true',
'eval symlink_path="~/sky_logs/sky_latest"; [ -L "$symlink_path" ] || exit 1 ;'
'target_file=$(readlink -f "$symlink_path") || exit 1 ;'
'sky local down || true ;'
'grep -E "To view detailed progress: .+ $target_file" log1.txt || exit 1;'
'sky launch -c test1 --cloud kubernetes -- echo hi > log2.txt || true ;'
'[ -L "$symlink_path" ] || exit 1 ;'
'target_file2=$(readlink -f "$symlink_path") ;'
'target_file2=$(readlink -f "$symlink_path") || exit 1 ;'
'grep -E "To view detailed progress: .+ $target_file2" log2.txt || exit 1;'
'[ "$target_file" != "$target_file2" ] || exit 1'
],
'sky local down',
'rm log1.txt log2.txt'
)
run_one_test(test)

Expand Down

0 comments on commit 384d3d8

Please sign in to comment.