diff --git a/dvc/repo/fetch.py b/dvc/repo/fetch.py index 05f92921d0..047a45f9c9 100644 --- a/dvc/repo/fetch.py +++ b/dvc/repo/fetch.py @@ -2,6 +2,7 @@ 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 diff --git a/dvc/repo/push.py b/dvc/repo/push.py index 202827c836..acf31573ce 100644 --- a/dvc/repo/push.py +++ b/dvc/repo/push.py @@ -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] diff --git a/tests/func/test_run_cache.py b/tests/func/test_run_cache.py index a8669e88bd..495e64c838 100644 --- a/tests/func/test_run_cache.py +++ b/tests/func/test_run_cache.py @@ -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