kfp.components¶
The kfp.components module contains functions for loading components from compiled YAML.
Functions:
|
Loads a component from a file. |
|
Loads a component from a URL. |
|
Loads a component from text. |
Classes:
|
A component defined via Python function. |
|
Base class for a component. |
|
Component defined via pre-built container. |
|
A component loaded from a YAML file. |
- kfp.components.load_component_from_file(file_path: str) YamlComponent [source]¶
Loads a component from a file.
Example
from kfp import components components.load_component_from_file('~/path/to/pipeline.yaml')
-
kfp.components.load_component_from_url(url: str, auth: tuple[str, str] | None =
None
) YamlComponent [source]¶ Loads a component from a URL.
- Parameters¶
- url : str¶
URL to a YAML component.
- auth : Tuple[str, str], optional¶
A
('<username>', '<password>')
tuple of authentication credentials necessary for URL access. See Requests Authorization for more information.
- Returns¶
Component loaded from YAML.
Example
from kfp import components components.load_component_from_url('https://raw.githubusercontent.com/kubeflow/pipelines/7b49eadf621a9054e1f1315c86f95fb8cf8c17c3/sdk/python/kfp/compiler/test_data/components/identity.yaml') components.load_component_from_url('gs://path/to/pipeline.yaml')
- kfp.components.load_component_from_text(text: str) YamlComponent [source]¶
Loads a component from text.
- class kfp.components.PythonComponent(component_spec: ComponentSpec, python_func: Callable)[source]¶
Bases:
BaseComponent
A component defined via Python function.
Note:
PythonComponent
is not intended to be used to construct components directly. Use@kfp.dsl.component
instead.- Parameters¶
Methods:
execute
(**kwargs)Executes the Python function that defines the component.
- class kfp.components.BaseComponent(component_spec: ComponentSpec)[source]¶
Bases:
ABC
Base class for a component.
Note:
BaseComponent
is not intended to be used to construct components directly. Use@kfp.dsl.component
orkfp.components.load_component_from_*()
instead.- name¶
Name of the component.
- component_spec¶
Component definition.
Attributes:
Returns the pipeline spec of the component.
Returns the PlatformSpec of the component.
Methods:
execute
(**kwargs)Executes the component locally if implemented by the inheriting subclass.
- property pipeline_spec : PipelineSpec¶
Returns the pipeline spec of the component.
- property platform_spec : PlatformSpec¶
Returns the PlatformSpec of the component.
Useful when the component is a GraphComponent, else will be empty per component_spec.platform_spec default.
- abstract execute(**kwargs)[source]¶
Executes the component locally if implemented by the inheriting subclass.
- property required_inputs : list[str]¶
- class kfp.components.ContainerComponent(component_spec: ComponentSpec, pipeline_func: Callable)[source]¶
Bases:
BaseComponent
Component defined via pre-built container.
- Attribute:
pipeline_func: The function that becomes the implementation of this component.
Methods:
execute
(**kwargs)Executes the component locally if implemented by the inheriting subclass.
- class kfp.components.YamlComponent(component_spec: ComponentSpec, component_yaml: str)[source]¶
Bases:
BaseComponent
A component loaded from a YAML file.
Note:
YamlComponent
is not intended to be used to construct components directly. Usekfp.components.load_component_from_*()
instead.- Attribute:
component_spec: Component definition. component_yaml: The yaml string that this component is loaded from.
Attributes:
Returns the pipeline spec of the component.
Methods:
execute
(*args, **kwargs)Not implemented.
- property pipeline_spec : PipelineSpec¶
Returns the pipeline spec of the component.