Join the SIG TFX-Addons community and help make TFX even better!

tfx.dsl.component.experimental.executor_specs.TemplatedExecutorContainerSpec

Experimental: Describes a command-line program inside a container.

Inherits From: ExecutorSpec

This class is similar to ExecutorContainerSpec, but uses structured placeholders instead of jinja templates for constructing container commands based on input and output artifact metadata. See placeholders.py for a list of supported placeholders. The spec includes the container image name and the command line (entrypoint plus arguments) for a program inside the container.

Example:

class MyTrainer(base_component.BaseComponent) class MyTrainerSpec(types.ComponentSpec): INPUTS = { 'training_data': component_spec.ChannelParameter(type=standard_artifacts.Dataset), } OUTPUTS = { 'model': component_spec.ChannelParameter(type=standard_artifacts.Model), } PARAMETERS = { 'num_training_steps': component_spec.ExecutionParameter(type=int), }

SPEC_CLASS = MyTrainerSpec EXECUTOR_SPEC = executor_specs.TemplatedExecutorContainerSpec( image='gcr.io/my-project/my-trainer', command=[ 'python3', 'my_trainer', '--training_data_uri', InputUriPlaceholder('training_data'), '--model_uri', OutputUriPlaceholder('model'), '--num_training-steps', InputValuePlaceholder('num_training_steps'), ] )

image Container image name.
command Container entrypoint command-line. Not executed within a shell. The command-line can use placeholder objects that will be replaced at the compilation time. Note: Jinja templates are not supported.

Methods

copy

View source

Makes a copy of the ExecutorSpec.

An abstract method to implement to make a copy of the ExecutorSpec instance. Deepcopy is preferred in the implementation. But if for any reason a deepcopy is not able to be made because of some fields are not deepcopyable, it is OK to make a shallow copy as long as the subfield is consider globally immutable.

Returns
A copy of ExecutorSpec.

encode

View source

Encodes ExecutorSpec into an IR proto for compiling.

This method will be used by DSL compiler to generate the corresponding IR.

Args
component_spec Optional. The ComponentSpec to help with the encoding.

Returns
An executor spec proto.

from_json_dict

View source

Convert from dictionary data to an object.

to_json_dict

View source

Convert from an object to a JSON serializable dictionary.

__eq__

View source

Return self==value.

__ne__

View source

Return self!=value.