forked from kubeflow/pipelines
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDK - Components refactoring (kubeflow#2865)
* SDK - Components refactoring This change is a pure refactoring of the implementation of component task creation. For pipelines compiled using the DSL compiler (the compile() function or the command-line program) nothing should change. The main goal of the refactoring is to change the way the component instantiation can be customized. Previously, the flow was like this: `ComponentSpec` + arguments --> `TaskSpec` --resolving+transform--> `ContainerOp` This PR changes it to more direct path: `ComponentSpec` + arguments --constructor--> `ContainerOp` or `ComponentSpec` + arguments --constructor--> `TaskSpec` or `ComponentSpec` + arguments --constructor--> `SomeCustomTask` The original approach where the flow always passes through `TaskSpec` had some issues since TaskSpec only accepts string arguments (and two other reference classes). This made it harder to handle custom types of arguments like PipelineParam or Channel. Low-level refactoring changes: Resolving of command-line argument placeholders has been extracted into a function usable by different task constructors. Changed `_components._created_task_transformation_handler` to `_components._container_task_constructor`. Previously, the handler was receiving a `TaskSpec` instance. Now it receives `ComponentSpec` + arguments [+ `ComponentReference`]. Moved the `ContainerOp` construction handler setup to the `kfp.dsl.Pipeline` context class as planned. Extracted `TaskSpec` creation to `_components._create_task_spec_from_component_and_arguments`. Refactored `_dsl_bridge.create_container_op_from_task` to `_components._resolve_command_line_and_paths` which returns `_ResolvedCommandLineAndPaths`. Renamed `_dsl_bridge._create_container_op_from_resolved_task` to `_dsl_bridge._create_container_op_from_component_and_arguments`. The signature of `_components._resolve_graph_task` was changed and it now returns `_ResolvedGraphTask` instead of modified `TaskSpec`. Some of the component tests still expect ContainerOp and its attributes. These tests will be changed later. * Adapted the _python_op tests * Fixed linter failure I do not want to add any top-level kfp imports in this file to prevent circular references. * Added docstrings * FIxed the return type forward reference
- Loading branch information
Showing
7 changed files
with
358 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.