flytekit.core.base_task.PythonTask#

class flytekit.core.base_task.PythonTask(*args, **kwargs)[source]#

Base Class for all Tasks with a Python native Interface. This should be directly used for task types, that do not have a python function to be executed. Otherwise refer to flytekit.PythonFunctionTask.

__init__(task_type, name, task_config, interface=None, environment=None, disable_deck=None, enable_deck=None, **kwargs)[source]#
Parameters
  • task_type (str) – defines a unique task-type for every new extension. If a backend plugin is required then this has to be done in-concert with the backend plugin identifier

  • name (str) – A unique name for the task instantiation. This is unique for every instance of task.

  • task_config (T) – Configuration for the task. This is used to configure the specific plugin that handles this task

  • interface (Optional[Interface]) – A python native typed interface (inputs) -> outputs that declares the signature of the task

  • environment (Optional[Dict[str, str]]) – Any environment variables that should be supplied during the execution of the task. Supplied as a dictionary of key/value pairs

  • disable_deck (bool) – (deprecated) If true, this task will not output deck html file

  • enable_deck (bool) – If true, this task will output deck html file

Methods

__init__(task_type, name, task_config[, ...])

param task_type

defines a unique task-type for every new extension. If a backend plugin is required then

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 method translates Flyte's Type system based input values and invokes the actual call to the executor This method is also invoked during runtime.

execute(**kwargs)

This method will be invoked to execute the task.

find_lhs()

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_extended_resources(settings)

Returns the extended resources to allocate to the task on hosted Flyte.

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.

local_execution_mode()

post_execute(user_params, rval)

Post execute is called after the execution has completed, with the user_params and can be used to clean-up, or alter the outputs to match the intended tasks outputs.

pre_execute(user_params)

This is the method that will be invoked directly before executing the task method and before all the inputs are converted.

sandbox_execute(ctx, input_literal_map)

Call dispatch_execute, in the context of a local sandbox execution.

Attributes

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.

instantiated_in

interface

lhs

location

metadata

name

python_interface

Returns this task's python interface.

security_context

task_config

Returns the user-specified task config which is used for plugin-specific handling of the task.

task_type

task_type_version