Overview
TheDeployer class provides a programmatic interface to configure and deploy Metaflow flows to production orchestrators such as AWS Step Functions, Argo Workflows, and others.
Usage
TheDeployer class allows you to access different production orchestrators supported by Metaflow.
Constructor
Deployer(flow_file, show_output=True, profile=None, env=None, cwd=None, file_read_timeout=3600, **kwargs)
Create a new Deployer instance for deploying a flow.
Parameters:
Path to the flow file to deploy, relative to the current directory.
Show the stdout and stderr to the console by default.
Metaflow profile to use for the deployment. If not specified, the default profile is used.
Additional environment variables to set for the deployment. This overrides the environment set for this process.
The directory to run the subprocess in. If not specified, the current directory is used.
The timeout in seconds until which we try to read the deployer attribute file.
Additional arguments that you would pass to
python myflow.py before the deployment command.Orchestrator Methods
TheDeployer class dynamically provides methods for different production orchestrators. The available methods depend on the Metaflow plugins installed.
Common Orchestrators
argo_workflows(**deployer_kwargs)
Create a deployer for Argo Workflows.
Returns: An orchestrator-specific deployer object that can be used to create, delete, and manage deployments.
Example:
step_functions(**deployer_kwargs)
Create a deployer for AWS Step Functions.
Returns: An orchestrator-specific deployer object that can be used to create, delete, and manage deployments.
Example:
DeployedFlow
TheDeployedFlow class represents a flow that has been deployed to a production orchestrator. It is returned by the create() method of orchestrator-specific deployers.
Class Methods
from_deployment(identifier, metadata=None, impl=None)
Retrieve a DeployedFlow object from an identifier and optional metadata.
Parameters:
identifier(str) - Deployer-specific identifier for the workflow to retrievemetadata(str, optional) - Optional deployer-specific metadataimpl(str, optional) - The deployer implementation to use (e.g.,argo_workflows). Defaults toMETAFLOW_DEFAULT_FROM_DEPLOYMENT_IMPL
DeployedFlow object
Example:
list_deployed_flows(flow_name=None, impl=None)
List all deployed flows for the specified implementation.
Parameters:
flow_name(str, optional) - If specified, only list deployed flows for this specific flow nameimpl(str, optional) - The deployer implementation to use. Defaults toMETAFLOW_DEFAULT_FROM_DEPLOYMENT_IMPL
DeployedFlow objects representing deployed flows
Example:
get_triggered_run(identifier, run_id, metadata=None, impl=None)
Retrieve a TriggeredRun object from an identifier, a run ID, and optional metadata.
Parameters:
identifier(str) - Deployer-specific identifier for the workflowrun_id(str) - Run ID for which to fetch the triggered run objectmetadata(str, optional) - Optional deployer-specific metadataimpl(str, optional) - The deployer implementation to use. Defaults toMETAFLOW_DEFAULT_FROM_DEPLOYMENT_IMPL
TriggeredRun object
Properties
name - str
The name of the deployed workflow.
flow_name - str
The name of the Metaflow flow.
metadata - str
Deployer-specific metadata for the deployment.
Methods
trigger(**kwargs)
Trigger a new run of the deployed flow.
Parameters:
**kwargs- Parameters to pass to the flow
TriggeredRun object
Example:
delete()
Delete the deployed workflow from the orchestrator.
Example:
TriggeredRun
TheTriggeredRun class represents a run that has been triggered on a production orchestrator.
Properties
run - Optional[metaflow.Run]
Retrieve the Metaflow Run object for the triggered run. Note that the Run becomes available only when the start task has started executing. Returns None if the start step hasn’t started yet.
name - str
The name of the triggered run.
pathspec - str
The pathspec of the triggered run (e.g., “MyFlow/123”).
metadata_for_flow - dict
Metadata associated with the flow.
Methods
wait_for_run(check_interval=5, timeout=None)
Wait for the run property to become available. The run property becomes available only after the start task of the triggered flow starts running.
Parameters:
check_interval(int, default 5) - Frequency of checking for the run to become available, in secondstimeout(int, optional) - Maximum time to wait for the run to become available, in seconds. If None, wait indefinitely
TimeoutError- If the run is not available within the specified timeout
terminate()
Terminate the triggered run.
Example:
