LocalProcessBackend.list_jobs() returns incorrect runtime metadata for unfiltered job listings

Open Beginner friendly
#653 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
api, backend

Research direction

Start in kubeflow/trainer/backends/localprocess/backend.py and compare list_jobs() with get_job(), focusing on how runtime is selected when no filter is passed. Verify that listed TrainJob objects expose each stored job’s runtime and remain consistent with get_job(); run or add focused tests if available.

Written by the indexing model from the issue text.

Description

kind/bug needs-triage
What happened?

While reviewing the LocalProcessBackend, I compared the implementations of list_jobs() and get_job() to make sure both APIs return consistent job information.

During the review, I noticed that get_job() correctly returns the runtime stored inside each job by using:

runtime=_job.runtime,

However, list_jobs() behaves differently.

In kubeflow/trainer/backends/localprocess/backend.py, every TrainJob returned by list_jobs() is created using the method parameter:

runtime=runtime,

instead of the runtime that actually belongs to the job:

runtime=_job.runtime,


This becomes a problem when `list_jobs()` is called without a runtime filter, which is also the default behavior.

For example:

backend.list_jobs()

Since the runtime parameter is None, every returned TrainJob is populated with:

runtime=None


even though each job already has a valid runtime stored internally.

At the same time, requesting the exact same job through `get_job()` returns the correct runtime because it uses `_job.runtime`.

So the same job exposes different runtime information depending on which API is used. This makes the two APIs inconsistent and causes incorrect runtime metadata to be returned by `list_jobs()`.


Affected File**


kubeflow/trainer/backends/localprocess/backend.py


*Current Code**


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

Expected Code

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

Why this matters

list_jobs() should always return the runtime associated with each stored job. Instead, it returns the runtime filter passed to the function. When no filter is supplied, every returned TrainJob contains runtime=None, even though the actual runtime exists. This results in inconsistent API behavior and incorrect metadata being returned to callers.

What did you expect to happen?

list_jobs() should always return each TrainJob with its actual associated runtime (_job.runtime), regardless of whether a runtime filter is provided. The returned runtime information should be consistent with get_job().

Environment

Kubernetes version:

$ 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 👍

Dominant language
Python
Stars
148
Forks
263
Avg merge
1d 2h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from kubeflow/sdk

All issues in kubeflow/sdk

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.