flytekit.extend.ExecutableTemplateShimTask¶
- class flytekit.extend.ExecutableTemplateShimTask(tt, executor_type, *args, **kwargs)[source]¶
The canonical
@task
decorated Python function task is pretty simple to reason about. At execution time (either locally or on a Flyte cluster), the function runs.This class, along with the
ShimTaskExecutor
class below, represents another execution pattern. This pattern, has two components:The
TaskTemplate
, or something like it like aFlyteTask
.An executor, which can use information from the task template (including the
custom
field)
Basically at execution time (both locally and on a Flyte cluster), the task template is given to the executor, which is responsible for computing and returning the results.
Note
The interface at execution time will have to derived from the Flyte IDL interface, which means it may be lossy. This is because when a task is serialized from Python into the
TaskTemplate
some information is lost because Flyte IDL can’t keep track of every single Python type (or Java type if writing in the Java flytekit).This class also implements the
dispatch_execute
andexecute
functions to make it look like aPythonTask
that theentrypoint.py
can execute, even though this class doesn’t inherit fromPythonTask
.Methods
- Parameters:
tt (_task_model.TaskTemplate)
executor_type (Type[ShimTaskExecutor])
- dispatch_execute(ctx, input_literal_map)[source]¶
This function is largely similar to the base PythonTask, with the exception that we have to infer the Python interface before executing. Also, we refer to
self.task_template
rather than justself
similar to task classes that derive from the basePythonTask
.- Parameters:
ctx (FlyteContext)
input_literal_map (LiteralMap)
- Return type:
LiteralMap | DynamicJobSpec
- post_execute(_, rval)[source]¶
This function is a stub, just here to keep dispatch_execute compatibility between this class and PythonTask.
- Parameters:
_ (ExecutionParameters | None)
rval (Any)
- Return type:
- pre_execute(user_params)[source]¶
This function is a stub, just here to keep dispatch_execute compatibility between this class and PythonTask.
- Parameters:
user_params (ExecutionParameters | None)
- Return type:
ExecutionParameters | None
Attributes
- executor
- executor_type
- name
Return the name of the underlying task.
- task_template