flytekit.core.base_task.Task#
- class flytekit.core.base_task.Task(task_type, name, interface, metadata=None, task_type_version=0, security_ctx=None, docs=None, **kwargs)[source]#
The base of all Tasks in flytekit. This task is closest to the FlyteIDL TaskTemplate and captures information in FlyteIDL specification and does not have python native interfaces associated. Refer to the derived classes for examples of how to extend this class.
Methods
- Parameters:
task_type (str)
name (str)
interface (TypedInterface)
metadata (TaskMetadata | None)
security_ctx (SecurityContext | None)
docs (Documentation | None)
- compile(ctx, *args, **kwargs)[source]#
- Parameters:
ctx (FlyteContext)
- abstract dispatch_execute(ctx, input_literal_map)[source]#
This method translates Flyte’s Type system based input values and invokes the actual call to the executor This method is also invoked during runtime.
- Parameters:
ctx (FlyteContext)
input_literal_map (LiteralMap)
- Return type:
LiteralMap
- get_config(settings)[source]#
Returns the task config as a serializable dictionary. This task config consists of metadata about the custom defined for this task.
- Parameters:
settings (SerializationSettings)
- Return type:
- get_container(settings)[source]#
Returns the container definition (if any) that is used to run the task on hosted Flyte.
- Parameters:
settings (SerializationSettings)
- Return type:
Container | None
- get_custom(settings)[source]#
Return additional plugin-specific custom data (if any) as a serializable dictionary.
- Parameters:
settings (SerializationSettings)
- Return type:
- get_extended_resources(settings)[source]#
Returns the extended resources to allocate to the task on hosted Flyte.
- Parameters:
settings (SerializationSettings)
- Return type:
ExtendedResources | None
- get_input_types()[source]#
Returns python native types for inputs. In case this is not a python native task (base class) and hence returns a None. we could deduce the type from literal types, but that is not a required exercise # TODO we could use literal type to determine this
- get_k8s_pod(settings)[source]#
Returns the kubernetes pod definition (if any) that is used to run the task on hosted Flyte.
- Parameters:
settings (SerializationSettings)
- Return type:
K8sPod | None
- get_sql(settings)[source]#
Returns the Sql definition (if any) that is used to run the task on hosted Flyte.
- Parameters:
settings (SerializationSettings)
- Return type:
Sql | None
- get_type_for_input_var(k, v)[source]#
Returns the python native type for the given input variable # TODO we could use literal type to determine this
- get_type_for_output_var(k, v)[source]#
Returns the python native type for the given output variable # TODO we could use literal type to determine this
- local_execute(ctx, **kwargs)[source]#
This function is used only in the local execution path and is responsible for calling dispatch execute. Use this function when calling a task with native values (or Promises containing Flyte literals derived from Python native values).
- Parameters:
ctx (FlyteContext)
- Return type:
- abstract pre_execute(user_params)[source]#
This is the method that will be invoked directly before executing the task method and before all the inputs are converted. One particular case where this is useful is if the context is to be modified for the user process to get some user space parameters. This also ensures that things like SparkSession are already correctly setup before the type transformers are called
This should return either the same context of the mutated context
- Parameters:
user_params (ExecutionParameters)
- Return type:
- sandbox_execute(ctx, input_literal_map)[source]#
Call dispatch_execute, in the context of a local sandbox execution. Not invoked during runtime.
- Parameters:
ctx (FlyteContext)
input_literal_map (LiteralMap)
- Return type:
LiteralMap
Attributes
- docs
- interface
- metadata
- name
- python_interface
- security_context
- task_type
- task_type_version