Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Michaelvll committed May 27, 2024
1 parent 930f148 commit 3ad060f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
19 changes: 14 additions & 5 deletions sky/jobs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,17 +462,24 @@ def stream_logs(job_id: Optional[int],
if job_id is None:
assert job_name is not None
managed_jobs = managed_job_state.get_managed_jobs()
# We manually filter the jobs by name, instead of using
# get_nonterminal_job_ids_by_name, as with `controller=True`, we
# should be able to show the logs for jobs in terminal states.
managed_jobs = list(
filter(lambda job: job['job_name'] == job_name, managed_jobs))
if len(managed_jobs) == 0:
return f'No managed job found with name {job_name!r}.'
if len(managed_jobs) > 1:
job_ids_str = ", ".join(job['job_id'] for job in managed_jobs)
raise ValueError(
f'Multiple managed jobs found with name {job_name!r}. '
'Please specify the job_id instead.')
f'Multiple managed jobs found with name {job_name!r} (Job '
f'IDs: {job_ids_str}). Please specify the job_id instead.')
job_id = managed_jobs[0]['job_id']
assert job_id is not None, (job_id, job_name)
# TODO: keep sync with job_lib.JobLibCodeGen.tail_logs
# TODO: keep the following code sync with
# job_lib.JobLibCodeGen.tail_logs, we do not directly call that function
# as the following code need to be run in the current machine, instead
# of running remotely.
run_timestamp = job_lib.get_run_timestamp(job_id)
if run_timestamp is None:
return f'No managed job contrller log found with job_id {job_id}.'
Expand Down Expand Up @@ -750,10 +757,11 @@ class ManagedJobCodeGen:
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 = managed_job_constants.MANAGED_JOBS_VERSION
except ImportError:
from sky.spot import spot_state as state, spot_utils as utils
from sky.spot import spot_state as managed_job_state
from sky.spot import spot_utils as utils
""")

@classmethod
Expand Down Expand Up @@ -799,6 +807,7 @@ def stream_logs(cls,
from sky.skylet import job_lib, log_lib
from sky.skylet import constants
from sky.jobs.utils import stream_logs_by_id
from typing import Optional
""")
code += inspect.getsource(stream_logs)
code += textwrap.dedent(f"""\
Expand Down
2 changes: 2 additions & 0 deletions sky/skylet/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@
# backend_utils.write_cluster_config.
RAY_SKYPILOT_INSTALLATION_COMMANDS = (
'mkdir -p ~/sky_workdir && mkdir -p ~/.sky/sky_app;'
# Disable the pip version check to avoid the warning message, which makes
# the output hard to read.
'export PIP_DISABLE_PIP_VERSION_CHECK=1;'
# Print the PATH in provision.log to help debug PATH issues.
'echo PATH=$PATH; '
Expand Down
2 changes: 2 additions & 0 deletions sky/templates/jobs-controller.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ file_mounts:

setup: |
{{ sky_activate_python_env }}
# Disable the pip version check to avoid the warning message, which makes the
# output hard to read.
export PIP_DISABLE_PIP_VERSION_CHECK=1

{%- for cmd in cloud_dependencies_installation_commands %}
Expand Down
2 changes: 2 additions & 0 deletions sky/templates/sky-serve-controller.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ name: {{service_name}}

setup: |
{{ sky_activate_python_env }}
# Disable the pip version check to avoid the warning message, which makes the
# output hard to read.
export PIP_DISABLE_PIP_VERSION_CHECK=1

# Install all cloud dependencies.
Expand Down

0 comments on commit 3ad060f

Please sign in to comment.