-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
WithParams #2044
WithParams #2044
Conversation
/retest |
|
||
if isinstance(items[0], dict): | ||
if isinstance(items, list) and isinstance(items[0], dict): | ||
subvar_names = set(items[0].keys()) |
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.
How does Argo resolve {{item.a}}
when the key a
is missing?
/lgtm |
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.
Hello everyone,
@kevinbache nice job there!
There is just one small issue I'd like to address.
If a user passes a mixed list of static values (non-dict) and PipelineParam
s, then the output looks like this
withItems:
- 5
- !!python/object:kfp.dsl._pipeline_param.PipelineParam
name: my-pipe-param
op_name: null
param_type: null
pattern: '{{pipelineparam:op=;name=my-pipe-param}}'
value: null
This should definitely be avoided. It can be easily achieved by performing some checks and raising ValueError()
with a proper message.
Similarly, when users pass a mixed list of dicts and PipelineParam
s they either get
Traceback (most recent call last):
File "withitem_basic.py", line 59, in <module>
print(compiler.Compiler().compile(pipeline, package_path=None))
File "/home/elias/git/hub/arrikto/kubeflow-pipelines/sdk/python/kfp/compiler/compiler.py", line 785, in compile
workflow = self._compile(pipeline_func)
File "/home/elias/git/hub/arrikto/kubeflow-pipelines/sdk/python/kfp/compiler/compiler.py", line 715, in _compile
pipeline_func(*args_list)
File "withitem_basic.py", line 34, in pipeline
with dsl.ParallelFor(loop_args) as item:
File "/home/elias/git/hub/arrikto/kubeflow-pipelines/sdk/python/kfp/dsl/_ops_group.py", line 183, in __init__
loop_args = _for_loop.LoopArguments(loop_args, code)
File "/home/elias/git/hub/arrikto/kubeflow-pipelines/sdk/python/kfp/dsl/_for_loop.py", line 43, in __init__
if not set(item.keys()) == subvar_names:
AttributeError: 'PipelineParam' object has no attribute 'keys'
or
withItems:
- !!python/object:kfp.dsl._pipeline_param.PipelineParam
name: my-pipe-param
op_name: null
param_type: null
pattern: '{{pipelineparam:op=;name=my-pipe-param}}'
value: null
- a: 1
b: 2
- a: 10
b: 20
All in all, I believe there should be errors and proper messages checking and informing for the following:
ParallelFor
may get as arguments either:
- one
PipelineParam
, - one primitive value,
- one dict, or
- a list of primitive values or a list of dicts with the same keys
And check for mixed list of dicts & primitives is missing, but I should have seen and mentioned it in the PR adding withItems
. It can be fixed in a separate PR.
Nice catch. I think we should not allow
All values need to be converted to strings before inserting into the workflow dict.
This one would have been caught by #2055 |
/retest |
@elikatsis thanks for the catches! the dict keys parity check in the LoopArguments constructor should catch the mixed list of dicts+singletons case that you mentioned. feel free to let me know if you have any other questions and thanks again. /ping for re-approves |
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.
responding
/lgtm |
We should probably simplify some of the scratch parts of the test files in another PR. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Ark-kun The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
Signed-off-by: Suresh Nakkeran <suresh.n@ideas2it.com>
This PR adds WithParams support.
This change is