mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
fix(push/pull): don't fail on unsupported run cache (#10441)
This commit is contained in:
@@ -2,6 +2,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from dvc.exceptions import DownloadError
|
||||
from dvc.log import logger
|
||||
from dvc.stage.cache import RunCacheNotSupported
|
||||
from dvc.ui import ui
|
||||
from dvc_data.index import DataIndex, FileStorage
|
||||
|
||||
@@ -136,6 +137,8 @@ def fetch( # noqa: PLR0913
|
||||
try:
|
||||
if run_cache:
|
||||
self.stage_cache.pull(remote)
|
||||
except RunCacheNotSupported as e:
|
||||
logger.debug("failed to pull run cache: %s", e)
|
||||
except DownloadError as exc:
|
||||
failed_count += exc.amount
|
||||
|
||||
|
||||
+9
-2
@@ -1,10 +1,14 @@
|
||||
from contextlib import suppress
|
||||
|
||||
from dvc.exceptions import InvalidArgumentError, UploadError
|
||||
from dvc.log import logger
|
||||
from dvc.stage.cache import RunCacheNotSupported
|
||||
from dvc.ui import ui
|
||||
|
||||
from . import locked
|
||||
|
||||
logger = logger.getChild(__name__)
|
||||
|
||||
|
||||
def _rebuild(idx, path, fs, cb):
|
||||
from dvc_data.index import DataIndex, DataIndexEntry, Meta
|
||||
@@ -95,8 +99,11 @@ def push( # noqa: PLR0913
|
||||
"Multiple rev push is unsupported for cloud versioned remotes"
|
||||
)
|
||||
|
||||
used_run_cache = self.stage_cache.push(remote) if run_cache else []
|
||||
transferred_count += len(used_run_cache)
|
||||
try:
|
||||
used_run_cache = self.stage_cache.push(remote) if run_cache else []
|
||||
transferred_count += len(used_run_cache)
|
||||
except RunCacheNotSupported as e:
|
||||
logger.debug("failed to push run cache: %s", e)
|
||||
|
||||
if isinstance(targets, str):
|
||||
targets = [targets]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
import pytest
|
||||
@@ -231,13 +232,15 @@ def test_restore_pull(tmp_dir, dvc, run_copy, mocker, local_remote):
|
||||
assert (tmp_dir / LOCK_FILE).exists()
|
||||
|
||||
|
||||
def test_push_pull_unsupported(tmp_dir, dvc, mocker, run_copy):
|
||||
def test_push_pull_unsupported(tmp_dir, dvc, mocker, run_copy, local_remote, caplog):
|
||||
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):
|
||||
with caplog.at_level(logging.DEBUG):
|
||||
dvc.push(run_cache=True)
|
||||
with pytest.raises(RunCacheNotSupported):
|
||||
assert "failed to push run cache" in caplog.text
|
||||
with caplog.at_level(logging.DEBUG):
|
||||
dvc.pull(run_cache=True)
|
||||
assert "failed to pull run cache" in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user