flytekitplugins.sqlalchemy.SQLAlchemyTask#

class flytekitplugins.sqlalchemy.SQLAlchemyTask(*args, **kwargs)[source]#

Makes it possible to run client side SQLAlchemy queries that optionally return a FlyteSchema object

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

  • container_image – This is the external container image the task should run at platform-run-time.

  • executor – This is an executor which will actually provide the business logic.

  • task_resolver – Custom resolver - if you don’t make one, use the default task template resolver.

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

  • requests – custom resource request settings.

  • limits – custom resource limit settings.

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

  • 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

Methods

compile(ctx, *args, **kwargs)#

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

Parameters

ctx (flytekit.core.context_manager.FlyteContext) –

construct_node_metadata()#

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

Return type

flytekit.models.core.workflow.NodeMetadata

dispatch_execute(ctx, input_literal_map)#

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.

Parameters
Return type

Union[flytekit.models.literals.LiteralMap, flytekit.models.dynamic_job.DynamicJobSpec]

execute(**kwargs)#

Rather than running here, send everything to the executor.

Return type

Any

find_lhs()#
Return type

str

get_command(settings)#
Parameters

settings (flytekit.configuration.SerializationSettings) –

Return type

List[str]

get_config(settings)#

Returns the task config as a serializable dictionary. This task config consists of metadata about the custom defined for this task.

Parameters

settings (flytekit.configuration.SerializationSettings) –

Return type

Dict[str, str]

get_container(settings)#

Returns the container definition (if any) that is used to run the task on hosted Flyte.

Parameters

settings (flytekit.configuration.SerializationSettings) –

Return type

flytekit.models.task.Container

get_custom(settings)[source]#

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

Parameters

settings (flytekit.configuration.SerializationSettings) –

Return type

Dict[str, Any]

get_input_types()#

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

Return type

Optional[Dict[str, type]]

get_k8s_pod(settings)#

Returns the kubernetes pod definition (if any) that is used to run the task on hosted Flyte.

Parameters

settings (flytekit.configuration.SerializationSettings) –

Return type

Optional[flytekit.models.task.K8sPod]

get_query(**kwargs)#
Return type

str

get_sql(settings)#

Returns the Sql definition (if any) that is used to run the task on hosted Flyte.

Parameters

settings (flytekit.configuration.SerializationSettings) –

Return type

Optional[flytekit.models.task.Sql]

get_type_for_input_var(k, v)#

Returns the python type for an input variable by name.

Parameters
Return type

Optional[Type[Any]]

get_type_for_output_var(k, v)#

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

Parameters
Return type

Optional[Type[Any]]

classmethod interpolate_query(query_template, **kwargs)#

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

Any

local_execute(ctx, **kwargs)#

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 (flytekit.core.context_manager.FlyteContext) –

Return type

Union[Tuple[flytekit.core.promise.Promise], flytekit.core.promise.Promise, flytekit.core.promise.VoidPromise]

post_execute(user_params, rval)#

This function is a stub, just here to keep dispatch_execute compatibility between this class and PythonTask.

Parameters
Return type

Any

pre_execute(user_params)#

This function is a stub, just here to keep dispatch_execute compatibility between this class and PythonTask.

Parameters

user_params (flytekit.core.context_manager.ExecutionParameters) –

Return type

flytekit.core.context_manager.ExecutionParameters

serialize_to_model(settings)#
Parameters

settings (flytekit.configuration.SerializationSettings) –

Return type

flytekit.models.task.TaskTemplate

Attributes

SERIALIZE_SETTINGS = SerializationSettings(image_config=ImageConfig(default_image=Image(name='custom_container_task', fqn='flyteorg.io/placeholder', tag='image'), images=None), project='PLACEHOLDER_PROJECT', domain='LOCAL', version='PLACEHOLDER_VERSION', env=None, python_interpreter='/opt/venv/bin/python3', flytekit_virtualenv_root='/opt/venv', fast_serialization_settings=None)#
container_image#
disable_deck#

If true, this task will not 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#