API Reference
- class ml_orchestrator.ComponentParser(add_imports: ~typing.List[str] = <factory>, only_function: bool = False)[source]
A parser class that extends FunctionParser to create and manage components for Kubeflow pipelines (KFP), including decorators and serialized representations.
- add_imports
Additional import statements to prepend to output files.
- Type:
List[str]
- only_function
Whether to generate only the function body.
- Type:
bool
- classmethod create_decorator(component: MetaComponent) str[source]
Creates a decorator string for a given MetaComponent.
- Parameters:
component (MetaComponent) – The component object used to generate a decorator.
- Returns:
A decorator string for use in Kubeflow components.
- Return type:
str
- class ml_orchestrator.EnvironmentParams(base_image: str | None = None, target_image: str | None = None, packages_to_install: ~typing.List[str] = <factory>, pip_index_urls: ~typing.List[str] = <factory>, install_kfp_package: bool | None = None, kfp_package_path: str | None = None)[source]
A dataclass for defining the configuration parameters used to set up the environment for pipeline components, including Docker images, package installations, and Kubeflow settings.
- base_image
The base Docker image to use for building and running pipeline components.
- Type:
str
- target_image
The Docker image to be built as the finalized environment for pipeline execution.
- Type:
str
- packages_to_install
A list of additional packages to be installed inside the Docker image.
- Type:
List[str]
- pip_index_urls
A list of custom pip index URLs that can be used to search for Python packages.
- Type:
List[str]
- install_kfp_package
Indicates whether the Kubeflow Pipelines (KFP) package should be installed.
- Type:
bool
- kfp_package_path
The path or URL for the Kubeflow Pipelines (KFP) package to be used for installation.
- Type:
str
- classmethod comp_fields() Tuple[Field, ...][source]
Retrieve all the fields defined in the EnvironmentParams dataclass.
- Returns:
A tuple of field definitions.
- Return type:
Tuple[dataclasses.Field, …]
- comp_vars() Dict[Field, Any][source]
Retrieve a mapping of each dataclass field to its corresponding value for the current instance.
- Returns:
A dictionary mapping fields to their current values.
- Return type:
Dict[dataclasses.Field, Any]
- class ml_orchestrator.FunctionParser[source]
Handles the parsing and generation of components into KFP (Kubeflow Pipelines) DSL files.
This class is responsible for orchestrating the process of generating string representations of components compatible with KFP DSL, and writing them to files for usage in Kubeflow Pipelines.
- parse_components_to_file(components: List[ComponentProtocol], filename: str) None[source]
Parses a list of components adhering to the ComponentProtocol into a py file and writes the result to the specified file. This process involves generating a KFP string functions representation of the components and saving it to the target file.
- Parameters:
components – List of components conforming to the ComponentProtocol protocol, which defines the structure and behavior required for each component to be processed by this method.
filename – Name of the file where the generated KFP representation of components will be saved.
- Returns:
This method does not return anything as its purpose is to perform file writing as a side effect.
- class ml_orchestrator.MetaComponent[source]
Represents a concrete MetaComponent that provides default environment parameters and a method for retrieving the component’s function name in lowercase format.
- env
Environment parameters for the component.
- Type:
EnvironmentParams
- property env: EnvironmentParams
Returns the environment parameters for this component.
- Returns:
A default EnvironmentParams instance.
- Return type:
EnvironmentParams
- classmethod kfp_func_name() str[source]
Retrieves the name of the Kubeflow Pipeline function for this component.
- Returns:
The lowercase class name of the component.
- Return type:
str