dvcfile: serialize params on --no-exec (#3859)

* dvc.yaml: don't generate lockfile on --no-exec

* dvcfile: serialize params on --no-exec

Fixes #3851
This commit is contained in:
Ruslan Kuprieiev
2020-05-23 03:19:38 +03:00
committed by GitHub
parent 3e951162b8
commit 2fba2e030a
4 changed files with 66 additions and 8 deletions
+47
View File
@@ -19,6 +19,30 @@ def test_run_with_name(tmp_dir, dvc, run_copy):
assert os.path.exists(PIPELINE_LOCK)
def test_run_no_exec(tmp_dir, dvc, run_copy):
from dvc.stage import PipelineStage
from dvc.dvcfile import PIPELINE_FILE, PIPELINE_LOCK
tmp_dir.dvc_gen("foo", "foo")
assert not os.path.exists(PIPELINE_FILE)
stage = run_copy("foo", "bar", name="copy-foo-to-bar", no_exec=True)
assert isinstance(stage, PipelineStage)
assert stage.name == "copy-foo-to-bar"
assert os.path.exists(PIPELINE_FILE)
assert not os.path.exists(PIPELINE_LOCK)
data, _ = stage.dvcfile._load()
assert data == {
"stages": {
"copy-foo-to-bar": {
"cmd": "python copy.py foo bar",
"deps": ["copy.py", "foo"],
"outs": ["bar"],
}
}
}
def test_run_with_multistage_and_single_stage(tmp_dir, dvc, run_copy):
from dvc.stage import PipelineStage, Stage
@@ -252,3 +276,26 @@ def test_run_params_custom_file(tmp_dir, dvc):
assert data["stages"]["read_params"]["params"] == [
{"params2.yaml": ["lists"]}
]
def test_run_params_no_exec(tmp_dir, dvc):
from dvc.dependency import ParamsDependency
with (tmp_dir / "params2.yaml").open("w+") as f:
yaml.dump(supported_params, f)
stage = dvc.run(
name="read_params",
params=["params2.yaml:lists"],
cmd="cat params2.yaml",
no_exec=True,
)
isinstance(stage.deps[0], ParamsDependency)
assert stage.deps[0].params == ["lists"]
assert not stage.dvcfile._lockfile.exists()
data, _ = stage.dvcfile._load()
assert data["stages"]["read_params"]["params"] == [
{"params2.yaml": ["lists"]}
]