MCPcopy
hub / github.com/treeverse/dvc / test_params_dump

Function test_params_dump

tests/func/test_lockfile.py:109–157  ·  view source on GitHub ↗
(tmp_dir, dvc, run_head)

Source from the content-addressed store, hash-verified

107
108
109def test_params_dump(tmp_dir, dvc, run_head):
110 tmp_dir.gen(FS_STRUCTURE)
111
112 stage = run_head(
113 "foo",
114 "bar",
115 "foobar",
116 name="copy-first-line",
117 params=[
118 "params2.yaml:answer,lists,name",
119 "params.yaml:lists,floats,nested.nested1,nested.nested1.nested2",
120 ],
121 )
122
123 initial_content = read_lock_file()
124 lock = initial_content["stages"]["copy-first-line"]
125
126 # lock stage key order:
127 assert list(lock.keys()) == ["cmd", "deps", "params", "outs"]
128 assert list(lock["params"].keys()) == ["params.yaml", "params2.yaml"]
129
130 # # params keys are always sorted by the name
131 assert list(lock["params"]["params.yaml"].keys()) == [
132 "floats",
133 "lists",
134 "nested.nested1",
135 "nested.nested1.nested2",
136 ]
137 assert list(lock["params"]["params2.yaml"]) == ["answer", "lists", "name"]
138
139 assert not dvc.reproduce(stage.addressing)
140
141 # let's change the order of params and dump them in pipeline file
142 params, _ = split_params_deps(stage)
143 for param in params:
144 param.params.reverse()
145
146 stage.dvcfile._dump_pipeline_file(stage)
147 assert not dvc.reproduce(stage.addressing)
148
149 (tmp_dir / LOCK_FILE).unlink()
150 assert dvc.reproduce(stage.addressing) == [stage]
151 assert_eq_lockfile(initial_content, read_lock_file())
152
153 # remove build-cache and check if the same structure is built
154 for item in [dvc.stage_cache.cache_dir, LOCK_FILE]:
155 remove(item)
156 assert dvc.reproduce(stage.addressing) == [stage]
157 assert_eq_lockfile(initial_content, read_lock_file())

Callers

nothing calls this directly

Calls 10

split_params_depsFunction · 0.90
removeFunction · 0.90
run_headFunction · 0.85
read_lock_fileFunction · 0.85
assert_eq_lockfileFunction · 0.85
keysMethod · 0.80
_dump_pipeline_fileMethod · 0.80
unlinkMethod · 0.80
genMethod · 0.45
reproduceMethod · 0.45

Tested by

no test coverage detected