Skip to content

LocalProcessBackend.list_jobs() returns TrainJob objects with Unknown status instead of actual job status #703

Description

What happened?

While looking through the LocalProcessBackend implementation, I noticed that list_jobs() and get_job() don't return consistent TrainJob objects.

get_job() calculates the job status using __get_job_status() before creating the TrainJob, but list_jobs() creates the same object without setting the status field.

Since TrainJob.status defaults to Unknown, every job returned by list_jobs() reports Unknown even if the underlying job has already completed, failed, or is running.

What did you expect to happen?

I expected list_jobs() to return the same status information as get_job(), since both APIs represent the same TrainJob.

How to reproduce

Looking at the implementation:

get_job() does:

status = self.__get_job_status(_job)

return types.TrainJob(
...
status=status,
)


But `list_jobs()` constructs the object without setting `status`:


types.TrainJob(
    name=_job.name,
    creation_timestamp=_job.created,
    runtime=runtime,
    num_nodes=1,
    steps=[...],
)


I also reproduced this with a small unit test by creating a local job whose step status is `TRAINJOB_COMPLETE`. Calling `list_jobs()` still returns a `TrainJob` with `status == "Unknown"` instead of `"Complete"`.

 **Why this matters**

This makes the behavior inconsistent between `list_jobs()` and `get_job()`. A caller using `list_jobs()` cannot rely on the returned status, even though the backend already has enough information to determine it.



### What did you expect to happen?

I expected list_jobs() to return the actual status of each TrainJob, consistent with get_job(). If a job has already completed, failed, or is running, list_jobs() should report that status instead of always returning Unknown.

### Environment

Kubernetes version:
```bash
$ kubectl version

Kubeflow Trainer version:

$ kubectl get pods -n kubeflow -l app.kubernetes.io/name=trainer -o jsonpath="{.items[*].spec.containers[*].image}"

Kubeflow Python SDK version:

$ pip show kubeflow

Impacted by this bug?

Give it a 👍 We prioritize the issues with most 👍

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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