Skip to content

Commit

Permalink
[Core] Fix issue with the wrong path of setup logs (#4209)
Browse files Browse the repository at this point in the history
* fix issue with a getting setup logs

* More conservative

* print error

* comment
  • Loading branch information
Michaelvll authored Oct 30, 2024
1 parent 9f055f4 commit 9d50f19
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
16 changes: 13 additions & 3 deletions sky/backends/cloud_vm_ray_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -3175,9 +3175,19 @@ def _run_setup(setup_cmd: str) -> int:
returncode = _run_setup(f'{create_script_code} && {setup_cmd}',)
if returncode == 255:
is_message_too_long = False
with open(setup_log_path, 'r', encoding='utf-8') as f:
if 'too long' in f.read():
is_message_too_long = True
try:
with open(os.path.expanduser(setup_log_path),
'r',
encoding='utf-8') as f:
if 'too long' in f.read():
is_message_too_long = True
except Exception as e: # pylint: disable=broad-except
# We don't crash the setup if we cannot read the log file.
# Instead, we should retry the setup with dumping the script
# to a file to be safe.
logger.debug('Failed to read setup log file '
f'{setup_log_path}: {e}')
is_message_too_long = True

if is_message_too_long:
# If the setup script is too long, we retry it with dumping
Expand Down
2 changes: 1 addition & 1 deletion sky/setup_files/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def parse_readme(readme: str) -> str:
'tabulate',
# Light weight requirement, can be replaced with "typing" once
# we deprecate Python 3.7 (this will take a while).
"typing_extensions",
'typing_extensions',
'filelock >= 3.6.0',
'packaging',
'psutil',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -3579,15 +3579,15 @@ def test_long_setup_run_script(generic_cloud: str):
setup: |
echo "start long setup"
"""))
for i in range(1024 * 120):
for i in range(1024 * 200):
f.write(f' echo {i}\n')
f.write(' echo "end long setup"\n')
f.write(
textwrap.dedent(""" \
run: |
echo "run"
"""))
for i in range(1024 * 120):
for i in range(1024 * 200):
f.write(f' echo {i}\n')
f.write(' echo "end run"\n')
f.flush()
Expand Down

0 comments on commit 9d50f19

Please sign in to comment.