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

[feature] Pydantic #10690

Closed
mikeedjones opened this issue Apr 11, 2024 · 7 comments
Closed

[feature] Pydantic #10690

mikeedjones opened this issue Apr 11, 2024 · 7 comments
Labels
kind/feature lifecycle/stale The issue / pull request is stale, any activities remove this label.

Comments

@mikeedjones
Copy link

mikeedjones commented Apr 11, 2024

Feature Area

What feature would you like to see?

I would like to be able to typehint containerized and lightweight python components, and pipelines, using Pydantic Models - and have the validation of those models occur automatically, making the validated models available inside the component code.

from pydantic import BaseModel

class MyModel(BaseModel):
    foo: str

@component(target_image="myimage")
def my_function_one(my_data: MyModel):
    print(my_data.foo)

What is the use case or pain point?

At the moment I'm passing complex hierarchical dictionaries as parameters to kubeflow using Dict[str, Any] and then validating those dictionaries inside the function code, as below

from pydantic import BaseModel

class MyModel(BaseModel):
    foo: str

@component(target_image="myimage")
def my_function_one(my_data: Dict[str, Any]):
    from . import MyModel
    my_data_validated = MyModel.model_validate(my_data)
    print(my_data_validated.foo)

Where myimage has the base model available.

Is there a workaround currently?

This gist shows my current attempt at a reusable workaround.


Love this idea? Give it a 👍.

@rimolive
Copy link
Member

Please join our next Pipelines WG meeting to discuss about this feature.

@caroline-paul99
Copy link

Hi @mikeedjones Im coming from Issue #10210 what is the state of this issue? Also what version of KFP are you trying to update?

@mikeedjones
Copy link
Author

mikeedjones commented Apr 28, 2024

Think mine is more of a feature request for future versions of 2.x - I'm not sure that your request is covered by what I had in mind :(

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the lifecycle/stale The issue / pull request is stale, any activities remove this label. label Jun 28, 2024
Copy link

This issue has been automatically closed because it has not had recent activity. Please comment "/reopen" to reopen it.

@AndresPrez
Copy link

/reopen

Copy link

@AndresPrez: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature lifecycle/stale The issue / pull request is stale, any activities remove this label.
Projects
None yet
Development

No branches or pull requests

4 participants