Skip to content

Commit

Permalink
[Jobs] Fix back compatibility for sky jobs logs from 0.5 (#3614)
Browse files Browse the repository at this point in the history
* Fix back compat from 0.5 for jobs

* fix

* add comment
  • Loading branch information
Michaelvll authored May 29, 2024
1 parent eedeed4 commit f377809
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sky/jobs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,8 @@ class ManagedJobCodeGen:
>> codegen = ManagedJobCodeGen.show_jobs(...)
"""
# TODO: the try..except.. block is for backward compatibility. Remove it in
# v0.8.0.
_PREFIX = textwrap.dedent("""\
managed_job_version = 0
try:
Expand Down Expand Up @@ -800,13 +802,17 @@ def stream_logs(cls,
# We inspect the source code of the function here for backward
# compatibility.
# TODO: change to utils.stream_logs(job_id, job_name, follow) in v0.8.0.
# Import libraries required by `stream_logs`
# Import libraries required by `stream_logs`. The try...except... block
# should be removed in v0.8.0.
code = textwrap.dedent("""\
import os
from sky.skylet import job_lib, log_lib
from sky.skylet import constants
from sky.jobs.utils import stream_logs_by_id
try:
from sky.jobs.utils import stream_logs_by_id
except ImportError:
from sky.spot.spot_utils import stream_logs_by_id
from typing import Optional
""")
code += inspect.getsource(stream_logs)
Expand Down

0 comments on commit f377809

Please sign in to comment.