Skip to content

Commit f377809

Browse files
authored
[Jobs] Fix back compatibility for sky jobs logs from 0.5 (#3614)
* Fix back compat from 0.5 for jobs * fix * add comment
1 parent eedeed4 commit f377809

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sky/jobs/utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,8 @@ class ManagedJobCodeGen:
751751
752752
>> codegen = ManagedJobCodeGen.show_jobs(...)
753753
"""
754+
# TODO: the try..except.. block is for backward compatibility. Remove it in
755+
# v0.8.0.
754756
_PREFIX = textwrap.dedent("""\
755757
managed_job_version = 0
756758
try:
@@ -800,13 +802,17 @@ def stream_logs(cls,
800802
# We inspect the source code of the function here for backward
801803
# compatibility.
802804
# TODO: change to utils.stream_logs(job_id, job_name, follow) in v0.8.0.
803-
# Import libraries required by `stream_logs`
805+
# Import libraries required by `stream_logs`. The try...except... block
806+
# should be removed in v0.8.0.
804807
code = textwrap.dedent("""\
805808
import os
806809
807810
from sky.skylet import job_lib, log_lib
808811
from sky.skylet import constants
809-
from sky.jobs.utils import stream_logs_by_id
812+
try:
813+
from sky.jobs.utils import stream_logs_by_id
814+
except ImportError:
815+
from sky.spot.spot_utils import stream_logs_by_id
810816
from typing import Optional
811817
""")
812818
code += inspect.getsource(stream_logs)

0 commit comments

Comments
 (0)