flytekit.PythonInstanceTask

class flytekit.PythonInstanceTask(*args, **kwargs)[source]

This class should be used as the base class for all Tasks that do not have a user defined function body, but have a platform defined execute method. (Execute needs to be overriden). This base class ensures that the module loader will invoke the right class automatically, by capturing the module name and variable in the module name.

__init__(name: str, task_config: T, task_type: str = 'python-task', task_resolver: Optional[flytekit.core.python_auto_container.TaskResolverMixin] = None, **kwargs)[source]
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

  • task_type – String task type to be associated with this Task

  • container_image – String FQN for the image.

  • requests – custom resource request settings.

  • limits – custom resource limit settings.

  • environment – Environment variables you want the task to have when run.

  • task_resolver – Custom resolver - will pick up the default resolver if empty, or the resolver set in the compilation context if one is set.

  • 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

    • Vault <https://www.vaultproject.io/>,

    • Confidant <https://lyft.github.io/confidant/>,

    • Kube secrets <https://kubernetes.io/docs/concepts/configuration/secret/>

    • AWS Parameter store

    etc

Methods

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

param name

unique name for the task, usually the function’s module and name.

compile(ctx, *args, **kwargs)

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)

find_lhs()

get_command(settings)

get_config(settings)

get_container(settings)

get_custom(settings)

get_input_types()

Returns python native types for inputs.

get_type_for_input_var(k, v)

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)

Returns the python native type for the given output variable # TODO we could use literal type to determine this

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.

Attributes

container_image

environment

instantiated_in

interface

lhs

location

metadata

name

python_interface

resources

security_context

task_config

task_resolver

task_type

task_type_version