pipelines icon indicating copy to clipboard operation
pipelines copied to clipboard

[feature] Support serializable classes as a parameter

Open diegolovison opened this issue 1 year ago • 1 comments

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()

diegolovison avatar Aug 27 '24 17:08 diegolovison

👏👏👏

franciscojavierarceo avatar Aug 27 '24 22:08 franciscojavierarceo

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[bot] avatar Oct 27 '24 07:10 github-actions[bot]

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

github-actions[bot] avatar Nov 17 '24 07:11 github-actions[bot]

/reopen

diegolovison avatar Nov 18 '24 13:11 diegolovison

@diegolovison: Reopened this issue.

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.

google-oss-prow[bot] avatar Nov 18 '24 13:11 google-oss-prow[bot]

Any update on this?

gasparev avatar Jan 08 '25 11:01 gasparev

/lifecycle frozen

hbelmiro avatar Jan 10 '25 11:01 hbelmiro