Skip to content

trainer get_job_logs should wait for pods to be running when follow=True #182

@AndEsterson

Description

@AndEsterson

What you would like to be added?

When running trainer.get_job_logs(job_id, follow=True), currently if the relevant pod does not exist, or is pending, the function exits without returning anything. Instead when follow=true, it would be good to wait for the pod to be running (potentially with some timeout)

def get_job_logs(
self,
name: str,
follow: bool = False,
step: str = constants.NODE + "-0",
) -> Iterator[str]:
"""Get the TrainJob logs"""
# Get the TrainJob Pod name.
pod_name = None
for c in self.get_job(name).steps:
if c.status != constants.POD_PENDING and c.name == step:
pod_name = c.pod_name
break
if pod_name is None:
return

Why is this needed?

When follow=False, the user expects an empty response if no pod logs exist, but a common use case for follow=True is to watch a job immediately after submitting it, in this case the pods are unlikely to exist, meaning with the current behaviour the user must implement their own logic to wait for the pod.

Love this feature?

Give it a 👍 We prioritize the features with most 👍

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions