Skip to content

fix: Defer kubernetes imports to method level for use with local mode#3167

Merged
google-oss-prow[bot] merged 3 commits into
kubeflow:masterfrom
Fiona-Waters:move-imports
Feb 5, 2026
Merged

fix: Defer kubernetes imports to method level for use with local mode#3167
google-oss-prow[bot] merged 3 commits into
kubeflow:masterfrom
Fiona-Waters:move-imports

Conversation

@Fiona-Waters

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Following on from this Kubeflow SDK PR adding Initializers to local podman/docker mode, these imports need to be deffered to the method level so that kubernetes config is not required in these local environments, these changes do not break existing functionality.

Which issue(s) this PR fixes (optional, in Fixes #<issue number>, #<issue number>, ... format, will close the issue(s) when PR gets merged):
Fixes #

Checklist:

  • Docs included if any changes are user facing

@github-actions

github-actions Bot commented Feb 3, 2026

Copy link
Copy Markdown

🎉 Welcome to the Kubeflow Trainer! 🎉

Thanks for opening your first PR! We're happy to have you as part of our community 🚀

Here's what happens next:

  • If you haven't already, please check out our Contributing Guide for repo-specific guidelines and the Kubeflow Contributor Guide for general community standards.
  • Our team will review your PR soon! cc @kubeflow/kubeflow-trainer-team

Join the community:

Feel free to ask questions in the comments if you need any help or clarification!
Thanks again for contributing to Kubeflow! 🙏

@coveralls

coveralls commented Feb 3, 2026

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 21711780024

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 51.217%

Totals Coverage Status
Change from base Build 21703881784: 0.0%
Covered Lines: 1241
Relevant Lines: 2423

💛 - Coveralls

@Fiona-Waters

Copy link
Copy Markdown
Contributor Author

@andreyvelich @astefanutti please take a look. Thank you.

Comment on lines -4 to -7
from kubernetes import client, config
from kubernetes.client.rest import ApiException
from kubernetes.dynamic.exceptions import ConflictError

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting, so we plan to re-use the same initializers for container execution as well?
How are we planning to use cache initializer there?
cc @akshaychitneni

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only data and model initializers are supported for container execution. Since container backend is designed for simpler local execution I don't think it makes sense to support cache initializer there. WDYT?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correct, we are not going to support data cache initializer in container backed for now: kubeflow/sdk#188 (comment)
In that case, why do we need to move these imports under def download_dataset(self): ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's because of this import - https://github.com/kubeflow/trainer/blob/master/pkg/initializers/dataset/__main__.py#L6
maybe it would be better to move that inside the relevant case instead?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That'd make sense to move the imports in each corresponding case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've updated to do this. Thanks. I don't think that the PR checks that are failing are related to my changes - could we re-run the tests?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, I agree with @astefanutti

@astefanutti

Copy link
Copy Markdown
Contributor

Thanks @Fiona-Waters!

/lgtm

@astefanutti

Copy link
Copy Markdown
Contributor

/retest

@astefanutti

Copy link
Copy Markdown
Contributor

/lgtm
/approve

Thanks @Fiona-Waters!

@google-oss-prow google-oss-prow Bot added the lgtm label Feb 5, 2026
@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: astefanutti

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow Bot merged commit 781606d into kubeflow:master Feb 5, 2026
30 of 33 checks passed
@google-oss-prow google-oss-prow Bot added this to the v2.2 milestone Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants