Fix loading of params from stage cache (#3972)

This commit is contained in:
Saugat Pachhai
2020-06-08 12:43:13 +03:00
committed by GitHub
parent b7c174641e
commit ae7b604531
2 changed files with 3 additions and 18 deletions
-15
View File
@@ -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,
)
+3 -3
View File
@@ -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",