Skip to main content

@app_deploy

Simplify bookkeeping and lifecycle management for apps deployed from Metaflow flows. While you can deploy apps from within a flow using the AppDeployer API directly, doing so at scale introduces operational challenges: tracking which apps belong to which run, cleaning up apps when flows complete or fail, and discovering apps deployed across many runs. This decorator addresses these concerns automatically. When applied to a flow, @app_deploy provides:
  1. Automatic Tagging: Every app deployed gains Metaflow metadata tags (flow name, run ID, step, task ID, project/branch info) enabling easy discovery and association with specific flow executions.
  2. Lifecycle Management: Configure automatic cleanup policies to scale down or delete apps when the flow exits (on success or failure), preventing orphaned apps from accumulating.
  3. Convenient Access: Exposes current.apps with the flow’s code package and container image, plus a list() method to discover all apps deployed in the current run.
Parameters:
string
default:"none"
Action to perform on all apps deployed in this run when the flow exits:
  • "none": No cleanup; apps remain running after flow completion.
  • "scale_down": Scale all deployed apps to zero replicas.
  • "delete": Delete all deployed apps.
Examples:
With cleanup policy to prevent orphaned apps:

current.apps

Manager for apps deployed within a Metaflow flow execution. Accessible via current.apps when using the @app_deploy decorator. Provides access to the flow’s code package, container image, and methods to list apps deployed in the current run. Attributes:
object
The code package for the current flow, ready to use with AppDeployer.
string
The container image used by the current task (from fast bakery or similar).
string
The default Kubernetes container image from the Metaflow config.
Examples: