Skip to content

Commit

Permalink
get/import: use in-memory index for remote repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry committed Aug 22, 2024
1 parent 3f2584d commit 5a44dbd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions dvc/repo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def __init__( # noqa: PLR0915, PLR0913
Callable[[str, Exception], None]
] = None
self._lock_depth: int = 0
self._is_remote = False

def __str__(self):
return self.url or self.root_dir
Expand Down Expand Up @@ -365,6 +366,8 @@ def data_index(self) -> "DataIndex":
index_dir = os.path.join(self.site_cache_dir, "index", "data")
os.makedirs(index_dir, exist_ok=True)
self._data_index = DataIndex.open(os.path.join(index_dir, "db.db"))
if self._is_remote:
self._data_index = DataIndex()

return self._data_index

Expand Down
4 changes: 3 additions & 1 deletion dvc/repo/open_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def _external_repo(url, rev: Optional[str] = None, **kwargs) -> "Repo":
**kwargs,
)

return Repo(**repo_kwargs)
repo = Repo(**repo_kwargs)
repo._is_remote = True
return repo


def open_repo(url, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion dvc/testing/benchmarks/cli/commands/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ def test_get(bench_dvc, tmp_dir, scm, dvc, make_dataset, remote):
dataset = make_dataset(
cache=False, files=False, dvcfile=True, commit=True, remote=True
)
bench_dvc("get", tmp_dir, dataset.name, "-o", "new")
bench_dvc("get", f"file://{tmp_dir.as_posix()}", dataset.name, "-o", "new")
3 changes: 1 addition & 2 deletions dvc/testing/benchmarks/cli/commands/test_import.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest


@pytest.mark.flaky(reruns=3)
@pytest.mark.requires(
"!=3.53.*,!=3.54.0",
reason="Takes 10 mins to run. Regression in 3.53.0, fixed in 3.54.1",
Expand All @@ -12,4 +11,4 @@ def test_import(bench_dvc, tmp_dir, scm, dvc, make_dataset, remote):
dataset = make_dataset(
cache=False, files=False, dvcfile=True, commit=True, remote=True
)
bench_dvc("import", tmp_dir, dataset.name, "-o", "new")
bench_dvc("import", f"file://{tmp_dir.as_posix()}", dataset.name, "-o", "new")

0 comments on commit 5a44dbd

Please sign in to comment.