ContainerTask
This class represents Flyte Tasks that execute a container at runtime. It serves as the base for most typical @task decorated tasks, as they all involve container execution. Non-container tasks, like an Athena SQL task, would not inherit from this class. It handles image specification, command execution, input/output management, and local log streaming.
Attributes
- MetadataFormat: Literal["JSON", "YAML", "PROTO"] = JSON
- The format of the output file. This can be "JSON", "YAML", or "PROTO".
Constructors
-
This is an intermediate class that represents Flyte Tasks that run a container at execution time. This is the vast majority of tasks - the typical
@taskdecorated tasks; for instance, all run a container. An example of something that doesn't run a container would be something like the Athena SQL task. -
Parameters
- name: string
- Name of the task
- image: Union[str, Image]
- The container image to use for the task. This can be a string or an Image object.
- command: List[str]
- The command to run in the container. This can be a list of strings or a single string.
- inputs: Optional[Dict[str, Type]]
- The inputs to the task. This is a dictionary of input names to types.
- arguments: Optional[List[str]]
- The arguments to pass to the command. This is a list of strings.
- outputs: Optional[Dict[str, Type]]
- The outputs of the task. This is a dictionary of output names to types.
- input_data_dir: str | pathlib.Path
- The directory where the input data is stored. This is a string or a Path object.
- output_data_dir: str | pathlib.Path
- The directory where the output data is stored. This is a string or a Path object.
- metadata_format: MetadataFormat
- The format of the output file. This can be "JSON", "YAML", or "PROTO".
- local_logs: bool
- If True, logs will be printed to the console in the local execution.
- name: string
Methods
def execute(kwargs: **kwargs) - > Any
-
Executes the container task.
-
Parameters
- kwargs: **kwargs
- Keyword arguments representing task inputs.
- kwargs: **kwargs
-
Return Value: Any
- The output of the container task.
def data_loading_config(sctx: [SerializationContext](src_flyte_models_serializationcontext)) - > tasks_pb2.DataLoadingConfig
-
Generates the DataLoadingConfig protobuf message for the task.
-
Parameters
- sctx: SerializationContext
- The serialization context.
- sctx: SerializationContext
-
Return Value: tasks_pb2.DataLoadingConfig
- The DataLoadingConfig protobuf message.
def container_args(sctx: [SerializationContext](src_flyte_models_serializationcontext)) - > List[str]
-
Returns the command and arguments for the container.
-
Parameters
- sctx: SerializationContext
- The serialization context.
- sctx: SerializationContext
-
Return Value: List[str]
- A list of strings representing the command and arguments.