-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(sdk): auto-detect and install Kubeflow SDK for component functions #12027 #12368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(sdk): auto-detect and install Kubeflow SDK for component functions #12027 #12368
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @Prateekbala. Thanks for your PR. I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
🚫 This command cannot be processed. Only organization members or owners can use the commands. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ok-to-test
@Prateekbala could you please add a sign off to your commit? |
8f7cf52
to
8c10e7b
Compare
This commit adds automatic detection and installation of kubeflow packages when they are imported in component functions. Key changes: - Added _detect_kubeflow_imports_in_function() to analyze AST for kubeflow imports - Added _parse_package_name() helper to extract clean package names - Enhanced _get_packages_to_install_command() to include kubeflow when detected - Added install_kubeflow_package parameter to @component decorator - Added kubeflow extras to setup.py for optional dependency management - Fixed type annotation syntax in component_factory_test.py - Fixed test function implementations to include actual kubeflow imports - Corrected InputPath/OutputPath type annotations with proper type parameters All tests now pass successfully. Signed-off-by: Prateek Bala <[email protected]>
…o feature/kubeflow-sdk-integrate
8c10e7b
to
f5c34d1
Compare
|
Description
This PR implements automatic Kubeflow SDK integration for KFP components as requested in #12027. It adds the ability to automatically detect and install the Kubeflow SDK when components use kubeflow imports, while also providing explicit extras for opt-in installation.
Changes Made
1. Added Kubeflow Extras to setup.py
kubeflow = ['kubeflow']
extras option'all'
extras bundlepip install kfp[kubeflow]
orpip install kfp[all]
2. Implemented AST-based Auto-detection
_detect_kubeflow_imports_in_function()
incomponent_factory.py
ast
+inspect
+textwrap.dedent
) to detect kubeflow imports in component functionsimport kubeflow
import kubeflow.<submodule>
from kubeflow import <symbol>
3. Automatic Package Installation
_get_packages_to_install_command(...)
to auto-detect kubeflow usage'kubeflow'
topackages_to_install
when detected and not already specified4. Opt-out Control per Component
@dsl.component
withinstall_kubeflow_package: bool = True
True
(default): auto-add kubeflow if user code imports itFalse
: never auto-add kubeflow for that component5. Comprehensive Test Coverage
Usage
Install via extras:
Default auto-detection (no user change needed):
Opt-out:
Related Issues
Fixes #12027