flytekit.extras.tasks.shell.ShellTask#

class flytekit.extras.tasks.shell.ShellTask(*args, **kwargs)[source]#

Methods

compile(ctx, *args, **kwargs)[source]#

Generates a node that encapsulates this task in a workflow definition.

Parameters:

ctx (FlyteContext)

Return type:

Tuple[Promise] | Promise | VoidPromise | None

construct_node_metadata()[source]#

Used when constructing the node that encapsulates this task as part of a broader workflow definition.

Return type:

NodeMetadata

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.

  • VoidPromise is returned in the case when the task itself declares no outputs.

  • Literal Map is returned when the task returns either one more outputs in the declaration. Individual outputs may be none

  • DynamicJobSpec is returned when a dynamic workflow is executed

Parameters:
Return type:

LiteralMap | DynamicJobSpec | Coroutine

execute(**kwargs)[source]#

Executes the given script by substituting the inputs and outputs and extracts the outputs from the filesystem

Return type:

Any

find_lhs()[source]#
Return type:

str

get_command(settings)[source]#

Returns the command which should be used in the container definition for the serialized version of this task registered on a hosted Flyte platform.

Parameters:

settings (SerializationSettings)

Return type:

List[str]

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:

Dict[str, str] | None

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

get_custom(settings)[source]#

Return additional plugin-specific custom data (if any) as a serializable dictionary.

Parameters:

settings (SerializationSettings)

Return type:

Dict[str, Any] | None

get_default_command(settings)[source]#

Returns the default pyflyte-execute command used to run this on hosted Flyte platforms.

Parameters:

settings (SerializationSettings)

Return type:

List[str]

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_image(settings)[source]#

Update image spec based on fast registration usage, and return string representing the image

Parameters:

settings (SerializationSettings)

Return type:

str

get_input_types()[source]#

Returns the names and python types as a dictionary for the inputs of this task.

Return type:

Dict[str, type]

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

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 type for an input variable by name.

Parameters:
Return type:

Type[Any]

get_type_for_output_var(k, v)[source]#

Returns the python type for the specified output variable by name.

Parameters:
Return type:

Type[Any]

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:

Tuple[Promise] | Promise | VoidPromise | Coroutine | None

local_execution_mode()[source]#
Return type:

Mode

post_execute(user_params, rval)[source]#

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. If not overridden, then this function is a No-op

Parameters:
  • execute (rval is returned value from call to)

  • user_params (ExecutionParameters) – are the modified user params as created during the pre_execute step

  • rval (Any)

Return type:

Any

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:

ExecutionParameters

reset_command_fn()[source]#

Resets the command which should be used in the container definition of this task to the default arguments. This is useful when the command line is overridden at serialization time.

sandbox_execute(ctx, input_literal_map)[source]#

Call dispatch_execute, in the context of a local sandbox execution. Not invoked during runtime.

Parameters:
Return type:

LiteralMap

set_command_fn(get_command_fn=None)[source]#

By default, the task will run on the Flyte platform using the pyflyte-execute command. However, it can be useful to update the command with which the task is serialized for specific cases like running map tasks (“pyflyte-map-execute”) or for fast-executed tasks.

Parameters:

get_command_fn (Callable[[SerializationSettings], List[str]] | None)

set_resolver(resolver)[source]#

By default, flytekit uses the DefaultTaskResolver to resolve the task. This method allows the user to set a custom task resolver. It can be useful to override the task resolver for specific cases like running tasks in the jupyter notebook.

Parameters:

resolver (TaskResolverMixin)

Attributes

container_image
deck_fields

If not empty, this task will output deck html file for the specified decks

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.

resources
result
script
script_file
security_context
task_config

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

task_resolver
task_type
task_type_version