@named_env decorator allows you to reference a pre-resolved, named environment for a specific step. Named environments are like Docker tags - they’re aliases for fully resolved environments that can be shared across flows and teams.
Overview
Use@named_env to reference environments that have been resolved and named separately. This enables environment reuse, sharing, and consistent versioning across projects.
When to Use
- Shared environments: Use environments resolved and maintained by your team
- Versioned environments: Pin to specific environment versions (e.g.,
v1,v2) - Reuse across flows: Multiple flows can use the same named environment
- Reproduce past runs: Reference environments from previous executions using pathspecs
- Latest environments: Use mutable tags like
:latestfor always-current dependencies - Environment isolation: Separate environment management from flow code
Parameters
Reference to a named environment alias. The environment must have been previously resolved and aliased.Name format: Note: Cannot specify both
namespace/environment-name[:tag]- The tag is optional; defaults to
:latestif not specified - Tags can contain environment variables using
@{VAR_NAME}syntax - Mutable tags:
:latest,:candidate,:stablecan be updated - Immutable tags: All other tags are permanent once created
name and pathspec in the same decorator.Reference the environment from a previously executed step using its pathspec.Pathspec format: Note: Cannot specify both
FlowName/RunId/StepName- Can use environment variables with
@{VAR_NAME}syntax - Useful for reproducing exact environments from past runs
- Automatically fetches the environment used by that step
name and pathspec in the same decorator.If
True, fetches the environment when the task executes (at runtime) rather than at deploy time or flow start.This is useful for:- Using the
:latestversion at execution time, not deployment time - Dynamic environments that update frequently
- Production deployments that should pick up environment updates
name or pathspec to be specified.If set to
True, disables the managed environment for this step and uses the external environment instead.Usage Examples
Using a Named Environment
Reference a pre-resolved environment:Creating a Named Environment
Resolve and name an environment using CLI:Using Latest Version
Use mutable:latest tag for always-current environments:
Fetch at Execution Time
Always use the latest environment at runtime:fetch_at_exec, the environment is fetched when:
- You run the flow locally
- You deploy to a scheduler (Argo/Airflow/Step Functions)
fetch_at_exec=True, the environment is fetched when:
- The specific task starts executing
Using Pathspecs
Reuse the environment from a previous run:Extending Named Environments
Add packages to a named environment:Environment Naming Convention
Recommended format:team/project/env-name:tag
Combining with Flow-Level Decorator
Step-level@named_env can override @named_env_base:
Viewing Named Environments
List Available Environments
Inspect Environment Contents
Interaction with Other Decorators
Extending with @conda and @pypi
Add packages to a named environment:With @named_env_base
Flow-level base with step-level overrides:Cannot Mix with Definition Decorators
At flow level, cannot combine with@conda_base or @pypi_base:
@named_env can be extended:
Mutable vs Immutable Tags
Mutable Tags
These can be updated to point to different environments::latest- Points to the most recently resolved environment:candidate- For testing/staging environments:stable- For production-ready environments
Immutable Tags
Once created, these always point to the same environment::v1,:v2,:v2.1- Version tags:2023-03-15- Date tags:prod-release-1.0- Release tags
Environment Sharing
Named environments are automatically shared:- Resolved once: One team member resolves and names the environment
- Cached in cloud: Stored in S3/GCS/Azure
- Used by all: Other team members automatically fetch and use it
Related Decorators
@named_env_base- Flow-level named environment reference@conda- Step-level Conda dependencies@conda_base- Flow-level Conda dependencies@pypi- Step-level PyPI dependencies@pypi_base- Flow-level PyPI dependencies
Requirements
- Must use
--environment=condawhen running the flow - Named environment must exist (be previously resolved and aliased)
- Requires Conda/Mamba/Micromamba installed
Notes
- Named environments are immutable (except for mutable tags)
- Environment contents are locked and reproducible
- Can be shared across teams and projects
- Environments are cached in cloud storage (S3/GCS/Azure)
- Pathspecs provide exact reproducibility of past runs
- Fetch-at-exec useful for production deployments with mutable tags
