-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(sdk): Add dict parameter access for granular value extraction #12419
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): Add dict parameter access for granular value extraction #12419
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 @wassimbensalem. 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. |
|
/assign |
Add support for extracting individual values from dictionary pipeline
parameters using Pythonic dict-style syntax (config['key']).
This enables:
- Single-level access: config['db_host']
- Nested access: config['database']['host']
- Sub-dict passing: config['database']
Changes:
- Add DictSubvariable class to represent extracted dict values
- Add __getitem__ to PipelineParameterChannel for dict-style access
- Extend compiler to generate CEL parameter_expression_selector
- Skip strict type checking for DictSubvariable (runtime resolution)
- Add comprehensive unit and integration tests
Benefits:
- Improved security (components receive only needed data)
- Better code clarity and reduced coupling
- No backend changes required (uses existing CEL evaluation)
- Fully backward compatible
Example usage:
@dsl.pipeline
def my_pipeline(config: dict):
component1(host=config['database']['host'])
component2(db_config=config['database'])
Signed-off-by: wassimbensalem <[email protected]>
d49613f to
4c41ccf
Compare
|
/ok-to-test |
Signed-off-by: wassimbensalem <[email protected]>
ba16844 to
6ac511a
Compare
|
/ok-to-test |
- Remove trailing whitespace - Fix line length issues by breaking long lines - Reformat function arguments to comply with yapf style Signed-off-by: wassimbensalem <[email protected]>
|
/ok-to-test |
|
Is anything still missing here? |
Add Dict Parameter Access Feature for Pipeline Parameters
Summary
This PR adds support for extracting individual values from dictionary pipeline parameters using Pythonic syntax, eliminating the need to pass entire dictionaries to components that only need specific values.
Motivation
Previously, when a pipeline had a dictionary parameter, the entire dictionary had to be passed to every component, even if the component only needed a single value or subset. This led to:
Changes
1. New
DictSubvariableClass (sdk/python/kfp/dsl/pipeline_channel.py)DictSubvariableclass to represent values extracted from dict parameters__getitem__method toPipelineParameterChannelto enable dict-style access2. Compiler Support (
sdk/python/kfp/compiler/pipeline_spec_builder.py)DictSubvariableinstancesparameter_expression_selectorexpressions3. Type Checking (
sdk/python/kfp/dsl/pipeline_task.py)DictSubvariable4. Tests
pipeline_channel_test.pytest_data/pipeline_files/valid/pipeline_with_dict_parameter_access.pyUsage Examples
Single-Level Access
Nested Access
Sub-Dictionary Passing
Technical Details
Compile-Time vs Runtime
DictSubvariableobjects and the compiler generates CEL expressionsCEL Expression Generation
parseJson(string_value)["key"]parseJson(string_value)["database"]["host"]Benefits
Testing
Run unit tests:
Run integration test:
Checklist
Related Issues
Closes #12418
Additional Notes
This feature leverages existing backend CEL expression evaluation capabilities, so no server-side changes are required. All changes are SDK-side and applied at compile time.