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.
This is example usage of component definition using this decorator:
fromtfximportv1astfx@tfx.orchestration.experimental.exit_handlerdefMyExitHandlerComponent(final_status:tfx.dsl.components.Parameter[str]):# parse the final statuspipeline_task_status=pipeline_pb2.PipelineTaskFinalStatus()proto_utils.json_to_proto(final_status,pipeline_task_status)print(pipeline_task_status)
[null,null,["Last updated 2024-05-03 UTC."],[],[],null,["# tfx.v1.orchestration.experimental.exit_handler\n\n\u003cbr /\u003e\n\nCreates an exit handler from a typehint-annotated Python function. \n\n tfx.v1.orchestration.experimental.exit_handler(\n func: types.FunctionType\n ) -\u003e Callable[..., Any]\n\nThis decorator creates an exit handler wrapping the component typehint\nannotation - typehint annotations specified for the arguments and return value\nfor a Python function.\nExit handler is to annotate the component for post actions of a pipeline,\nonly supported in Vertex AI. Specifically, function\narguments can be annotated with the following types and associated semantics\nsupported in component. In order to get in the final status of dependent\npipeline, parameter should be defined as Parameter\\[str\\], passing in\nFinalStatusStr type when initializing the component.\n\nThis is example usage of component definition using this decorator: \n\n from tfx import v1 as tfx\n\n @tfx.orchestration.experimental.exit_handler\n def MyExitHandlerComponent(final_status: tfx.dsl.components.Parameter[str]):\n # parse the final status\n pipeline_task_status = pipeline_pb2.PipelineTaskFinalStatus()\n proto_utils.json_to_proto(final_status, pipeline_task_status)\n print(pipeline_task_status)\n\nExample usage in a Vertex AI graph definition: \n\n exit_handler = exit_handler_component(\n final_status=tfx.dsl.experimental.FinalStatusStr())\n\n dsl_pipeline = tfx.dsl.Pipeline(...)\n\n runner = tfx.orchestration.experimental.KubeflowV2DagRunner(...)\n runner.set_exit_handler([exit_handler])\n runner.run(pipeline=dsl_pipeline)\n\n| **Experimental:** no backwards compatibility guarantees.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------|-------------------------------------------------|\n| `func` | Typehint-annotated component executor function. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| `base_component.BaseComponent` subclass for the given component executor function. ||\n\n\u003cbr /\u003e"]]