LinuxCommandLibrary

dvc-config

Configure DVC projects

TLDR

Get the name of the default remote

$ dvc config core.remote
copy

Set the project's default remote
$ dvc config core.remote [remote_name]
copy

Unset the project's default remote
$ dvc config [[-u|--unset]] core.remote
copy

Get the configuration value for a specified key for the current project
$ dvc config [key]
copy

Set the configuration value for a key on a project level
$ dvc config [key] [value]
copy

Unset a project level configuration value for a given key
$ dvc config [[-u|--unset]] [key]
copy

Set a local, global, or system level configuration value
$ dvc config --[local|global|system] [key] [value]
copy

SYNOPSIS

dvc config [options] <param> [<value>]
dvc config [options] --list
dvc config [options] --unset <param>

PARAMETERS

-h, --help
    Show the help message for the dvc-config command and exit.

-q, --quiet
    Suppress all output from the command, useful for scripting.

-v, --verbose
    Be more verbose in output, displaying additional diagnostic information.

-g, --global
    Operate on the global DVC configuration file, typically located at ~/.dvc/config on Linux. Settings here apply to all DVC projects for the current user.

-L, --local
    Operate on the local DVC configuration file, usually found at .dvc/config.local within a DVC repository. Settings here have the highest precedence and are typically not committed to Git.

--unset
    Unset (remove) the specified configuration parameter. This option requires a <param> argument and cannot be used with a <value>.

--list
    List all effective configuration parameters known to DVC, including those inherited from global, repository, and local files. This option does not take <param> or <value>.

<param>
    The specific configuration parameter to set, query, or unset. Parameters are often structured hierarchically using dot notation, e.g., core.cache_dir or remote.origin.url.

<value>
    The value to assign to the specified <param> when setting a configuration. This argument is not used with --unset or --list.

DESCRIPTION

dvc-config is a fundamental subcommand of DVC (Data Version Control) designed to manage configuration parameters for DVC projects. It empowers users to set, unset, query, or list various DVC settings that dictate how DVC operates within a specific repository, or globally across all DVC projects for a user.

These configurations can include critical settings such as defining remote storage locations (e.g., S3, Google Cloud Storage, SSH), specifying cache directories, controlling data linking strategies (e.g., hardlinks, symlinks), and adjusting other core behaviors. The command functions much like git config, providing a structured and familiar interface for customizing DVC to suit different environments, team workflows, or specific project requirements. It's capable of modifying configuration files at the system-wide, global user, repository-specific, or local repository levels, adhering to a defined precedence for how these settings are applied and overridden.

CAVEATS

1. Configuration Precedence: DVC applies configuration settings with a specific order of precedence: .dvc/config.local (highest) > .dvc/config > ~/.dvc/config > system-wide config (lowest). Be aware of where you set parameters to ensure they take effect as intended.
2. Impact of Changes: Modifying critical parameters like core.cache_dir or remote.default can significantly alter how DVC handles data and models. For instance, changing the cache directory might require re-running dvc add or dvc checkout to update links or move cached files.
3. Sensitive Information: While dvc-config can store any string, it's generally recommended to avoid embedding sensitive credentials (e.g., cloud access keys) directly into plain-text configuration files. DVC provides alternative mechanisms like environment variables or external credential management for better security.

CONFIG FILE LOCATIONS AND HIERARCHY

DVC reads configurations from several locations, applying them in a specific hierarchical order, where settings in higher-priority files override those in lower-priority ones:
1. Local Repository Config: .dvc/config.local (highest precedence). This file is intended for user-specific settings within a repository and is typically excluded from Git version control.
2. Repository Config: .dvc/config. This file contains project-wide settings that are usually committed to Git, ensuring consistency across collaborators.
3. Global User Config: ~/.dvc/config. This file applies to all DVC projects for the current user.
4. System-wide Config: /etc/dvc/config (or similar, depending on OS). This is the lowest precedence and is less commonly used.
When setting a parameter without --global or --local flags, dvc-config defaults to writing to the .dvc/config file.

PARAMETER NAMING STRUCTURE

Configuration parameters are typically organized hierarchically using dot notation, reflecting a section.key or section.subsection.key structure. Common top-level sections include:
core: Controls general DVC behavior and settings (e.g., core.cache_dir, core.no_scm, core.dvc_ignore).
remote: Defines and configures remote storage locations for data and models (e.g., remote.origin.url, remote.my_s3.path, remote.my_gcs.credentialpath).
cache: Specifies settings related to the DVC cache (e.g., cache.type for hardlinks/symlinks, cache.dir to override core.cache_dir).
feature: Used for enabling or disabling experimental DVC features.

HISTORY

dvc-config has been an integral and fundamental component of DVC (Data Version Control) since its initial major release around 2017 by Iterative.ai. Its design and functionality closely mirror that of git config, reflecting DVC's core philosophy of bringing Git-like version control to data and machine learning models. This deliberate design choice aimed to provide a familiar and intuitive configuration experience for users already accustomed to Git, thereby facilitating easier adoption and seamless integration of DVC into existing data science and MLOps workflows.

SEE ALSO

dvc(1), dvc remote(1), git config(1), git(1)

Copied to clipboard