mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
Fix loading of params from stage cache (#3972)
This commit is contained in:
@@ -80,27 +80,12 @@ class StageCache:
|
||||
def _create_stage(self, cache, wdir=None):
|
||||
from dvc.stage import create_stage, PipelineStage
|
||||
|
||||
params = []
|
||||
for param in cache.get("params", []):
|
||||
if isinstance(param, str):
|
||||
params.append(param)
|
||||
continue
|
||||
|
||||
assert isinstance(param, dict)
|
||||
assert len(param) == 1
|
||||
path = list(param.keys())[0]
|
||||
params_list = param[path]
|
||||
assert isinstance(params_list, list)
|
||||
params.append(f"{path}:" + ",".join(params_list))
|
||||
|
||||
stage = create_stage(
|
||||
PipelineStage,
|
||||
repo=self.repo,
|
||||
path="dvc.yaml",
|
||||
cmd=cache["cmd"],
|
||||
wdir=wdir,
|
||||
params=params,
|
||||
deps=[dep["path"] for dep in cache.get("deps", [])],
|
||||
outs=[out["path"] for out in cache["outs"]],
|
||||
external=True,
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
|
||||
|
||||
def test_stage_cache(tmp_dir, dvc, run_copy, mocker):
|
||||
def test_stage_cache(tmp_dir, dvc, mocker):
|
||||
tmp_dir.gen("dep", "dep")
|
||||
tmp_dir.gen(
|
||||
"script.py",
|
||||
@@ -53,7 +53,7 @@ def test_stage_cache(tmp_dir, dvc, run_copy, mocker):
|
||||
assert (tmp_dir / "out_no_cache").read_text() == "out_no_cache"
|
||||
|
||||
|
||||
def test_stage_cache_params(tmp_dir, dvc, run_copy, mocker):
|
||||
def test_stage_cache_params(tmp_dir, dvc, mocker):
|
||||
tmp_dir.gen("params.yaml", "foo: 1\nbar: 2")
|
||||
tmp_dir.gen("myparams.yaml", "baz: 3\nqux: 4")
|
||||
tmp_dir.gen(
|
||||
@@ -106,7 +106,7 @@ def test_stage_cache_params(tmp_dir, dvc, run_copy, mocker):
|
||||
assert (tmp_dir / "out_no_cache").read_text() == "out_no_cache"
|
||||
|
||||
|
||||
def test_stage_cache_wdir(tmp_dir, dvc, run_copy, mocker):
|
||||
def test_stage_cache_wdir(tmp_dir, dvc, mocker):
|
||||
tmp_dir.gen("dep", "dep")
|
||||
tmp_dir.gen(
|
||||
"script.py",
|
||||
|
||||
Reference in New Issue
Block a user