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:
Impacted by this bug?
Give it a 👍 We prioritize the issues with most 👍
What happened?
While looking through the
LocalProcessBackendimplementation, I noticed thatlist_jobs()andget_job()don't return consistentTrainJobobjects.get_job()calculates the job status using__get_job_status()before creating theTrainJob, butlist_jobs()creates the same object without setting thestatusfield.Since
TrainJob.statusdefaults toUnknown, every job returned bylist_jobs()reportsUnknowneven 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 asget_job(), since both APIs represent the sameTrainJob.How to reproduce
Looking at the implementation:
get_job()does:status = self.__get_job_status(_job)
return types.TrainJob(
...
status=status,
)
Kubeflow Trainer version:
$ kubectl get pods -n kubeflow -l app.kubernetes.io/name=trainer -o jsonpath="{.items[*].spec.containers[*].image}"Kubeflow Python SDK version:
Impacted by this bug?
Give it a 👍 We prioritize the issues with most 👍