Orchestration¶
tfx.v1.orchestration
¶
TFX orchestration module.
MODULE | DESCRIPTION |
---|---|
experimental |
TFX orchestration.experimental module. |
metadata |
Public API for metadata. |
CLASS | DESCRIPTION |
---|---|
LocalDagRunner |
Local TFX DAG runner. |
Classes¶
LocalDagRunner
¶
Bases: IrBasedRunner
Local TFX DAG runner.
Initializes LocalDagRunner as a TFX orchestrator.
METHOD | DESCRIPTION |
---|---|
run |
See TfxRunner. |
run_with_ir |
Runs given pipeline locally. |
Source code in tfx/orchestration/local/local_dag_runner.py
Functions¶
run
¶
See TfxRunner.
Source code in tfx/orchestration/portable/tfx_runner.py
run_with_ir
¶
run_with_ir(pipeline: Pipeline, run_options: Optional[RunOptions] = None) -> None
Runs given pipeline locally.
PARAMETER | DESCRIPTION |
---|---|
pipeline
|
Pipeline IR containing pipeline args and components.
TYPE:
|
run_options
|
Optional args for the run.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If run_options is provided, and partial_run_options.from_nodes and partial_run_options.to_nodes are both empty. |
Source code in tfx/orchestration/local/local_dag_runner.py
Modules¶
experimental
¶
TFX orchestration.experimental module.
CLASS | DESCRIPTION |
---|---|
FinalStatusStr |
FinalStatusStr: is the type for parameter receiving PipelineTaskFinalStatus. |
KubeflowV2DagRunner |
Kubeflow V2 pipeline runner (currently for managed pipelines). |
KubeflowV2DagRunnerConfig |
Runtime configuration specific to execution on Kubeflow V2 pipelines. |
FUNCTION | DESCRIPTION |
---|---|
exit_handler |
Creates an exit handler from a typehint-annotated Python function. |
Classes¶
FinalStatusStr
¶
Bases: str
FinalStatusStr: is the type for parameter receiving PipelineTaskFinalStatus.
Vertex AI backend passes in jsonlized string of
kfp.pipeline_spec.pipeline_spec_pb2.PipelineTaskFinalStatus
.
KubeflowV2DagRunner
¶
KubeflowV2DagRunner(config: KubeflowV2DagRunnerConfig, output_dir: Optional[str] = None, output_filename: Optional[str] = None)
Bases: TfxRunner
Kubeflow V2 pipeline runner (currently for managed pipelines).
Builds a pipeline job spec in json format based on TFX pipeline DSL object.
Constructs an KubeflowV2DagRunner for compiling pipelines.
PARAMETER | DESCRIPTION |
---|---|
config
|
An KubeflowV2DagRunnerConfig object to specify runtime configuration when running the pipeline in Kubeflow. |
output_dir
|
An optional output directory into which to output the pipeline definition files. Defaults to the current working directory. |
output_filename
|
An optional output file name for the pipeline definition file. The file output format will be a JSON-serialized or YAML-serialized PipelineJob pb message. Defaults to 'pipeline.json'. |
METHOD | DESCRIPTION |
---|---|
run |
Compiles a pipeline DSL object into pipeline file. |
set_exit_handler |
Set exit handler components for the Kubeflow V2(Vertex AI) dag runner. |
ATTRIBUTE | DESCRIPTION |
---|---|
config |
TYPE:
|
Source code in tfx/orchestration/kubeflow/v2/kubeflow_v2_dag_runner.py
run
¶run(pipeline: Pipeline, parameter_values: Optional[Dict[str, Any]] = None, write_out: Optional[bool] = True) -> Dict[str, Any]
Compiles a pipeline DSL object into pipeline file.
PARAMETER | DESCRIPTION |
---|---|
pipeline
|
TFX pipeline object.
TYPE:
|
parameter_values
|
mapping from runtime parameter names to its values. |
write_out
|
set to True to actually write out the file to the place designated by output_dir and output_filename. Otherwise return the JSON-serialized pipeline job spec. |
RETURNS | DESCRIPTION |
---|---|
Dict[str, Any]
|
Returns the JSON/YAML pipeline job spec. |
RAISES | DESCRIPTION |
---|---|
RuntimeError
|
if trying to write out to a place occupied by an existing |
Source code in tfx/orchestration/kubeflow/v2/kubeflow_v2_dag_runner.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
|
set_exit_handler
¶set_exit_handler(exit_handler: BaseNode)
Set exit handler components for the Kubeflow V2(Vertex AI) dag runner.
This feature is currently experimental without backward compatibility gaurantee.
PARAMETER | DESCRIPTION |
---|---|
exit_handler
|
exit handler component.
TYPE:
|
Source code in tfx/orchestration/kubeflow/v2/kubeflow_v2_dag_runner.py
KubeflowV2DagRunnerConfig
¶
KubeflowV2DagRunnerConfig(display_name: Optional[str] = None, default_image: Optional[Union[str, MutableMapping[str, str]]] = None, default_commands: Optional[List[str]] = None, use_pipeline_spec_2_1: bool = False, **kwargs)
Bases: PipelineConfig
Runtime configuration specific to execution on Kubeflow V2 pipelines.
Constructs a Kubeflow V2 runner config.
PARAMETER | DESCRIPTION |
---|---|
display_name
|
Optional human-readable pipeline name. Defaults to the
pipeline name passed into |
default_image
|
The default TFX image to be used if not overriden by per component specification. It can be a map whose key is a component id and value is an image path to set the image by a component level.
TYPE:
|
default_commands
|
Optionally specifies the commands of the provided
container image. When not provided, the default |
use_pipeline_spec_2_1
|
Use the KFP pipeline spec schema 2.1 to support Vertex ML pipeline teamplate gallary.
TYPE:
|
**kwargs
|
Additional args passed to base PipelineConfig.
DEFAULT:
|
ATTRIBUTE | DESCRIPTION |
---|---|
component_config_overrides |
|
default_commands |
|
default_component_configs |
|
default_image |
|
display_name |
|
supported_launcher_classes |
|
use_pipeline_spec_2_1 |
|
Source code in tfx/orchestration/kubeflow/v2/kubeflow_v2_dag_runner.py
component_config_overrides
instance-attribute
¶component_config_overrides = component_config_overrides or {}
default_component_configs
instance-attribute
¶default_component_configs = default_component_configs or []
supported_launcher_classes
instance-attribute
¶supported_launcher_classes = supported_launcher_classes or [InProcessComponentLauncher]
Functions¶
exit_handler
¶
exit_handler(func: FunctionType) -> Callable[..., Any]
Creates an exit handler from a typehint-annotated Python function.
This decorator creates an exit handler wrapping the component typehint annotation - typehint annotations specified for the arguments and return value for a Python function. Exit handler is to annotate the component for post actions of a pipeline, only supported in Vertex AI. Specifically, function arguments can be annotated with the following types and associated semantics supported in component. In order to get in the final status of dependent pipeline, parameter should be defined as Parameter[str], passing in FinalStatusStr type when initializing the component.
Example
This is example usage of component definition using this decorator:
from tfx import v1 as tfx
@tfx.orchestration.experimental.exit_handler
def MyExitHandlerComponent(final_status: tfx.dsl.components.Parameter[str]):
# parse the final status
pipeline_task_status = pipeline_pb2.PipelineTaskFinalStatus()
proto_utils.json_to_proto(final_status, pipeline_task_status)
print(pipeline_task_status)
Example
Example usage in a Vertex AI graph definition:
Experimental: no backwards compatibility guarantees.
PARAMETER | DESCRIPTION |
---|---|
func
|
Typehint-annotated component executor function.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Callable[..., Any]
|
|
Callable[..., Any]
|
function. |
Source code in tfx/orchestration/kubeflow/decorators.py
metadata
¶
Public API for metadata.
FUNCTION | DESCRIPTION |
---|---|
mysql_metadata_connection_config |
Convenience function to create mysql-based metadata connection config. |
sqlite_metadata_connection_config |
Convenience function to create file based metadata connection config. |
ATTRIBUTE | DESCRIPTION |
---|---|
ConnectionConfigType |
|
Attributes¶
ConnectionConfigType
module-attribute
¶
ConnectionConfigType = Union[ConnectionConfig, MetadataStoreClientConfig]
Functions¶
mysql_metadata_connection_config
¶
mysql_metadata_connection_config(host: str, port: int, database: str, username: str, password: str) -> ConnectionConfig
Convenience function to create mysql-based metadata connection config.
PARAMETER | DESCRIPTION |
---|---|
host
|
The name or network address of the instance of MySQL to connect to.
TYPE:
|
port
|
The port MySQL is using to listen for connections.
TYPE:
|
database
|
The name of the database to use.
TYPE:
|
username
|
The MySQL login account being used.
TYPE:
|
password
|
The password for the MySQL account being used.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ConnectionConfig
|
A metadata_store_pb2.ConnectionConfig based on given metadata db uri. |
Source code in tfx/orchestration/metadata.py
sqlite_metadata_connection_config
¶
sqlite_metadata_connection_config(metadata_db_uri: str) -> ConnectionConfig
Convenience function to create file based metadata connection config.
PARAMETER | DESCRIPTION |
---|---|
metadata_db_uri
|
uri to metadata db.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ConnectionConfig
|
A metadata_store_pb2.ConnectionConfig based on given metadata db uri. |