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

create_component_from_func vs func_to_container_op #7794

Closed
thethiny opened this issue May 26, 2022 · 7 comments
Closed

create_component_from_func vs func_to_container_op #7794

thethiny opened this issue May 26, 2022 · 7 comments

Comments

@thethiny
Copy link

I don't seem to understand the behavior behind these two functions.
I have been using create_component_from_func for all of my pipelines, however all tutorials and guides I'm seeing online use func_to_container_op and the docstrings don't explain them enough (They both say Converts a Python function to a component and returns a task).
Can anyone elaborate on this as the documentation doesn't include much info about this?

@wenboown
Copy link

wenboown commented Jun 3, 2022

What is the difference between create_component_from_func and func_to_container_op?
They are equivalent, but func_to_container_op is deprecated in v2 of the SDK. For more information on what has been deprecated see here:
#6133

Credit: Alexandre Brown in Community Slack

ref: https://journal.arrikto.com/kubeflow-tips-tricks-january-2022-238fde12f7d0

@zijianjoy
Copy link
Collaborator

We are moving away from func_to_container_op in KFPv1, we suggest to use create_component_from_func in KFPv1.

For KFPv2, we are moving away from both approaches above. We recommend using @component decorator in KFPv2.

Feel free to reopen this issue if you need more help.

@casassg
Copy link
Contributor

casassg commented Jul 20, 2022

@zijianjoy will create_component_from_func add extra_code? It's sometimes useful when defaults in a function are not a python primitive.

@zijianjoy
Copy link
Collaborator

cc @connor-mccarthy Do we support extra_code in create_component_from_func?

@connor-mccarthy
Copy link
Member

create_component_from_func does not support extra_code, though for some use-cases you can work around this by using subprocess.call or os.system to execute a subprocess within the Python code itself

@casassg
Copy link
Contributor

casassg commented Jul 20, 2022

This won't work as we need to add extra code before the function is instantiated in order to avoid issues on default values from the parsed function.

@connor-mccarthy
Copy link
Member

@casassg, I see. Yes, unfortunately that's one of the use-cases where this workaround will not work. The other approach is creating a containerized component that implements this.

I suspect this is a fairly common use-case. If you feel strongly about having extra_code functionality, please feel free to open a feature request issue requesting that this be included in v2, then the community can upvote it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants