kfp.components
The kfp.components module contains functions for loading components from compiled YAML.
- 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.
- abstract execute(**kwargs)[source]
Executes the component locally if implemented by the inheriting subclass.
- 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.
- execute(**kwargs)[source]
Executes the component locally if implemented by the inheriting subclass.
- 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
component_spec – Component definition.
python_func – Python function that becomes the implementation of this component.
- execute(**kwargs)[source]
Executes the Python function that defines the component.
- class kfp.components.YamlComponent(component_spec: ComponentSpec)[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.- Parameters
component_spec – Component definition.
- execute(*args, **kwargs)[source]
Not implemented.
- kfp.components.load_component_from_file(file_path: str) YamlComponent [source]
Loads a component from a file.
- Parameters
file_path (str) – Filepath to a YAML component.
- Returns
Component loaded from YAML.
Example
from kfp import components components.load_component_from_file('~/path/to/pipeline.yaml')
- kfp.components.load_component_from_text(text: str) YamlComponent [source]
Loads a component from text.
- Parameters
text (str) – Component YAML text.
- Returns
Component loaded from YAML.
- kfp.components.load_component_from_url(url: str, auth: Optional[Tuple[str, str]] = 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')