Source: dvc/api/show.py:156-404
Description
Retrieve parameters tracked in a DVC repository. Without arguments, this function retrieves all parameters from all tracked parameter files for the current working tree. Parameters are typically stored in YAML, JSON, TOML, or Python files and tracked indvc.yaml. This function provides programmatic access to these parameters for analysis, comparison, or dynamic configuration.
Signature
Parameters
Names of the parameter files to retrieve parameters from (positional arguments).
- If no targets are provided, all parameter files tracked in
dvc.yamlwill be used - Targets don’t necessarily have to be defined in
dvc.yaml - Can specify multiple files:
params_show("params.yaml", "config.toml")
Location of the DVC repository.
- Defaults to the current project (found by walking up from the current working directory)
- Can be a URL or a file system path
- Both HTTP and SSH protocols are supported for online Git repos
Name or names of the stages to retrieve parameters from.
- If
None, all parameters from all stages will be retrieved - Can be a single string or an iterable of strings
- If called from a different location than
dvc.yaml, use:{relpath}:{stage}
Name of the Git revision to retrieve parameters from.
- Defaults to
None(current working tree) - Can be a branch name, tag name, commit hash, or DVC experiment name
- If
repois not a Git repo, this option is ignored
Whether to retrieve only parameters that are stage dependencies.
- When
True, only returns parameters explicitly listed as dependencies - When
False, returns all parameters
Config dictionary to be passed through to the DVC project.
Returns
A dictionary containing the parameters. The structure depends on the parameter files:
- Single file: Returns the parameters directly
- Multiple files with unique keys: Merges parameters from all files
- Multiple files with conflicting keys: Prefixes keys with
filename:key
Examples
Basic Usage - All Parameters
From Specific Git Revision
Filter by Stages
Specific Parameter Files
Remote Repository
Compare Parameters Across Branches
Access Nested Parameters
Handle Multiple Files with Conflicts
Load Parameters for Training
Get Only Dependency Parameters
Error Handling
Use Cases
Hyperparameter Tracking
Track and compare hyperparameters across experiments and branches.
Dynamic Configuration
Load parameters programmatically in training and inference scripts.
Experiment Comparison
Compare parameter settings across different experiments.
Reproducibility
Retrieve exact parameters used in past experiments for reproduction.
Parameter File Formats
- YAML
- JSON
- TOML
- Python
Return Value Structure
Single parameter file
Single parameter file
When retrieving parameters from a single file, the structure matches the file content:
Multiple files (unique keys)
Multiple files (unique keys)
When parameter keys are unique across files, they’re merged:
Multiple files (conflicting keys)
Multiple files (conflicting keys)
When keys conflict, they’re prefixed with the filename:
Stage filtering
Stage filtering
When filtering by stages, only parameters used by those stages are returned:
Best Practices
Version control parameters
Version control parameters
Store parameters in version control and track with DVC:
Use for reproducibility
Use for reproducibility
Retrieve exact parameters for reproducing results:
Compare across experiments
Compare across experiments
Build parameter comparison tools:
Handle missing parameters gracefully
Handle missing parameters gracefully
Use
.get() with defaults for robustness:Related Functions
metrics_show()
Retrieve metrics values
exp_show()
Show experiments with params
read()
Read any tracked file