Skip to content
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

Sanitize KFP input/output params in kwargs #2533

Merged

Conversation

thesuperzapper
Copy link
Member

What changes were proposed in this pull request?

This PR prevents Elyra from throwing an error when it tries to pass invalid kwargs to a KFP component-factory function.

Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/elyra/pipeline/kfp/processor_kfp.py", line 622, in _cc_pipeline
    container_op = factory_function(**operation.component_params_as_dict)
TypeError: My Component - 0.1.0() got an unexpected keyword argument 'my-input'

A Kubeflow component can name its inputs/outputs things that are not valid python kwargs names, in these cases, KFP silently renames these inputs by replacing the invalid characters with _.

It is also possible to have a case where multiple different parameters map to the same "sanitized value". In these cases, KFP appends a number to the end of the ones which were transformed (starting at 2). But because elyra stores parameters in an unordered dictionary, we can't possibly know which one maps to which index. (But it's probably not a huge issue if we don't support this extreme edge case)

How was this pull request tested?

I have tested this in a Kubeflow cluster with a component that has parameters named things like my-parameter-name, and they were correctly compiled and run.


Developer's Certificate of Origin 1.1

   By making a contribution to this project, I certify that:

   (a) The contribution was created in whole or in part by me and I
       have the right to submit it under the Apache License 2.0; or

   (b) The contribution is based upon previous work that, to the best
       of my knowledge, is covered under an appropriate open source
       license and I have the right under that license to submit that
       work with modifications, whether created in whole or in part
       by me, under the same open source license (unless I am
       permitted to submit under a different license), as indicated
       in the file; or

   (c) The contribution was provided directly to me by some other
       person who certified (a), (b) or (c) and I have not modified
       it.

   (d) I understand and agree that this project and the contribution
       are public and that a record of the contribution (including all
       personal information I submit with it, including my sign-off) is
       maintained indefinitely and may be redistributed consistent with
       this project or the open source license(s) involved.

@elyra-bot
Copy link

elyra-bot bot commented Mar 4, 2022

Thanks for making a pull request to Elyra!

To try out this branch on binder, follow this link: Binder

@thesuperzapper thesuperzapper added this to the 3.7.0 milestone Mar 4, 2022
@ptitzler ptitzler added component:pipeline-runtime issues related to pipeline runtimes e.g. kubeflow pipelines kind:bug Something isn't working platform: pipeline-Kubeflow Related to usage of Kubeflow Pipelines as pipeline runtime labels Mar 4, 2022
Copy link
Member

@ptitzler ptitzler left a comment

Choose a reason for hiding this comment

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

LGTM

@akchinSTC akchinSTC merged commit a1558ce into elyra-ai:master Mar 7, 2022
@thesuperzapper thesuperzapper deleted the normalize-kfp-input-names branch March 8, 2022 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:pipeline-runtime issues related to pipeline runtimes e.g. kubeflow pipelines kind:bug Something isn't working platform: pipeline-Kubeflow Related to usage of Kubeflow Pipelines as pipeline runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants