flytekit.SQLTask#
- class flytekit.SQLTask(*args, **kwargs)[source]#
Base task types for all SQL tasks. See
flytekit.extras.sqlite3.task.SQLite3Task
andflytekitplugins.athena.task.AthenaTask
for examples of how to use it as a base class.- class SQLite3Task(*args, **kwargs)
Run client side SQLite3 queries that optionally return a FlyteSchema object.
Note
This is a pre-built container task. That is, your user container will not be used at task execution time. Instead the image defined in this task definition will be used instead.
sql_task = SQLite3Task( "test", query_template="select TrackId, Name from tracks limit {{.inputs.limit}}", inputs=kwtypes(limit=int), output_schema_type=FlyteSchema[kwtypes(TrackId=int, Name=str)], task_config=SQLite3Config( uri=EXAMPLE_DB, compressed=True, ), )
See the integrations guide for additional usage examples and the base class
flytekit.extend.PythonCustomizedContainerTask
as well.
Methods
- compile(ctx, *args, **kwargs)[source]#
Generates a node that encapsulates this task in a workflow definition.
- Parameters:
ctx (FlyteContext)
- Return type:
- 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 noneDynamicJobSpec
is returned when a dynamic workflow is executed
- Parameters:
ctx (FlyteContext)
input_literal_map (LiteralMap)
- Return type:
LiteralMap | DynamicJobSpec | Coroutine
- 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:
- 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 | None
- get_custom(settings)[source]#
Return additional plugin-specific custom data (if any) as a serializable dictionary.
- Parameters:
settings (SerializationSettings)
- Return type:
- 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_input_types()[source]#
Returns the names and python types as a dictionary for the inputs of this task.
- 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 | None
- 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_output_var(k, v)[source]#
Returns the python type for the specified output variable by name.
- classmethod interpolate_query(query_template, **kwargs)[source]#
This function will fill in the query template with the provided kwargs and return the interpolated query. Please note that when SQL tasks run in Flyte, this step is done by the task executor.
- Return type:
- 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:
- 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 | None) – are the modified user params as created during the pre_execute step
rval (Any)
- Return type:
- 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 | None)
- Return type:
ExecutionParameters | None
- sandbox_execute(ctx, input_literal_map)[source]#
Call dispatch_execute, in the context of a local sandbox execution. Not invoked during runtime.
- Parameters:
ctx (FlyteContext)
input_literal_map (LiteralMap)
- Return type:
LiteralMap
Attributes
- 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
- enable_deck
If true, this task will output deck html file
- 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.
- query_template
- 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