Skip to content

Commit

Permalink
dvc.yaml: preserve outputs' desc on rewrites/updates to the stage (#8247
Browse files Browse the repository at this point in the history
)

preserve outputs' desc on rewrites/updates to the stage

We were not loading `desc` of the output, due to which we were not preserving the desc field over rewrites. Note that the rewrite only happens in select commands for `dvc.yaml`: `freeze`/`unfreeze`/`run`/`stage-add`, so we did not notice this before.
  • Loading branch information
skshetry committed Sep 5, 2022
1 parent 65dc1cd commit 0b2b59a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions dvc/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def load_from_pipeline(stage, data, typ="outs"):
Output.PARAM_PERSIST,
Output.PARAM_CHECKPOINT,
Output.PARAM_REMOTE,
Output.PARAM_DESC,
],
)

Expand Down
24 changes: 24 additions & 0 deletions tests/func/test_dvcfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,27 @@ def test_dvcfile_try_dumping_parametrized_stage(tmp_dir, dvc, data, name):
dvcfile.dump(stage)

assert str(exc.value) == f"cannot dump a parametrized stage: '{name}'"


def test_dvcfile_load_dump_stage_with_desc_meta(tmp_dir, dvc):
data = {
"stages": {
"stage1": {
"cmd": "cp foo bar",
"desc": "stage desc",
"meta": {"key1": "value1", "key2": "value2"},
"deps": ["foo"],
"outs": [{"bar": {"desc": "bar desc"}}],
}
}
}
(tmp_dir / "dvc.yaml").dump(data)

stage = dvc.stage.load_one(name="stage1")
assert stage.meta == {"key1": "value1", "key2": "value2"}
assert stage.desc == "stage desc"
assert stage.outs[0].desc == "bar desc"

# sanity check
stage.dump()
assert (tmp_dir / "dvc.yaml").parse() == data

0 comments on commit 0b2b59a

Please sign in to comment.