mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 15:28:28 +01:00
repro --pull: don't fail for cloud-versioned remotes (#10001)
* repro --pull: don't fail for cloud-versioned remotes * raise RunCacheNotSupported for cloud-versioned remotes
This commit is contained in:
+1
-1
@@ -135,7 +135,7 @@ class DataCloud:
|
||||
|
||||
remote = self.get_remote(name=name, command=command)
|
||||
if remote.fs.version_aware or remote.worktree:
|
||||
raise NoRemoteError(
|
||||
raise RemoteConfigError(
|
||||
f"'{command}' is unsupported for cloud versioned remotes"
|
||||
)
|
||||
if hash_name in LEGACY_HASH_NAMES:
|
||||
|
||||
+13
-6
@@ -6,6 +6,7 @@ from typing import TYPE_CHECKING, List, Optional, Tuple
|
||||
from funcy import first
|
||||
|
||||
from dvc import fs
|
||||
from dvc.config import RemoteConfigError
|
||||
from dvc.exceptions import CollectCacheError, DvcException
|
||||
from dvc.utils import dict_sha256, relpath
|
||||
|
||||
@@ -274,15 +275,21 @@ class StageCache:
|
||||
return ret
|
||||
|
||||
def push(self, remote: Optional[str], odb: Optional["ObjectDB"] = None):
|
||||
dest_odb = odb or self.repo.cloud.get_remote_odb(
|
||||
remote, "push --run-cache", hash_name="md5-dos2unix"
|
||||
)
|
||||
try:
|
||||
dest_odb = odb or self.repo.cloud.get_remote_odb(
|
||||
remote, "push --run-cache", hash_name="md5-dos2unix"
|
||||
)
|
||||
except RemoteConfigError as e:
|
||||
raise RunCacheNotSupported(e) from e
|
||||
return self.transfer(self.repo.cache.legacy, dest_odb)
|
||||
|
||||
def pull(self, remote: Optional[str], odb: Optional["ObjectDB"] = None):
|
||||
odb = odb or self.repo.cloud.get_remote_odb(
|
||||
remote, "fetch --run-cache", hash_name="md5-dos2unix"
|
||||
)
|
||||
try:
|
||||
odb = odb or self.repo.cloud.get_remote_odb(
|
||||
remote, "fetch --run-cache", hash_name="md5-dos2unix"
|
||||
)
|
||||
except RemoteConfigError as e:
|
||||
raise RunCacheNotSupported(e) from e
|
||||
return self.transfer(odb, self.repo.cache.legacy)
|
||||
|
||||
def get_used_objs(self, used_run_cache, *args, **kwargs):
|
||||
|
||||
@@ -4,7 +4,7 @@ import pytest
|
||||
from funcy import first
|
||||
|
||||
from dvc.dvcfile import LOCK_FILE
|
||||
from dvc.stage.cache import _get_stage_hash
|
||||
from dvc.stage.cache import RunCacheNotSupported, _get_stage_hash
|
||||
from dvc.utils.fs import remove
|
||||
|
||||
|
||||
@@ -229,3 +229,15 @@ def test_restore_pull(tmp_dir, dvc, run_copy, mocker, local_remote):
|
||||
assert (tmp_dir / "bar").exists()
|
||||
assert not (tmp_dir / "foo").unlink()
|
||||
assert (tmp_dir / LOCK_FILE).exists()
|
||||
|
||||
|
||||
def test_push_pull_unsupported(tmp_dir, dvc, mocker, run_copy):
|
||||
tmp_dir.gen("foo", "foo")
|
||||
run_copy("foo", "bar", name="copy-foo-bar")
|
||||
mocker.patch.object(
|
||||
dvc.cloud, "get_remote_odb", side_effect=RunCacheNotSupported("foo")
|
||||
)
|
||||
with pytest.raises(RunCacheNotSupported):
|
||||
dvc.push(run_cache=True)
|
||||
with pytest.raises(RunCacheNotSupported):
|
||||
dvc.pull(run_cache=True)
|
||||
|
||||
Reference in New Issue
Block a user