From a8ca38f1defe09e93797e42286530165dc702890 Mon Sep 17 00:00:00 2001 From: Zhanghao Wu Date: Sun, 26 May 2024 23:17:30 +0000 Subject: [PATCH] Fix controller log --- sky/jobs/constants.py | 2 +- sky/jobs/utils.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sky/jobs/constants.py b/sky/jobs/constants.py index 0f677ae186d..d5f32908317 100644 --- a/sky/jobs/constants.py +++ b/sky/jobs/constants.py @@ -24,4 +24,4 @@ # The version of the lib files that jobs/utils use. Whenever there is an API # change for the jobs/utils, we need to bump this version and update # job.utils.ManagedJobCodeGen to handle the version update. -MANAGED_JOBS_VERSION = 2 +MANAGED_JOBS_VERSION = 1 diff --git a/sky/jobs/utils.py b/sky/jobs/utils.py index 9792d33586e..a76daefa48f 100644 --- a/sky/jobs/utils.py +++ b/sky/jobs/utils.py @@ -747,11 +747,11 @@ class ManagedJobCodeGen: _PREFIX = textwrap.dedent("""\ managed_job_version = 0 try: - from sky.jobs import constants, utils - from sky.jobs.utils import stream_logs_by_id + from sky.jobs import utils + from sky.jobs import constants as managed_job_constants from sky.jobs import state as managed_job_state from typing import Optional - managed_job_version = constants.MANAGED_JOBS_VERSION + managed_job_version = managed_job_constants.MANAGED_JOBS_VERSION except ImportError: from sky.spot import spot_state as state, spot_utils as utils """) @@ -792,7 +792,15 @@ 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. - code = inspect.getsource(stream_logs) + # Import libraries required by `stream_logs` + 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 + """) + code += inspect.getsource(stream_logs) code += textwrap.dedent(f"""\ msg = stream_logs({job_id!r}, {job_name!r},