Implementation:Iterative Dvc DataCloud Get Remote
| Knowledge Sources | |
|---|---|
| Domains | Storage_Management, Configuration_Management |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
Concrete tool for resolving a named remote storage configuration into a fully initialized Remote object provided by the DVC library.
Description
The DataCloud.get_remote method is the primary entry point in DVC for translating a remote name (or the default remote) into a usable Remote object. It reads the merged multi-level configuration, instantiates the appropriate fsspec-compatible filesystem class, and wraps the result alongside the remote path, an optional data index view, and provider-specific configuration. The Remote object in turn provides lazy-initialized object databases (ODB) for both the current hash algorithm and the legacy md5-dos2unix algorithm.
The method resides in the DataCloud class within dvc/data_cloud.py, which serves as the central manager for all remote operations (push, pull, status). The companion Config class in dvc/config.py handles the layered loading and merging of configuration files from system, global, repo, and local levels. Together, these two classes implement the full remote resolution pipeline from raw config files to a ready-to-use filesystem connection.
Usage
Import and use DataCloud.get_remote whenever you need to obtain a configured remote before performing data transfer, status checks, or any operation that targets a specific storage backend. It is called internally by push, pull, fetch, and status commands, but can also be invoked directly when building custom data synchronization workflows.
Code Reference
Source Location
- Repository: DVC
- File:
dvc/data_cloud.py - Lines: L81-124 (get_remote)
- Supporting files:
dvc/config.pyL81-107 (Config.__init__), L164-196 (Config.load)
Signature
def get_remote(
self,
name: Optional[str] = None,
command: str = "<command>",
) -> "Remote":
Import
from dvc.data_cloud import DataCloud
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | Optional[str] | No | Name of the remote to resolve. If None, the default remote from core.remote config is used. |
| command | str | No | Name of the calling command (e.g., "push", "pull"), used in error messages when no remote is found. |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Remote | A Remote object containing the resolved filesystem (fs), root path (path), remote name (name), optional data index view (index), and a lazily-initialized ODB for content-addressed storage. The Remote also exposes a worktree flag and provider-specific config. |
Exceptions:
- NoRemoteError -- raised when no remote name is provided, no default is configured, and the operation cannot proceed.
- RemoteConfigError -- raised when a worktree remote explicitly sets version_aware to False (which is incompatible).
Usage Examples
Basic Usage
from dvc.repo import Repo
# Open the DVC repository
repo = Repo()
# Resolve the default remote
remote = repo.cloud.get_remote()
print(f"Remote: {remote.name}")
print(f"Path: {remote.path}")
print(f"Filesystem: {remote.fs.protocol}")
# Resolve a specific named remote
s3_remote = repo.cloud.get_remote(name="myremote", command="push")
print(f"ODB path: {s3_remote.odb.path}")
Configuration Hierarchy Example
from dvc.config import Config
# Load the full layered config
config = Config(dvc_dir=".dvc")
# Inspect which remote is the default
default_remote = config["core"].get("remote")
print(f"Default remote: {default_remote}")
# List all configured remotes
for name, settings in config["remote"].items():
print(f" {name}: {settings.get('url', 'no url')}")