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] Support serializable classes as a parameter #11141

Open
diegolovison opened this issue Aug 27, 2024 · 2 comments
Open

[feature] Support serializable classes as a parameter #11141

diegolovison opened this issue Aug 27, 2024 · 2 comments
Labels
area/sdk kind/feature lifecycle/stale The issue / pull request is stale, any activities remove this label.

Comments

@diegolovison
Copy link
Contributor

Feature Area

/area sdk

What feature would you like to see?

Being able to send an argument that is a serializable class to a @dsl.component function

What is the use case or pain point?

Reduce code duplication.

Is there a workaround currently?

Copy and paste the function multiple times inside the @dsl.component

Code example that must work:

from kfp import dsl
from kfp.compiler import Compiler
from kfp import local


local.init(runner=local.SubprocessRunner())


class MyExample:
    def do_sum(self, a, b):
        return a + b


@dsl.component(base_image="docker.io/library/python:3.10")
def do_something(my_example: MyExample):
    result = my_example.do_sum(1, 2)
    assert result == 3


@dsl.pipeline(name="simple_example")
def my_pipeline():
    my_example = MyExample()
    task = do_something(my_example)


if __name__ == "__main__":
    Compiler().compile(my_pipeline, "my_pipeline.yaml")

    # Execute the pipeline directly
    my_pipeline()
@franciscojavierarceo
Copy link

👏👏👏

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 Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sdk kind/feature lifecycle/stale The issue / pull request is stale, any activities remove this label.
Projects
None yet
Development

No branches or pull requests

2 participants