flytekit.extend.PythonCustomizedContainerTask#
- class flytekit.extend.PythonCustomizedContainerTask(*args, **kwargs)[source]#
Please take a look at the comments for :py:class`flytekit.extend.ExecutableTemplateShimTask` as well. This class should be subclassed and a custom Executor provided as a default to this parent class constructor when building a new external-container flytekit-only plugin.
This class provides authors of new task types the basic scaffolding to create task-template based tasks. In order to write such a task, authors need to
subclass the
ShimTaskExecutor
class and override theexecute_from_model
function. This function is where all the business logic should go. Keep in mind though that you, the plugin author, will not have access to anything that’s not serialized within theTaskTemplate
which is why you’ll also need tosubclass this class, and override the
get_custom
function to include all the information the executor will need to run.Also pass the executor you created as the
executor_type
argument of this class’s constructor.
Keep in mind that the total size of the
TaskTemplate
still needs to be small, since these will be accessed frequently by the Flyte engine.- Parameters
name – unique name for the task, usually the function’s module and name.
task_config – Configuration object for Task. Should be a unique type for that specific Task
container_image – This is the external container image the task should run at platform-run-time.
executor – This is an executor which will actually provide the business logic.
task_resolver – Custom resolver - if you don’t make one, use the default task template resolver.
task_type – String task type to be associated with this Task.
requests – custom resource request settings.
limits – custom resource limit settings.
environment – Environment variables you want the task to have when run.
secret_requests (List[Secret]) –
Secrets that are requested by this container execution. These secrets will be mounted based on the configuration in the Secret and available through the SecretManager using the name of the secret as the group Ideally the secret keys should also be semi-descriptive. The key values will be available from runtime, if the backend is configured to provide secrets and if secrets are available in the configured secrets store. Possible options for secret stores are
- __init__(name, task_config, container_image, executor_type, task_resolver=None, task_type='python-task', requests=None, limits=None, environment=None, secret_requests=None, **kwargs)[source]#
- Parameters
name (str) – unique name for the task, usually the function’s module and name.
task_config (flytekit.core.python_customized_container_task.TC) – Configuration object for Task. Should be a unique type for that specific Task
container_image (str) – This is the external container image the task should run at platform-run-time.
executor – This is an executor which will actually provide the business logic.
task_resolver (Optional[flytekit.core.python_customized_container_task.TaskTemplateResolver]) – Custom resolver - if you don’t make one, use the default task template resolver.
task_type – String task type to be associated with this Task.
requests (Optional[flytekit.core.resources.Resources]) – custom resource request settings.
limits (Optional[flytekit.core.resources.Resources]) – custom resource limit settings.
environment (Optional[Dict[str, str]]) – Environment variables you want the task to have when run.
secret_requests (List[Secret]) –
Secrets that are requested by this container execution. These secrets will be mounted based on the configuration in the Secret and available through the SecretManager using the name of the secret as the group Ideally the secret keys should also be semi-descriptive. The key values will be available from runtime, if the backend is configured to provide secrets and if secrets are available in the configured secrets store. Possible options for secret stores are
executor_type (Type[flytekit.core.shim_task.ShimTaskExecutor]) –
Methods
__init__
(name, task_config, container_image, ...)- param name
unique name for the task, usually the function's module and name.
compile
(ctx, *args, **kwargs)Generates a node that encapsulates this task in a workflow definition.
construct_node_metadata
()Used when constructing the node that encapsulates this task as part of a broader workflow definition.
dispatch_execute
(ctx, input_literal_map)This function is largely similar to the base PythonTask, with the exception that we have to infer the Python interface before executing.
execute
(**kwargs)Rather than running here, send everything to the executor.
find_lhs
()get_command
(settings)get_config
(settings)Returns the task config as a serializable dictionary.
get_container
(settings)Returns the container definition (if any) that is used to run the task on hosted Flyte.
get_custom
(settings)Return additional plugin-specific custom data (if any) as a serializable dictionary.
get_input_types
()Returns the names and python types as a dictionary for the inputs of this task.
get_k8s_pod
(settings)Returns the kubernetes pod definition (if any) that is used to run the task on hosted Flyte.
get_sql
(settings)Returns the Sql definition (if any) that is used to run the task on hosted Flyte.
get_type_for_input_var
(k, v)Returns the python type for an input variable by name.
get_type_for_output_var
(k, v)Returns the python type for the specified output variable by name.
local_execute
(ctx, **kwargs)This function is used only in the local execution path and is responsible for calling dispatch execute.
post_execute
(_, rval)This function is a stub, just here to keep dispatch_execute compatibility between this class and PythonTask.
pre_execute
(user_params)This function is a stub, just here to keep dispatch_execute compatibility between this class and PythonTask.
sandbox_execute
(ctx, input_literal_map)Call dispatch_execute, in the context of a local sandbox execution.
serialize_to_model
(settings)Attributes
SERIALIZE_SETTINGS
container_image
disable_deck
If true, this task will not output deck html file
docs
environment
Any environment variables that supplied during the execution of the task.
executor
executor_type
instantiated_in
interface
lhs
location
metadata
name
Return the name of the underlying task.
python_interface
Returns this task's python interface.
resources
security_context
task_config
Returns the user-specified task config which is used for plugin-specific handling of the task.
task_resolver
task_template
Override the base class implementation to serialize on first call.
task_type
task_type_version