run-cache: http: stage cache uploads in http remotes

Currently, there is no way to find run-cache in HTTP remotes.
In the future, we could use directory-listings from supported
webservers to find files.
Temporarily, we are restricting the run-cache uploads. This is a bit
strict, we could have only restricted the downloads, but it might be
more confusing to the users, so I went to categorically restrict
stage cache uploads and downloads for http filesystems.
This commit is contained in:
Saugat Pachhai (सौगात)
2022-06-12 13:49:56 +03:00
committed by Ruslan Kuprieiev
parent e6db6ffc89
commit d30dbd50bc
2 changed files with 22 additions and 1 deletions
+18 -1
View File
@@ -22,6 +22,10 @@ class RunCacheNotFoundError(DvcException):
super().__init__(f"No run-cache for {stage.addressing}")
class RunCacheNotSupported(DvcException):
pass
def _get_cache_hash(cache, key=False):
from dvc_objects.meta import Meta
@@ -213,7 +217,7 @@ class StageCache:
cached_stage.checkout()
def transfer(self, from_odb, to_odb):
from dvc.fs import LocalFileSystem
from dvc.fs import HTTPFileSystem, LocalFileSystem
from dvc.fs.callbacks import Callback
from_fs = from_odb.fs
@@ -221,6 +225,19 @@ class StageCache:
func = _log_exceptions(fs.generic.copy)
runs = from_fs.path.join(from_odb.fs_path, "runs")
http_odb = next(
(
odb
for odb in (from_odb, to_odb)
if isinstance(odb.fs, HTTPFileSystem)
),
None,
)
if http_odb:
path = http_odb.fs_path
message = f"run-cache is not supported for http filesystem: {path}"
raise RunCacheNotSupported(message)
ret = []
if not from_fs.exists(runs):
return ret
+4
View File
@@ -1,6 +1,9 @@
import os
import shutil
import pytest
from dvc.stage.cache import RunCacheNotSupported
from dvc.utils.fs import remove
@@ -92,6 +95,7 @@ class TestRemote:
status_dir = dvc.cloud.status(dir_hashes)
_check_status(status_dir, ok=dir_hashes)
@pytest.mark.xfail(raises=RunCacheNotSupported, strict=False)
def test_stage_cache_push_pull(self, tmp_dir, dvc, remote):
tmp_dir.gen("foo", "foo")
stage = dvc.stage.add(