metaflow environment.
Global Options
These options apply to allmetaflow environment commands:
—quiet / —no-quiet
Default:False
Suppress unnecessary messages. Useful for scripting.
—metadata
Default:serviceChoices:
local, service
Metadata service type to use.
—datastore
Default:s3Choices:
s3, local, azure, gs
Datastore type for environment caching.
—environment
Default:condaChoices:
conda
Type of environment to manage (currently only conda is supported).
—conda-root
Root path for Conda cached information. OverridesMETAFLOW_CONDA_S3ROOT (or equivalent for other datastores).
resolve
Resolve dependencies into a fully specified environment.Options
—alias
Type: String (multiple allowed)Default:
None
Alias the resolved environment. Can specify multiple times for multiple aliases.
—force / —no-force
Default:False
Force resolution of already resolved environments.
—local-only / —non-local
Default:False
Only look locally for “using” environments (don’t fetch from remote).
—dry-run / —no-dry-run
Default:False
Only resolve, don’t download, cache, persist, or alias anything.
—set-default / —no-set-default
Default:True
Set the resolved environment as the default for this requirement ID.
—arch
Type: String (multiple allowed)Default: Current architecture Architecture(s) to resolve for. Can specify multiple times.
—python
Type: StringDefault: Current Python version Python version constraint.
-r, —requirement
Type: File path Get environment definition from a requirements.txt file (pip format).-f, —file
Type: File path Get environment definition from an environment.yml file (conda format).-p, —pyproject
Type: File path Get environment definition from a pyproject.toml file (poetry format).—using-pathspec
Type: String Create environment starting with the environment from the specified pathspec.—using
Type: String Create environment starting with the referenced environment.—from-pathspec
Type: String Create environment by cloning requirements from the specified pathspec.—from
Type: String Create environment by cloning requirements from the referenced environment.Examples
- Basic Resolution
- With Alias
- Multi-Architecture
- Extending
Resolve from requirements file:
create
Create a local Conda environment from a resolved environment.Arguments
ENV_NAME
Required Environment identifier. Can be:- A pathspec:
MyFlow/123/train(with--pathspecflag) - A partial hash (req_id):
42a4ed94b63f12e1fe9dd29de21bf9ec6e271b1c - A full hash:
42a4ed94b63f12e1fe9dd29de21bf9ec6e271b1c:a3b104c4ce2215351a2b94076ef7827de3ad890a - An environment name:
my_team/my_env:v1
Options
—name
Type: StringDefault: Auto-generated Name for the local environment.
—local-only / —non-local
Default:False
Only create if environment is known locally (don’t fetch from remote).
—force / —no-force
Default:False
Recreate the environment if it exists. Also remove --into-dir if it exists.
—strict / —no-strict
Default:True
Fail if cannot install the original Metaflow environment.
—into-dir
Type: Directory path Download the step’s code package into this directory (for pathspecs).—install-notebook / —no-install-notebook
Default:False
Install the environment as a Jupyter kernel. Requires --name.
—pathspec
Default:False
The environment name is a pathspec.
Examples
- From Named Env
- From Pathspec
- With Jupyter
Create from a named environment:Activate:
When using
--into-dir with a pathspec, the code package is downloaded and a metaflow_setup.sh script is created to set up environment variables.show
Show information about an environment.Arguments
ENVS
Required (one or more) Environment identifier(s) to show.Options
—local-only / —non-local
Default:False
Only resolve using local information (don’t fetch from remote).
—arch
Default: Current architecture Show environment for this architecture.—pathspec
Default:False
The environments given are pathspecs.
Examples
- Named Environment
- Pathspec
- Multiple
- Different Arch
Output
Shows:- Environment type (conda-only, pypi-only, mixed)
- Full hash (req_id:full_id)
- Architecture
- Resolution date and user
- Local presence
- User-requested packages
- All installed packages
get
Fetch an environment from remote storage to local cache.Arguments
SOURCE_ENV
Required Environment identifier to fetch.Options
—default / —no-default
Default:True
Set the downloaded environment as default for its requirement ID.
—arch
Type: StringDefault: Current architecture Request this architecture.
—pathspec
Default:False
The environment name is a pathspec.
Examples
- Fetch Named
- Fetch Pathspec
- Different Arch
This command downloads the environment definition from remote storage and adds it to your local cache. It does not create the actual Conda environment - use
create for that.alias
Alias an existing environment with a new name.Arguments
SOURCE_ENV
Required Source environment identifier.ALIAS
Required New alias name.Options
—local-only / —non-local
Default:False
Only resolve source environment using local information.
—pathspec
Default:False
The source environment is a pathspec.
Examples
- Alias Hash
- Alias Pathspec
- Promote Candidate
Flow-Specific Commands
When usingpython myflow.py --environment=conda environment, you get flow-specific environment commands:
Resolve Flow Environments
metaflow environment resolve except no -r, -f, or -p options.
Example
Debugging and Inspection
View All Packages in an Environment
Check if Environment Exists Locally
Find Which Steps Use an Environment
Compare Two Environments
Scripting with —quiet
Use--quiet for machine-readable output:
Next Steps
Configuration
Configure Conda v2 behavior
Troubleshooting
Debug common issues
