Repository navigation
feat(cache): add 'dt cache relink' to symlink cache onto a local remote (0.28.0) - #194
Merged
Merged
Conversation
…te (0.28.0) Replace every regular file in the primary DVC cache with a symlink to its content-addressed twin in a locally-accessible remote, reclaiming the duplicated space. On a shared-filesystem HPC setup the local remote already holds a good copy of every pushed object, so the identical bytes in each clone's cache are pure duplication; the cache stays fully usable because 'dvc checkout' still resolves each object at its normal path. The match is content-addressed (a cache object and its remote copy share the md5 that names them), so the relink is existence-only and never re-hashes. Because that is only trustworthy on a known-good remote, 'dt remote verify' runs first by default (incremental via the remote's ledger) and the relink aborts if it finds bad/incomplete blobs; --force overrides, --skip-verify skips. Objects absent from the remote are left untouched; already-symlinked objects are skipped so re-runs are idempotent. Each replacement is atomic (temp symlink renamed over the object). Handles v3/v2/mixed layouts and .dir manifests, and only renames within existing prefix dirs so shared-cache directory permissions are never disturbed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
dt cache relink [remote], which replaces every regular file in the primary DVC cache with a symlink to its content-addressed twin in a locally-accessible remote — reclaiming the duplicated space. On a shared-filesystem HPC setup the local remote already holds a good copy of every pushed object, so the identical bytes sitting in each clone's cache are pure duplication. The cache stays fully usable:dvc checkoutstill resolves each object at its normal path, it's just a symlink now.Behaviour
dt remote verifyruns first (incremental via the remote's ledger, so repeat runs are cheap) and the relink aborts if it finds bad/incomplete blobs.--force— relink anyway despite bad blobs (warns).--skip-verify— skip the pass entirely (only safe if already verified).-vlists each.--drypreviews and counts reclaimable space without touching the cache.Handles v3/v2/mixed layouts and
.dirmanifests, and only renames within existing prefix directories so shared-cache directory permissions are never disturbed.Remote selection mirrors the rest of the
remote/cachegroups: positional[remote], defaulting to the DVC default remote (via the sharedresolve_local_remote).Changes
dt/cache_relink.py— new module (sweep + helpers)dt/cli.py— newcache relinkcommandtests/unit/test_cache_relink.py— 13 unit testsdocs/cache.md,docs/commands.md— docspyproject.toml,dt/__init__.py— version bump 0.27.1 → 0.28.0Testing
--force,.dirhandling, idempotency, dry-run).dvc checkoutstill resolves; idempotent re-run; missing/.dirhandling; bad-blob abort (exit 1) and--forceoverride all verified.🤖 Generated with Claude Code