-
Notifications
You must be signed in to change notification settings - Fork 512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Jobs] Allow logs for finished jobs and add sky jobs logs --refresh
for restartin jobs controller
#4380
base: master
Are you sure you want to change the base?
Conversation
sky jobs logs --refresh
for restartin jobs controller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this @Michaelvll ! Left some discussions.
handle: cloud_vm_ray_backend.CloudVmRayResourceHandle) -> None: | ||
self, task_id: Optional[int], | ||
handle: Optional[cloud_vm_ray_backend.CloudVmRayResourceHandle] | ||
) -> None: | ||
"""Downloads and streams the logs of the latest job. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Downloads and streams the logs of the latest job. | |
"""Downloads and streams the logs of the given task id. |
is this correct?
refresh=False, | ||
include_controller=False) | ||
if clusters: | ||
handle = clusters[0].get('handle') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle = clusters[0].get('handle') | |
assert len(clusters) == 1 | |
handle = clusters[0].get('handle') |
@@ -382,15 +397,25 @@ def tail_logs(name: Optional[str], job_id: Optional[int], follow: bool, | |||
sky.exceptions.ClusterNotUpError: the jobs controller is not up. | |||
""" | |||
# TODO(zhwu): Automatically restart the jobs controller | |||
if name is not None and job_id is not None: | |||
raise ValueError('Cannot specify both name and job_id.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ux_utils?
def set_local_log_file(job_id: int, task_id: Optional[int], | ||
local_log_file: str): | ||
"""Set the local log file for a job.""" | ||
task_str = '' if task_id is None else f' AND task_id={task_id}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure do we need to pass in task_id as ?
.. Actually, is there any difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should just use ?
everywhere to avoid having to reason about where injection may be possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems super useful, thanks!
def set_local_log_file(job_id: int, task_id: Optional[int], | ||
local_log_file: str): | ||
"""Set the local log file for a job.""" | ||
task_str = '' if task_id is None else f' AND task_id={task_id}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should just use ?
everywhere to avoid having to reason about where injection may be possible.
|
||
def get_local_log_file(job_id: int, task_id: Optional[int]) -> Optional[str]: | ||
"""Get the local log directory for a job.""" | ||
task_str = '' if task_id is None else f' AND task_id={task_id}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Stream the logs to the console without reading the whole | ||
# file into memory. | ||
start_streaming = False | ||
for line in f: | ||
if log_lib.LOG_FILE_START_STREAMING_AT in line: | ||
start_streaming = True | ||
if start_streaming: | ||
print(line, end='', flush=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move this into some utils file?
Currently,
sky jobs logs
does not work with finished jobs, although we do have the logs downloaded for failed jobs to the controller. We now enablesky jobs logs
for all finished jobs, including succeeded ones.Tested (run the relevant ones):
bash format.sh
pytest tests/test_smoke.py
pytest tests/test_smoke.py::test_fill_in_the_name
conda deactivate; bash -i tests/backward_compatibility_tests.sh