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

SDK - Components - Creating graph components from python pipeline function #2273

Conversation

Ark-kun
Copy link
Contributor

@Ark-kun Ark-kun commented Oct 1, 2019

The experimental create_graph_component_from_pipeline_func creates graph component definition from a python pipeline function. The component file can be published for sharing.
Pipeline function is a function that only calls component functions and passes outputs to inputs.
This feature is experimental and lacks support for some of the DSL features like conditions and loops.
Only pipelines consisting of loaded components or python components are supported at this moment(no manually created ContainerOps or ResourceOps).

Example:

producer_op = load_component_from_file('producer/component.yaml')
processor_op = load_component_from_file('processor/component.yaml')

def pipeline1(pipeline_param_1: int):
    producer_task = producer_op()
    processor_task = processor_op(pipeline_param_1, producer_task.outputs['Output 2'])

    return OrderedDict([ # You can safely return normal dict in python 3.6+
        ('Pipeline output 1', producer_task.outputs['Output 1']),
        ('Pipeline output 2', processor_task.outputs['Output 2']),
    ])

create_graph_component_from_pipeline_func(pipeline1, output_component_file='pipeline1.component.yaml')

This change is Reviewable

`create_graph_component_from_pipeline_func` converts python pipeline function to a graph component object that can be saved, shared, composed or submitted for execution.

Example:

    producer_op = load_component(component_with_0_inputs_and_2_outputs)
    processor_op = load_component(component_with_2_inputs_and_2_outputs)

    def pipeline1(pipeline_param_1: int):
        producer_task = producer_op()
        processor_task = processor_op(pipeline_param_1, producer_task.outputs['Output 2'])

        return OrderedDict([
            ('Pipeline output 1', producer_task.outputs['Output 1']),
            ('Pipeline output 2', processor_task.outputs['Output 2']),
        ])

    graph_component = create_graph_component_from_pipeline_func(pipeline1)
Non-public create_graph_component_spec_from_pipeline_func creates ComponentSpec
Public create_graph_component_from_pipeline_func creates component and writes it to file.
…gnature

Stopped humanizing the input names for now. I think it's benefitial to extract interface from function signature the same way for both container and graph python components.
Ark-kun and others added 3 commits September 30, 2019 18:31
Remove the component spec from component reference unless it will make the reference empty or unless explicitly asked by the user
@Ark-kun Ark-kun force-pushed the SDK---Components---Creating-graph-components-from-python-pipeline-function---2 branch from 1fa60fb to e410b4d Compare October 1, 2019 01:31
@Ark-kun Ark-kun force-pushed the SDK---Components---Creating-graph-components-from-python-pipeline-function---2 branch from 34f1431 to 66ebd74 Compare October 2, 2019 21:13
@numerology
Copy link

/lgtm
The year in the unittest python file also needs to change. Thanks!

@Ark-kun Ark-kun force-pushed the SDK---Components---Creating-graph-components-from-python-pipeline-function---2 branch from 66ebd74 to 1e59cfc Compare October 2, 2019 21:38
@k8s-ci-robot k8s-ci-robot removed the lgtm label Oct 2, 2019
@Ark-kun
Copy link
Contributor Author

Ark-kun commented Oct 2, 2019

/lgtm
The year in the unittest python file also needs to change. Thanks!

Looks like I did git commit --amend without actually adding that file. Fixed now.

@numerology
Copy link

/lgtm

@Ark-kun
Copy link
Contributor Author

Ark-kun commented Oct 2, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit be4f585 into kubeflow:master Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants