flytekit.remote.remote.FlyteRemote#

class flytekit.remote.remote.FlyteRemote(config, default_project=None, default_domain=None, data_upload_location='s3://my-s3-bucket/data', **kwargs)[source]#

Main entrypoint for programmatically accessing a Flyte remote backend.

The term ‘remote’ is synonymous with ‘backend’ or ‘deployment’ and refers to a hosted instance of the Flyte platform, which comes with a Flyte Admin server on some known URI.

Initialize a FlyteRemote object.

Parameters
  • default_project (Optional[str]) – default project to use when fetching or executing flyte entities.

  • default_domain (Optional[str]) – default domain to use when fetching or executing flyte entities.

  • data_upload_location (str) – this is where all the default data will be uploaded when providing inputs. The default location - s3://my-s3-bucket/data works for sandbox/demo environment. Please override this for non-sandbox cases.

  • config (Config) –

Methods

execute(entity, inputs, project=None, domain=None, name=None, version=None, execution_name=None, image_config=None, options=None, wait=False, type_hints=None, overwrite_cache=None)[source]#

Execute a task, workflow, or launchplan, either something that’s been declared locally, or a fetched entity.

This method supports: - Flyte{Task, Workflow, LaunchPlan} remote module objects. - @task-decorated functions and TaskTemplate tasks. - @workflow-decorated functions. - LaunchPlan objects.

For local entities, this code will attempt to find the entity first, and if missing, will compile and register the object.

Not all arguments are relevant in all circumstances. For example, there’s no reason to use the serialization settings for entities that have already been registered on Admin.

Parameters
  • options (Optional[flytekit.tools.translator.Options]) –

  • entity (Union[flytekit.remote.entities.FlyteTask, flytekit.remote.entities.FlyteLaunchPlan, flytekit.remote.entities.FlyteWorkflow, flytekit.core.base_task.PythonTask, flytekit.core.workflow.WorkflowBase, flytekit.core.launch_plan.LaunchPlan]) – entity to execute

  • inputs (Dict[str, Any]) – dictionary mapping argument names to values

  • project (Optional[str]) – execute entity in this project. If entity doesn’t exist in the project, register the entity first before executing.

  • domain (Optional[str]) – execute entity in this domain. If entity doesn’t exist in the domain, register the entity first before executing.

  • name (Optional[str]) – execute entity using this name. If not None, use this value instead of entity.name

  • version (Optional[str]) – execute entity using this version. If None, uses auto-generated value.

  • execution_name (Optional[str]) – name of the execution. If None, uses auto-generated value.

  • image_config (Optional[flytekit.configuration.ImageConfig]) –

  • wait (bool) – if True, waits for execution to complete

  • type_hints (Optional[Dict[str, Type]]) – Python types to be passed to the TypeEngine so that it knows how to properly convert the input values for the execution into Flyte literals. If missing, will default to first guessing the type using the type engine, and then to type(v). Providing the correct Python types is particularly important if the inputs are containers like lists or maps, or if the Python type is one of the more complex Flyte provided classes (like a StructuredDataset that’s annotated with columns).

  • overwrite_cache (Optional[bool]) – Allows for all cached values of a workflow and its tasks to be overwritten for a single execution. If enabled, all calculations are performed even if cached results would be available, overwriting the stored data once execution finishes successfully.

Return type

flytekit.remote.executions.FlyteWorkflowExecution

execute_local_launch_plan(entity, inputs, version, project=None, domain=None, execution_name=None, options=None, wait=False, overwrite_cache=None)[source]#
Parameters
  • entity (flytekit.core.launch_plan.LaunchPlan) – The locally defined launch plan object

  • inputs (Dict[str, Any]) – Inputs to be passed into the execution as a dict with Python native values.

  • version (str) – The version to look up/register the launch plan (if not already exists)

  • project (Optional[str]) – The same as version, but will default to the Remote object’s project

  • domain (Optional[str]) – The same as version, but will default to the Remote object’s domain

  • execution_name (Optional[str]) – If specified, will be used as the execution name instead of randomly generating.

  • options (Optional[flytekit.tools.translator.Options]) –

  • wait (bool) –

  • overwrite_cache (Optional[bool]) –

Returns

Return type

flytekit.remote.executions.FlyteWorkflowExecution

execute_local_task(entity, inputs, project=None, domain=None, name=None, version=None, execution_name=None, image_config=None, wait=False, overwrite_cache=None)[source]#

Execute an @task-decorated function or TaskTemplate task.

Parameters
Returns

Return type

flytekit.remote.executions.FlyteWorkflowExecution

execute_local_workflow(entity, inputs, project=None, domain=None, name=None, version=None, execution_name=None, image_config=None, options=None, wait=False, overwrite_cache=None)[source]#

Execute an @workflow decorated function. :param entity: :param inputs: :param project: :param domain: :param name: :param version: :param execution_name: :param image_config: :param options: :param wait: :param overwrite_cache: :return:

Parameters
Return type

flytekit.remote.executions.FlyteWorkflowExecution

execute_remote_task_lp(entity, inputs, project=None, domain=None, execution_name=None, options=None, wait=False, type_hints=None, overwrite_cache=None)[source]#

Execute a FlyteTask, or FlyteLaunchplan.

NOTE: the name and version arguments are currently not used and only there consistency in the function signature

Parameters
Return type

flytekit.remote.executions.FlyteWorkflowExecution

execute_remote_wf(entity, inputs, project=None, domain=None, execution_name=None, options=None, wait=False, type_hints=None, overwrite_cache=None)[source]#

Execute a FlyteWorkflow.

NOTE: the name and version arguments are currently not used and only there consistency in the function signature

Parameters
Return type

flytekit.remote.executions.FlyteWorkflowExecution

fast_package(root, deref_symlinks=True, output=None)[source]#

Packages the given paths into an installable zip and returns the md5_bytes and the URL of the uploaded location :param root: path to the root of the package system that should be uploaded :param output: output path. Optional, will default to a tempdir :param deref_symlinks: if symlinks should be dereferenced. Defaults to True :return: md5_bytes, url

Parameters
Return type

(bytes, str)

fetch_execution(project=None, domain=None, name=None)[source]#

Fetch a workflow execution entity from flyte admin.

Parameters
  • project (Optional[str]) – fetch entity from this project. If None, uses the default_project attribute.

  • domain (Optional[str]) – fetch entity from this domain. If None, uses the default_domain attribute.

  • name (Optional[str]) – fetch entity with matching name.

Returns

FlyteWorkflowExecution

Raises

FlyteAssertion if name is None

Return type

flytekit.remote.executions.FlyteWorkflowExecution

fetch_launch_plan(project=None, domain=None, name=None, version=None)[source]#

Fetch a launchplan entity from flyte admin.

Parameters
  • project (Optional[str]) – fetch entity from this project. If None, uses the default_project attribute.

  • domain (Optional[str]) – fetch entity from this domain. If None, uses the default_domain attribute.

  • name (Optional[str]) – fetch entity with matching name.

  • version (Optional[str]) – fetch entity with matching version. If None, gets the latest version of the entity.

Returns

FlyteLaunchPlan

Raises

FlyteAssertion if name is None

Return type

flytekit.remote.entities.FlyteLaunchPlan

fetch_task(project=None, domain=None, name=None, version=None)[source]#

Fetch a task entity from flyte admin.

Parameters
  • project (Optional[str]) – fetch entity from this project. If None, uses the default_project attribute.

  • domain (Optional[str]) – fetch entity from this domain. If None, uses the default_domain attribute.

  • name (Optional[str]) – fetch entity with matching name.

  • version (Optional[str]) – fetch entity with matching version. If None, gets the latest version of the entity.

Returns

FlyteTask

Raises

FlyteAssertion if name is None

Return type

flytekit.remote.entities.FlyteTask

fetch_task_lazy(project=None, domain=None, name=None, version=None)[source]#

Similar to fetch_task, just that it returns a LazyEntity, which will fetch the workflow lazily.

Parameters
Return type

flytekit.remote.lazy_entity.LazyEntity

fetch_workflow(project=None, domain=None, name=None, version=None)[source]#

Fetch a workflow entity from flyte admin. :param project: fetch entity from this project. If None, uses the default_project attribute. :param domain: fetch entity from this domain. If None, uses the default_domain attribute. :param name: fetch entity with matching name. :param version: fetch entity with matching version. If None, gets the latest version of the entity. :raises: FlyteAssertion if name is None

Parameters
Return type

flytekit.remote.entities.FlyteWorkflow

fetch_workflow_lazy(project=None, domain=None, name=None, version=None)[source]#

Similar to fetch_workflow, just that it returns a LazyEntity, which will fetch the workflow lazily.

Parameters
Return type

flytekit.remote.lazy_entity.LazyEntity[flytekit.remote.entities.FlyteWorkflow]

generate_console_http_domain()[source]#

This should generate the domain where console is hosted.

Returns

Return type

str

generate_console_url(entity)[source]#

Generate a Flyteconsole URL for the given Flyte remote endpoint. This will automatically determine if this is an execution or an entity and change the type automatically

Parameters

entity (Union[flytekit.remote.executions.FlyteWorkflowExecution, flytekit.remote.executions.FlyteNodeExecution, flytekit.remote.executions.FlyteTaskExecution, flytekit.remote.entities.FlyteWorkflow, flytekit.remote.entities.FlyteTask, flytekit.remote.entities.FlyteLaunchPlan]) –

launch_backfill(project, domain, from_date, to_date, launchplan, launchplan_version=None, execution_name=None, version=None, dry_run=False, execute=True, parallel=False)[source]#

Creates and launches a backfill workflow for the given launchplan. If launchplan version is not specified, then the latest launchplan is retrieved. The from_date is exclusive and end_date is inclusive and backfill run for all instances in between.

-> (start_date - exclusive, end_date inclusive)

If dry_run is specified, the workflow is created and returned if execute==False is specified then the workflow is created and registered in the last case, the workflow is created, registered and executed.

The parallel flag can be used to generate a workflow where all launchplans can be run in parallel. Default is that execute backfill is run sequentially

Parameters
  • project (str) – str project name

  • domain (str) – str domain name

  • from_date (datetime) – datetime generate a backfill starting at this datetime (exclusive)

  • to_date (datetime) – datetime generate a backfill ending at this datetime (inclusive)

  • launchplan (str) – str launchplan name in the flyte backend

  • launchplan_version (str) – str (optional) version for the launchplan. If not specified the most recent will be retrieved

  • execution_name (str) – str (optional) the generated execution will be named so. this can help in ensuring idempotency

  • version (str) – str (optional) version to be used for the newly created workflow.

  • dry_run (bool) – bool do not register or execute the workflow

  • execute (bool) – bool Register and execute the wwkflow.

  • parallel (bool) – if the backfill should be run in parallel. False (default) will run each bacfill sequentially

Returns

In case of dry-run, return WorkflowBase, else if no_execute return FlyteWorkflow else in the default case return a FlyteWorkflowExecution

Return type

Optional[FlyteWorkflowExecution, FlyteWorkflow, WorkflowBase]

list_signals(execution_name, project=None, domain=None, limit=100, filters=None)[source]#
Parameters
  • execution_name (str) – The name of the execution. This is the tailend of the URL when looking at the workflow execution.

  • project (Optional[str]) – The execution project, will default to the Remote’s default project.

  • domain (Optional[str]) – The execution domain, will default to the Remote’s default domain.

  • limit (int) – The number of signals to fetch

  • filters (Optional[List[flytekit.models.filters.Filter]]) – Optional list of filters

Return type

List[flyteidl.admin.signal_pb2.Signal]

list_tasks_by_version(version, project=None, domain=None, limit=100)[source]#
Parameters
Return type

List[flytekit.remote.entities.FlyteTask]

raw_register(cp_entity, settings, version, create_default_launchplan=True, options=None, og_entity=None)[source]#

Raw register method, can be used to register control plane entities. Usually if you have a Flyte Entity like a WorkflowBase, Task, LaunchPlan then use other methods. This should be used only if you have already serialized entities

Parameters
  • cp_entity (Union[flytekit.models.task.TaskSpec, flytekit.models.launch_plan.LaunchPlan, flytekit.models.admin.workflow.WorkflowSpec, flytekit.models.core.workflow.Node, flytekit.models.core.workflow.BranchNode]) – The controlplane “serializable” version of a flyte entity. This is in the form that FlyteAdmin understands.

  • settings (flytekit.configuration.SerializationSettings) – SerializationSettings to be used for registration - especially to identify the id

  • version (str) – Version to be registered

  • create_default_launchplan (bool) – boolean that indicates if a default launch plan should be created

  • options (Optional[flytekit.tools.translator.Options]) – Options to be used if registering a default launch plan

  • og_entity (Optional[Union[flytekit.core.base_task.PythonTask, flytekit.core.condition.BranchNode, flytekit.core.node.Node, flytekit.core.launch_plan.LaunchPlan, flytekit.core.workflow.WorkflowBase, flytekit.core.workflow.ReferenceWorkflow, flytekit.core.task.ReferenceTask, flytekit.core.launch_plan.ReferenceLaunchPlan, flytekit.core.reference_entity.ReferenceEntity]]) – Pass in the original workflow (flytekit type) if create_default_launchplan is true

Returns

Identifier of the created entity

Return type

Optional[flytekit.models.core.identifier.Identifier]

recent_executions(project=None, domain=None, limit=100)[source]#
Parameters
Return type

List[flytekit.remote.executions.FlyteWorkflowExecution]

register_launch_plan(entity, version, project=None, domain=None, options=None)[source]#

Register a given launchplan, possibly applying overrides from the provided options. :param entity: Launchplan to be registered :param version: :param project: Optionally provide a project, if not already provided in flyteremote constructor or a separate one :param domain: Optionally provide a domain, if not already provided in FlyteRemote constructor or a separate one :param options: :return:

Parameters
Return type

flytekit.remote.entities.FlyteLaunchPlan

register_script(entity, image_config=None, version=None, project=None, domain=None, destination_dir='.', default_launch_plan=True, options=None, source_path=None, module_name=None)[source]#

Use this method to register a workflow via script mode. :param destination_dir: :param domain: :param project: :param image_config: :param version: version for the entity to be registered as :param entity: The workflow to be registered or the task to be registered :param default_launch_plan: This should be true if a default launch plan should be created for the workflow :param options: Additional execution options that can be configured for the default launchplan :param source_path: The root of the project path :param module_name: the name of the module :return:

Parameters
Return type

Union[flytekit.remote.entities.FlyteWorkflow, flytekit.remote.entities.FlyteTask]

register_task(entity, serialization_settings, version=None)[source]#

Register a qualified task (PythonTask) with Remote For any conflicting parameters method arguments are regarded as overrides

Parameters
Returns

Return type

flytekit.remote.entities.FlyteTask

register_workflow(entity, serialization_settings=None, version=None, default_launch_plan=True, options=None)[source]#

Use this method to register a workflow. :param version: version for the entity to be registered as :param entity: The workflow to be registered :param serialization_settings: The serialization settings to be used :param default_launch_plan: This should be true if a default launch plan should be created for the workflow :param options: Additional execution options that can be configured for the default launchplan :return:

Parameters
Return type

flytekit.remote.entities.FlyteWorkflow

remote_context()[source]#

Context manager with remote-specific configuration.

set_signal(signal_id, execution_name, value, project=None, domain=None, python_type=None, literal_type=None)[source]#
Parameters
  • signal_id (str) – The name of the signal, this is the key used in the approve() or wait_for_input() call.

  • execution_name (str) – The name of the execution. This is the tail-end of the URL when looking at the workflow execution.

  • value (Union[flytekit.models.literals.Literal, Any]) – This is either a Literal or a Python value which FlyteRemote will invoke the TypeEngine to convert into a Literal. This argument is only value for wait_for_input type signals.

  • project (Optional[str]) – The execution project, will default to the Remote’s default project.

  • domain (Optional[str]) – The execution domain, will default to the Remote’s default domain.

  • python_type (Optional[Type]) – Provide a python type to help with conversion if the value you provided is not a Literal.

  • literal_type (Optional[flytekit.models.types.LiteralType]) – Provide a Flyte literal type to help with conversion if the value you provided is not a Literal

sync(execution, entity_definition=None, sync_nodes=False)[source]#

This function was previously a singledispatchmethod. We’ve removed that but this function remains so that we don’t break people.

Parameters
Returns

Returns the same execution object, but with additional information pulled in.

Return type

flytekit.remote.executions.FlyteWorkflowExecution

sync_execution(execution, entity_definition=None, sync_nodes=False)[source]#

Sync a FlyteWorkflowExecution object with its corresponding remote state.

Parameters
Return type

flytekit.remote.executions.FlyteWorkflowExecution

sync_node_execution(execution, node_mapping)[source]#

Get data backing a node execution. These FlyteNodeExecution objects should’ve come from Admin with the model fields already populated correctly. For purposes of the remote experience, we’d like to supplement the object with some additional fields:

  • inputs/outputs

  • task/workflow executions, and/or underlying node executions in the case of parent nodes

  • TypedInterface (remote wrapper type)

A node can have several different types of executions behind it. That is, the node could’ve run (perhaps multiple times because of retries):

  • A task

  • A static subworkflow

  • A dynamic subworkflow (which in turn may have run additional tasks, subwfs, and/or launch plans)

  • A launch plan

The data model is complicated, so ascertaining which of these happened is a bit tricky. That logic is encapsulated in this function.

Parameters
Return type

flytekit.remote.executions.FlyteNodeExecution

sync_task_execution(execution, entity_definition=None)[source]#

Sync a FlyteTaskExecution object with its corresponding remote state.

Parameters
Return type

flytekit.remote.executions.FlyteTaskExecution

terminate(execution, cause)[source]#

Terminate a workflow execution.

Parameters
wait(execution, timeout=None, poll_interval=None, sync_nodes=True)[source]#

Wait for an execution to finish.

Parameters
Return type

flytekit.remote.executions.FlyteWorkflowExecution

Attributes

client#

Return a SynchronousFlyteClient for additional operations.

config#

Image config.

context#
default_domain#

Default project to use when fetching or executing flyte entities.

default_project#

Default project to use when fetching or executing flyte entities.

file_access#

File access provider to use for offloading non-literal inputs/outputs.