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

ContainerOp alternative #4713

Closed
tom-dd opened this issue Nov 3, 2020 · 13 comments
Closed

ContainerOp alternative #4713

tom-dd opened this issue Nov 3, 2020 · 13 comments
Assignees
Labels
area/sdk/components lifecycle/stale The issue / pull request is stale, any activities remove this label.

Comments

@tom-dd
Copy link

tom-dd commented Nov 3, 2020

Per request of @Bobgy:

Currently, when using ContainerOp you will get the following warning:

FutureWarning: Please create reusable components instead of constructing ContainerOp instances directly. Reusable components are shareable, portable and have compatibility and support guarantees. Please see the documentation: https://www.kubeflow.org/docs/pipelines/sdk/component-development/#writing-your-component-definition-file The components can be created manually (or, in case of python, using kfp.components.create_component_from_func or func_to_container_op) and then loaded using kfp.components.load_component_from_file, load_component_from_uri or load_component_from_text: https://kubeflow-pipelines.readthedocs.io/en/latest/source/kfp.components.html#kfp.components.load_component_from_file
  category=FutureWarning,

The alternatives requires you to specify your ContainerOp instance as either yaml or json if you want to use it inline. This option however lacks the editor/type checking support that you would get when using the Python based ContainerOp.

Proposals:

  • Offer a Python based alternative for defining your ContainerOp instance in a future proof way
  • Yaml schema's could offer editor support for the content of the definition, however it will probably be less convinient than native Python code.
@Bobgy
Copy link
Contributor

Bobgy commented Nov 3, 2020

/assign @chensun @Ark-kun

@Ark-kun
Copy link
Contributor

Ark-kun commented Nov 4, 2020

The alternatives requires you to specify your ContainerOp instance as either yaml or json if you want to use it inline.

There are also lightweight python components created using kfp.components.create_component_from_func.

This option however lacks the editor/type checking support that you would get when using the Python based ContainerOp.

Can you describe the problems you're seeing?
The loaded components are represented as strongly typed functions.
When working in a Jupyter environment, the editor shows the help for the parameters and help(op) works as well. Does this work for you?

Yaml schema's could offer editor support for the content of the definition

Can you please help me understand this request. ComponentSpec has a schema and also when you load a component from URL, file or inline text, the component structure is validated. Is there something missing?

Offer a Python based alternative for defining your ContainerOp instance in a future proof way

It's possible to construct an instance of the kfp.components.structures.ComponentsSpec class and then .save it. I'm not sure this is more convenient than lightweight python components or manual component.yaml authoring. I'd like to hear your thoughts.

@Bobgy
Copy link
Contributor

Bobgy commented Nov 4, 2020

@Ark-kun you might want to check more context in the slack discussion: https://kubeflow.slack.com/archives/CE10KS9M4/p1604333477307400

@munagekar
Copy link
Contributor

Comments on #4644 might be relevant.

@Bobgy
Copy link
Contributor

Bobgy commented Nov 4, 2020

There was a great example for component spec python class in #3748 (comment).

@tom-dd
Copy link
Author

tom-dd commented Nov 10, 2020

There are also lightweight python components created using kfp.components.create_component_from_func.

In our case, we are coming from a "legacy" environment where we have all our pipeline code in a large container, so unfortunately we are not lightweight anymore.

Can you describe the problems you're seeing?
The loaded components are represented as strongly typed functions.
When working in a Jupyter environment, the editor shows the help for the parameters and help(op) works as well. Does this work for you?

We are not using Notebooks at the moment, so I cannot judge how that would work. However, when you have pylint/mypy check your code for type safety it helps if also your ContainerOp definitions can be checked as well.

Yaml schema's could offer editor support for the content of the definition

Can you please help me understand this request. ComponentSpec has a schema and also when you load a component from URL, file or inline text, the component structure is validated. Is there something missing?

It is validated when you load them, but having validation/autocomplete while you are writing specs is very helpful

It's possible to construct an instance of the kfp.components.structures.ComponentsSpec class and then .save it. I'm not sure this is more convenient than lightweight python components or manual component.yaml authoring. I'd like to hear your thoughts.

I guess this is close to what could work. If I take the (a reduced) example from the link @Bobgy posted, I can identify a case however that would be caught by my editor tooling with the ContainerOp route:

component_spec = ComponentSpec(
    name='Dummy op',
    description='Dummy component for illustrative purposes',
    inputs=[
        InputSpec(name='input1', type='String'),
    ],
    implementation=ContainerImplementation(container=ContainerSpec(
        image="dummy-image",
        command=[
            "python", "runner.py",
            "--input1", InputValuePlaceholder('inpt1'),
        ],
    ))
)

vs

def slack_notification(input1: str) -> ContainerOp:
    return ContainerOp(
        name="dummy-image",
        image="dummy-image",
        arguments=[
                "python", "runner.py",
                "--input1", inpt1
        ],
    )

My editor tooling would find that inpt1 doesn't exist

@stale
Copy link

stale bot commented Aug 28, 2021

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.

@stale stale bot added the lifecycle/stale The issue / pull request is stale, any activities remove this label. label Aug 28, 2021
@pbarker
Copy link

pbarker commented Nov 23, 2021

Also agree with this, maybe my editor (vscode) isn't loading components right, but having the ability to use autocomplete around operations is pivotal to developer experience. I would suggest not deprecating container_op unless necessary

@stale stale bot removed the lifecycle/stale The issue / pull request is stale, any activities remove this label. label Nov 23, 2021
@stale
Copy link

stale bot commented Mar 2, 2022

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.

@stale stale bot added the lifecycle/stale The issue / pull request is stale, any activities remove this label. label Mar 2, 2022
@andreclaudino
Copy link

@Ark-kun , you sugested using create_component_from_func, but it doen't allow creating components from containers in other technologies than Python, what in my openion is a great feature of Kubeflow, which is being lost when breaking ContainerOp.

@stale stale bot removed the lifecycle/stale The issue / pull request is stale, any activities remove this label. label Apr 15, 2022
@joesan
Copy link

joesan commented May 7, 2022

I'm also seeing this warning:

FutureWarning: Please create reusable components instead of constructing ContainerOp instances directly. Reusable components are shareable, portable and have compatibility and support guarantees. Please see the documentation: https://www.kubeflow.org/docs/pipelines/sdk/component-development/#writing-your-component-definition-file The components can be created manually (or, in case of python, using kfp.components.create_component_from_func or func_to_container_op) and then loaded using kfp.components.load_component_from_file, load_component_from_uri or load_component_from_text: https://kubeflow-pipelines.readthedocs.io/en/stable/source/kfp.components.html#kfp.components.load_component_from_file
  warnings.warn(

Do I simply ignore and just proceed?

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 25, 2024
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sdk/components lifecycle/stale The issue / pull request is stale, any activities remove this label.
Projects
Status: Closed
Development

No branches or pull requests

8 participants