Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Michaelvll
Copy link
Collaborator

@Michaelvll Michaelvll commented Nov 18, 2024

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 enable sky jobs logs for all finished jobs, including succeeded ones.

Tested (run the relevant ones):

  • Code formatting: bash format.sh
  • Any manual or new tests for this PR (please specify below)
  • All smoke tests: pytest tests/test_smoke.py
  • Relevant individual smoke tests: pytest tests/test_smoke.py::test_fill_in_the_name
  • Backward compatibility tests: conda deactivate; bash -i tests/backward_compatibility_tests.sh

@Michaelvll Michaelvll requested review from cblmemo and cg505 and removed request for cblmemo November 18, 2024 18:50
@Michaelvll Michaelvll changed the title [Jobs] Allow logs for finished jobs [Jobs] Allow logs for finished jobs and add sky jobs logs --refresh for restartin jobs controller Nov 18, 2024
Copy link
Collaborator

@cblmemo cblmemo left a 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ux_utils?

sky/jobs/state.py Show resolved Hide resolved
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}'
Copy link
Collaborator

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?

Copy link
Collaborator

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.

sky/utils/controller_utils.py Show resolved Hide resolved
Copy link
Collaborator

@cg505 cg505 left a 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}'
Copy link
Collaborator

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}'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +387 to +394
# 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)
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants