flytekitplugins.sqlalchemy.task
Directory
Classes
| Class | Description |
|---|---|
SQLAlchemyConfig |
Use this configuration to configure task. |
SQLAlchemyDefaultImages |
Default images for the sqlalchemy flytekit plugin. |
SQLAlchemyTask |
Makes it possible to run client side SQLAlchemy queries that optionally return a FlyteSchema object. |
SQLAlchemyTaskExecutor |
Please see the notes for the metaclass above first. |
flytekitplugins.sqlalchemy.task.SQLAlchemyConfig
Use this configuration to configure task. String should be standard sqlalchemy connector format ( https://docs.sqlalchemy.org/en/14/core/engines.html#database-urls). Database can be found:
- within the container
- or from a publicly accessible source
class SQLAlchemyConfig(
uri: str,
connect_args: typing.Optional[typing.Dict[str, typing.Any]],
secret_connect_args: typing.Optional[typing.Dict[str, flytekit.models.security.Secret]],
)| Parameter | Type |
|---|---|
uri |
str |
connect_args |
typing.Optional[typing.Dict[str, typing.Any]] |
secret_connect_args |
typing.Optional[typing.Dict[str, flytekit.models.security.Secret]] |
Methods
| Method | Description |
|---|---|
secret_connect_args_to_dicts() |
secret_connect_args_to_dicts()
def secret_connect_args_to_dicts()flytekitplugins.sqlalchemy.task.SQLAlchemyDefaultImages
Default images for the sqlalchemy flytekit plugin.
Methods
| Method | Description |
|---|---|
default_image() |
|
find_image_for() |
|
get_version_suffix() |
default_image()
def default_image()find_image_for()
def find_image_for(
python_version: typing.Optional[flytekit.configuration.default_images.PythonVersion],
flytekit_version: typing.Optional[str],
) -> str| Parameter | Type |
|---|---|
python_version |
typing.Optional[flytekit.configuration.default_images.PythonVersion] |
flytekit_version |
typing.Optional[str] |
get_version_suffix()
def get_version_suffix()flytekitplugins.sqlalchemy.task.SQLAlchemyTask
Makes it possible to run client side SQLAlchemy queries that optionally return a FlyteSchema object
class SQLAlchemyTask(
name: str,
query_template: str,
task_config: flytekitplugins.sqlalchemy.task.SQLAlchemyConfig,
inputs: typing.Optional[typing.Dict[str, typing.Type]],
output_schema_type: typing.Optional[typing.Type[flytekit.types.schema.types.FlyteSchema]],
container_image: str,
kwargs,
)| Parameter | Type |
|---|---|
name |
str |
query_template |
str |
task_config |
flytekitplugins.sqlalchemy.task.SQLAlchemyConfig |
inputs |
typing.Optional[typing.Dict[str, typing.Type]] |
output_schema_type |
typing.Optional[typing.Type[flytekit.types.schema.types.FlyteSchema]] |
container_image |
str |
kwargs |
**kwargs |
Methods
| 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() |
compile()
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 |
|---|---|
ctx |
flytekit.core.context_manager.FlyteContext |
args |
*args |
kwargs |
**kwargs |
construct_node_metadata()
def construct_node_metadata()Used when constructing the node that encapsulates this task as part of a broader workflow definition.
dispatch_execute()
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 |
|---|---|
ctx |
FlyteContext |
input_literal_map |
_literal_models.LiteralMap |
execute()
def execute(
kwargs,
) -> AnyRather than running here, send everything to the executor.
| Parameter | Type |
|---|---|
kwargs |
**kwargs |
find_lhs()
def find_lhs()get_command()
def get_command(
settings: SerializationSettings,
) -> List[str]| Parameter | Type |
|---|---|
settings |
SerializationSettings |
get_config()
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 |
|---|---|
settings |
SerializationSettings |
get_container()
def get_container(
settings: SerializationSettings,
) -> _task_model.ContainerReturns the container definition (if any) that is used to run the task on hosted Flyte.
| Parameter | Type |
|---|---|
settings |
SerializationSettings |
get_custom()
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 |
|---|---|
settings |
flytekit.configuration.SerializationSettings |
get_extended_resources()
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 |
|---|---|
settings |
flytekit.configuration.SerializationSettings |
get_image()
def get_image(
settings: SerializationSettings,
) -> str| Parameter | Type |
|---|---|
settings |
SerializationSettings |
get_input_types()
def get_input_types()Returns the names and python types as a dictionary for the inputs of this task.
get_k8s_pod()
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 |
|---|---|
settings |
flytekit.configuration.SerializationSettings |
get_query()
def get_query(
kwargs,
) -> str| Parameter | Type |
|---|---|
kwargs |
**kwargs |
get_sql()
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 |
|---|---|
settings |
flytekit.configuration.SerializationSettings |
get_type_for_input_var()
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 |
|---|---|
k |
str |
v |
typing.Any |
get_type_for_output_var()
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 |
|---|---|
k |
str |
v |
typing.Any |
interpolate_query()
def interpolate_query(
query_template,
kwargs,
) -> typing.AnyThis 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 |
|---|---|
query_template |
|
kwargs |
**kwargs |
local_execute()
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 |
|---|---|
ctx |
flytekit.core.context_manager.FlyteContext |
kwargs |
**kwargs |
local_execution_mode()
def local_execution_mode()post_execute()
def post_execute(
_: Optional[ExecutionParameters],
rval: Any,
) -> AnyThis function is a stub, just here to keep dispatch_execute compatibility between this class and PythonTask.
| Parameter | Type |
|---|---|
_ |
Optional[ExecutionParameters] |
rval |
Any |
pre_execute()
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 |
|---|---|
user_params |
Optional[ExecutionParameters] |
sandbox_execute()
def sandbox_execute(
ctx: flytekit.core.context_manager.FlyteContext,
input_literal_map: flytekit.models.literals.LiteralMap,
) -> flytekit.models.literals.LiteralMapCall dispatch_execute, in the context of a local sandbox execution. Not invoked during runtime.
| Parameter | Type |
|---|---|
ctx |
flytekit.core.context_manager.FlyteContext |
input_literal_map |
flytekit.models.literals.LiteralMap |
serialize_to_model()
def serialize_to_model(
settings: SerializationSettings,
) -> _task_model.TaskTemplate| Parameter | Type |
|---|---|
settings |
SerializationSettings |
Properties
| Property | Type | Description |
|---|---|---|
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 |
||
enable_deck |
If true, this task will output deck html file |
|
environment |
Any environment variables that supplied during the execution of the task. |
|
executor |
||
executor_type |
||
instantiated_in |
||
interface |
||
lhs |
||
location |
||
metadata |
||
name |
Return the name of the underlying task. |
|
output_columns |
||
python_interface |
Returns this task’s python interface. |
|
query_template |
||
resources |
||
security_context |
||
task_config |
Returns the user-specified task config which is used for plugin-specific handling of the task. |
|
task_resolver |
||
task_template |
Override the base class implementation to serialize on first call. |
|
task_type |
||
task_type_version |
flytekitplugins.sqlalchemy.task.SQLAlchemyTaskExecutor
Please see the notes for the metaclass above first.
This functionality has two use-cases currently,
- Keep track of naming for non-function
PythonAutoContainerTasks. That is, things like the :py:class:flytekit.extras.sqlite3.task.SQLite3Tasktask. - Task resolvers, because task resolvers are instances of :py:class:
flytekit.core.python_auto_container.TaskResolverMixinclasses, not the classes themselves, which means we need to look on the left hand side of them to see how to find them at task execution time.
class SQLAlchemyTaskExecutor(
args,
kwargs,
)| Parameter | Type |
|---|---|
args |
*args |
kwargs |
**kwargs |
Methods
| 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() |
execute_from_model()
def execute_from_model(
tt: flytekit.models.task.TaskTemplate,
kwargs,
) -> n: Python native output values from the task.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 |
|---|---|
tt |
flytekit.models.task.TaskTemplate |
kwargs |
**kwargs |
find_lhs()
def find_lhs()Properties
| Property | Type | Description |
|---|---|---|
instantiated_in |
||
lhs |
||
location |