mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
output: Pass version_aware=True to fs if files is present.
This will be ignored by filesystems that don't support `version_aware`. Closes #8853
This commit is contained in:
+3
-1
@@ -327,7 +327,9 @@ class Output:
|
||||
meta = Meta.from_dict(info or {})
|
||||
# NOTE: when version_aware is not passed into get_cloud_fs, it will be
|
||||
# set based on whether or not path is versioned
|
||||
fs_kwargs = {"version_aware": True} if meta.version_id else {}
|
||||
fs_kwargs = {}
|
||||
if meta.version_id or files:
|
||||
fs_kwargs["version_aware"] = True
|
||||
|
||||
if fs_config is not None:
|
||||
fs_kwargs.update(**fs_config)
|
||||
|
||||
@@ -176,3 +176,30 @@ def test_dumpd_cloud_versioning_dir(mocker):
|
||||
|
||||
dumpd = out.dumpd()
|
||||
assert dumpd == {"path": "path", "files": files}
|
||||
|
||||
|
||||
def test_version_aware_is_set_based_on_files(mocker):
|
||||
import dvc.fs as dvc_fs
|
||||
|
||||
get_fs_config = mocker.spy(dvc_fs, "get_fs_config")
|
||||
|
||||
stage = mocker.MagicMock()
|
||||
stage.repo.fs.version_aware = False
|
||||
stage.repo.fs.PARAM_CHECKSUM = "etag"
|
||||
files = [
|
||||
{
|
||||
"size": 3,
|
||||
"version_id": "WYRG4BglP7pD.gEoJP6a4AqOhl.FRA.h",
|
||||
"etag": "acbd18db4cc2f85cedef654fccc4a4d8",
|
||||
"md5": "acbd18db4cc2f85cedef654fccc4a4d8",
|
||||
"relpath": "bar",
|
||||
}
|
||||
]
|
||||
Output(stage, "path", files=files)
|
||||
# version_aware is passed as `True` if `files` is present`.
|
||||
# This will be intentionally ignored in filesystems that don't handle it
|
||||
# in `_prepare_credentials`.
|
||||
assert get_fs_config.call_args_list[0][1] == {
|
||||
"url": "path",
|
||||
"version_aware": True,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user