| Class |
Description |
SQLite3Config |
Use this configuration to configure if sqlite3 files that should be loaded by the task. |
SQLite3Task |
Run client side SQLite3 queries that optionally return a FlyteSchema object. |
SQLite3TaskExecutor |
|
| Method |
Description |
unarchive_file() |
Unarchive given archive and returns the unarchived file name. |
def unarchive_file(
local_path: str,
to_dir: str,
)
Unarchive given archive and returns the unarchived file name. It is expected that only one file is unarchived.
More than one file or 0 files will result in a RuntimeError
| Parameter |
Type |
Description |
local_path |
str |
|
to_dir |
str |
|
Use this configuration to configure if sqlite3 files that should be loaded by the task. The file itself is
considered as a database and hence is treated like a configuration
The path to a static sqlite3 compatible database file can be
- within the container
- or from a publicly downloadable source
class SQLite3Config(
uri: str,
compressed: bool,
)
| Parameter |
Type |
Description |
uri |
str |
default FlyteFile that will be downloaded on execute |
compressed |
bool |
Boolean that indicates if the given file is a compressed archive. Supported file types are [zip, tar, gztar, bztar, xztar] |
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.
<!–
.. literalinclude:: ../../../tests/flytekit/unit/extras/sqlite3/test_task.py
:start-after: # sqlite3_start
:end-before: # sqlite3_end
:language: python
:dedent: 4
–>
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 :ref:integrations guide <cookbook:integrations_sql_sqlite3> for additional usage examples and
the base class {{< py_class_ref flytekit.extend.PythonCustomizedContainerTask >}} as well.
class SQLite3Task(
name: str,
query_template: str,
inputs: typing.Optional[typing.Dict[str, typing.Type]],
task_config: typing.Optional[flytekit.extras.sqlite3.task.SQLite3Config],
output_schema_type: typing.Optional[typing.Type[ForwardRef('FlyteSchema')]],
container_image: typing.Optional[str],
kwargs,
)
| Parameter |
Type |
Description |
name |
str |
unique name for the task, usually the function’s module and name. |
query_template |
str |
|
inputs |
typing.Optional[typing.Dict[str, typing.Type]] |
|
task_config |
typing.Optional[flytekit.extras.sqlite3.task.SQLite3Config] |
Configuration object for Task. Should be a unique type for that specific Task |
output_schema_type |
typing.Optional[typing.Type[ForwardRef('FlyteSchema')]] |
|
container_image |
typing.Optional[str] |
This is the external container image the task should run at platform-run-time. |
kwargs |
**kwargs |
|
| Property |
Type |
Description |
container_image |
None |
|
deck_fields |
None |
If not empty, this task will output deck html file for the specified decks |
disable_deck |
None |
If true, this task will not output deck html file |
docs |
None |
|
enable_deck |
None |
If true, this task will output deck html file |
environment |
None |
Any environment variables that supplied during the execution of the task. |
executor |
None |
|
executor_type |
None |
|
instantiated_in |
None |
|
interface |
None |
|
lhs |
None |
|
location |
None |
|
metadata |
None |
|
name |
None |
Return the name of the underlying task. |
output_columns |
None |
|
python_interface |
None |
Returns this task’s python interface. |
query_template |
None |
|
resources |
None |
|
security_context |
None |
|
task_config |
None |
Returns the user-specified task config which is used for plugin-specific handling of the task. |
task_resolver |
None |
|
task_template |
None |
Override the base class implementation to serialize on first call. |
task_type |
None |
|
task_type_version |
None |
|
| Method |
Description |
compile() |
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() |
This function is largely similar to the base PythonTask, with the exception that we have to infer the Python. |
execute() |
Rather than running here, send everything to the executor. |
find_lhs() |
|
get_command() |
|
get_config() |
Returns the task config as a serializable dictionary. |
get_container() |
Returns the container definition (if any) that is used to run the task on hosted Flyte. |
get_custom() |
Return additional plugin-specific custom data (if any) as a serializable dictionary. |
get_extended_resources() |
Returns the extended resources to allocate to the task on hosted Flyte. |
get_image() |
|
get_input_types() |
Returns the names and python types as a dictionary for the inputs of this task. |
get_k8s_pod() |
Returns the kubernetes pod definition (if any) that is used to run the task on hosted Flyte. |
get_query() |
|
get_sql() |
Returns the Sql definition (if any) that is used to run the task on hosted Flyte. |
get_type_for_input_var() |
Returns the python type for an input variable by name. |
get_type_for_output_var() |
Returns the python type for the specified output variable by name. |
interpolate_query() |
This function will fill in the query template with the provided kwargs and return the interpolated query. |
local_execute() |
This function is used only in the local execution path and is responsible for calling dispatch execute. |
local_execution_mode() |
|
post_execute() |
This function is a stub, just here to keep dispatch_execute compatibility between this class and PythonTask. |
pre_execute() |
This function is a stub, just here to keep dispatch_execute compatibility between this class and PythonTask. |
sandbox_execute() |
Call dispatch_execute, in the context of a local sandbox execution. |
serialize_to_model() |
|
def compile(
ctx: flytekit.core.context_manager.FlyteContext,
args,
kwargs,
) -> typing.Union[typing.Tuple[flytekit.core.promise.Promise], flytekit.core.promise.Promise, flytekit.core.promise.VoidPromise, NoneType]
Generates a node that encapsulates this task in a workflow definition.
| Parameter |
Type |
Description |
ctx |
flytekit.core.context_manager.FlyteContext |
|
args |
*args |
|
kwargs |
**kwargs |
|
def construct_node_metadata()
Used when constructing the node that encapsulates this task as part of a broader workflow definition.
def dispatch_execute(
ctx: FlyteContext,
input_literal_map: _literal_models.LiteralMap,
) -> Union[_literal_models.LiteralMap, _dynamic_job.DynamicJobSpec]
This function is largely similar to the base PythonTask, with the exception that we have to infer the Python
interface before executing. Also, we refer to self.task_template rather than just self similar to task
classes that derive from the base PythonTask.
| Parameter |
Type |
Description |
ctx |
FlyteContext |
|
input_literal_map |
_literal_models.LiteralMap |
|
def execute(
kwargs,
) -> Any
Rather than running here, send everything to the executor.
| Parameter |
Type |
Description |
kwargs |
**kwargs |
|
def get_command(
settings: SerializationSettings,
) -> List[str]
| Parameter |
Type |
Description |
settings |
SerializationSettings |
|
def get_config(
settings: SerializationSettings,
) -> Dict[str, str]
Returns the task config as a serializable dictionary. This task config consists of metadata about the custom
defined for this task.
| Parameter |
Type |
Description |
settings |
SerializationSettings |
|
def get_container(
settings: SerializationSettings,
) -> _task_model.Container
Returns the container definition (if any) that is used to run the task on hosted Flyte.
| Parameter |
Type |
Description |
settings |
SerializationSettings |
|
def get_custom(
settings: flytekit.configuration.SerializationSettings,
) -> typing.Dict[str, typing.Any]
Return additional plugin-specific custom data (if any) as a serializable dictionary.
| Parameter |
Type |
Description |
settings |
flytekit.configuration.SerializationSettings |
|
def get_extended_resources(
settings: flytekit.configuration.SerializationSettings,
) -> typing.Optional[flyteidl.core.tasks_pb2.ExtendedResources]
Returns the extended resources to allocate to the task on hosted Flyte.
| Parameter |
Type |
Description |
settings |
flytekit.configuration.SerializationSettings |
|
def get_image(
settings: SerializationSettings,
) -> str
| Parameter |
Type |
Description |
settings |
SerializationSettings |
|
Returns the names and python types as a dictionary for the inputs of this task.
def get_k8s_pod(
settings: flytekit.configuration.SerializationSettings,
) -> typing.Optional[flytekit.models.task.K8sPod]
Returns the kubernetes pod definition (if any) that is used to run the task on hosted Flyte.
| Parameter |
Type |
Description |
settings |
flytekit.configuration.SerializationSettings |
|
def get_query(
kwargs,
) -> str
| Parameter |
Type |
Description |
kwargs |
**kwargs |
|
def get_sql(
settings: flytekit.configuration.SerializationSettings,
) -> typing.Optional[flytekit.models.task.Sql]
Returns the Sql definition (if any) that is used to run the task on hosted Flyte.
| Parameter |
Type |
Description |
settings |
flytekit.configuration.SerializationSettings |
|
def get_type_for_input_var(
k: str,
v: typing.Any,
) -> typing.Type[typing.Any]
Returns the python type for an input variable by name.
| Parameter |
Type |
Description |
k |
str |
|
v |
typing.Any |
|
def get_type_for_output_var(
k: str,
v: typing.Any,
) -> typing.Type[typing.Any]
Returns the python type for the specified output variable by name.
| Parameter |
Type |
Description |
k |
str |
|
v |
typing.Any |
|
def interpolate_query(
query_template,
kwargs,
) -> typing.Any
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.
| Parameter |
Type |
Description |
query_template |
|
|
kwargs |
**kwargs |
|
def local_execute(
ctx: flytekit.core.context_manager.FlyteContext,
kwargs,
) -> typing.Union[typing.Tuple[flytekit.core.promise.Promise], flytekit.core.promise.Promise, flytekit.core.promise.VoidPromise, typing.Coroutine, NoneType]
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).
| Parameter |
Type |
Description |
ctx |
flytekit.core.context_manager.FlyteContext |
|
kwargs |
**kwargs |
|
def local_execution_mode()
def post_execute(
_: Optional[ExecutionParameters],
rval: Any,
) -> Any
This function is a stub, just here to keep dispatch_execute compatibility between this class and PythonTask.
| Parameter |
Type |
Description |
_ |
Optional[ExecutionParameters] |
|
rval |
Any |
|
def pre_execute(
user_params: Optional[ExecutionParameters],
) -> Optional[ExecutionParameters]
This function is a stub, just here to keep dispatch_execute compatibility between this class and PythonTask.
| Parameter |
Type |
Description |
user_params |
Optional[ExecutionParameters] |
|
def sandbox_execute(
ctx: flytekit.core.context_manager.FlyteContext,
input_literal_map: flytekit.models.literals.LiteralMap,
) -> flytekit.models.literals.LiteralMap
Call dispatch_execute, in the context of a local sandbox execution. Not invoked during runtime.
| Parameter |
Type |
Description |
ctx |
flytekit.core.context_manager.FlyteContext |
|
input_literal_map |
flytekit.models.literals.LiteralMap |
|
def serialize_to_model(
settings: SerializationSettings,
) -> _task_model.TaskTemplate
| Parameter |
Type |
Description |
settings |
SerializationSettings |
|
class SQLite3TaskExecutor(
args,
kwargs,
)
| Parameter |
Type |
Description |
args |
*args |
|
kwargs |
**kwargs |
|
| Property |
Type |
Description |
instantiated_in |
None |
|
lhs |
None |
|
location |
None |
|
| Method |
Description |
execute_from_model() |
This function must be overridden and is where all the business logic for running a task should live. |
find_lhs() |
|
def execute_from_model(
tt: flytekit.models.task.TaskTemplate,
kwargs,
) -> typing.Any
This function must be overridden and is where all the business logic for running a task should live. Keep in
mind that you’re only working with the TaskTemplate. You won’t have access to any information in the task
that wasn’t serialized into the template.
| Parameter |
Type |
Description |
tt |
flytekit.models.task.TaskTemplate |
This is the template, the serialized form of the task. |
kwargs |
**kwargs |
These are the Python native input values to the task. :return: Python native output values from the task. |