nit: fit statement/expr in the same line instead of hanging (#10267)

The code are wrapped due to us using line-length=79 before, but now some
of the code can easily fit in 88 chars.

The formatter did not change this automatically when we changed line-length,
because of magic trailing commas that gets added when they turn into multiple lines.

Black/ruff wrapping them in parens and splitting them into multiple lines
was making it difficult to read.
This commit is contained in:
skshetry
2024-01-30 18:23:04 +05:45
committed by GitHub
parent 422caa13c4
commit 9a1bcd7f1d
144 changed files with 342 additions and 1707 deletions
+9 -45
View File
@@ -31,38 +31,15 @@ def params_repo(tmp_dir, scm, dvc):
tmp_dir.gen("params.json", '{"bar": 2, "foobar": 3}')
tmp_dir.gen("other_params.json", '{"foo": {"bar": 4}}')
dvc.run(
name="stage-0",
cmd="echo stage-0",
)
dvc.run(name="stage-0", cmd="echo stage-0")
dvc.run(
name="stage-1",
cmd="echo stage-1",
params=["foo", "params.json:bar"],
)
dvc.run(name="stage-1", cmd="echo stage-1", params=["foo", "params.json:bar"])
dvc.run(
name="stage-2",
cmd="echo stage-2",
params=["other_params.json:foo"],
)
dvc.run(name="stage-2", cmd="echo stage-2", params=["other_params.json:foo"])
dvc.run(
name="stage-3",
cmd="echo stage-2",
params=["params.json:foobar"],
)
dvc.run(name="stage-3", cmd="echo stage-2", params=["params.json:foobar"])
scm.add(
[
"params.yaml",
"params.json",
"other_params.json",
"dvc.yaml",
"dvc.lock",
]
)
scm.add(["params.yaml", "params.json", "other_params.json", "dvc.yaml", "dvc.lock"])
scm.commit("commit dvc files")
tmp_dir.gen("params.yaml", "foo: 5")
@@ -77,10 +54,7 @@ def metrics_repo(tmp_dir, scm, dvc, run_copy_metrics):
scm.commit("prepare data")
sub_dir = tmp_dir / "eval"
sub_dir.mkdir()
tmp_dir.gen(
"tmp_train_val_metrics.json",
json.dumps(TRAIN_METRICS[0]),
)
tmp_dir.gen("tmp_train_val_metrics.json", json.dumps(TRAIN_METRICS[0]))
train_metrics_file = os.path.join(sub_dir, "train_val_metrics.json")
run_copy_metrics(
"tmp_train_val_metrics.json",
@@ -107,10 +81,7 @@ def metrics_repo(tmp_dir, scm, dvc, run_copy_metrics):
scm.commit("test model")
with tmp_dir.branch("better-model", new=True):
tmp_dir.gen(
"tmp_train_val_metrics.json",
json.dumps(TRAIN_METRICS[1]),
)
tmp_dir.gen("tmp_train_val_metrics.json", json.dumps(TRAIN_METRICS[1]))
run_copy_metrics(
"tmp_train_val_metrics.json",
train_metrics_file,
@@ -243,11 +214,7 @@ def test_params_show_while_running_stage(tmp_dir, dvc):
def test_params_show_repo(tmp_dir, erepo_dir):
with erepo_dir.chdir():
erepo_dir.scm_gen("params.yaml", "foo: 1", commit="Create params.yaml")
erepo_dir.dvc.run(
name="stage-1",
cmd="echo stage-1",
params=["foo"],
)
erepo_dir.dvc.run(name="stage-1", cmd="echo stage-1", params=["foo"])
assert api.params_show(repo=erepo_dir) == {"foo": 1}
@@ -268,10 +235,7 @@ def test_params_show_no_params_found(tmp_dir, dvc):
def test_params_show_stage_without_params(tmp_dir, dvc):
tmp_dir.gen("params.yaml", "foo: 1")
dvc.run(
name="stage-0",
cmd="echo stage-0",
)
dvc.run(name="stage-0", cmd="echo stage-0")
assert api.params_show(stages="stage-0") == {}
+3 -18
View File
@@ -70,9 +70,7 @@ def test_artifacts_add_subdir(tmp_dir, dvc):
name: Artifact(**values) for name, values in dvcyaml["artifacts"].items()
}
artifacts["new"] = new_art
assert tmp_dir.dvc.artifacts.read() == {
f"subdir{os.path.sep}dvc.yaml": artifacts,
}
assert tmp_dir.dvc.artifacts.read() == {f"subdir{os.path.sep}dvc.yaml": artifacts}
def test_artifacts_add_abspath(tmp_dir, dvc):
@@ -114,11 +112,7 @@ bad_dvcyaml_extra_field = {
}
bad_dvcyaml_missing_path = {
"artifacts": {
"lol": {},
}
}
bad_dvcyaml_missing_path = {"artifacts": {"lol": {}}}
@pytest.mark.parametrize(
@@ -148,16 +142,7 @@ def test_artifacts_read_fails_on_id_duplication(tmp_dir, dvc):
@pytest.mark.parametrize(
"name",
[
"1",
"m",
"nn",
"m1",
"1nn",
"model-prod",
"model-prod-v1",
],
"name", ["1", "m", "nn", "m1", "1nn", "model-prod", "model-prod-v1"]
)
def test_name_is_compatible(name):
check_name_format(name)
+1 -5
View File
@@ -34,10 +34,6 @@ def params_repo(tmp_dir, scm, dvc):
(tmp_dir / "params.yaml").dump(
{"foo": [{"bar": 1}, {"baz": 2}], "goo": {"bag": 3.0}, "lorem": False}
)
dvc.run(
cmd="echo foo",
params=["params.yaml:"],
name="foo",
)
dvc.run(cmd="echo foo", params=["params.yaml:"], name="foo")
scm.add(["dvc.yaml", "dvc.lock", "copy.py", "params.yaml"])
scm.commit("init")
+1 -5
View File
@@ -46,11 +46,7 @@ def test_apply_failed(tmp_dir, scm, dvc, failed_exp_stage, mocker):
),
],
)
mocker.patch.object(
queue,
"iter_queued",
return_value=[],
)
mocker.patch.object(queue, "iter_queued", return_value=[])
dvc.experiments.apply(exp_rev)
assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 3"
+8 -41
View File
@@ -100,14 +100,7 @@ def test_file_permissions(tmp_dir, scm, dvc, exp_stage, mocker):
assert stat.S_IMODE(os.stat(tmp_dir / "copy.py").st_mode) == mode
def test_failed_exp_workspace(
tmp_dir,
scm,
dvc,
failed_exp_stage,
mocker,
capsys,
):
def test_failed_exp_workspace(tmp_dir, scm, dvc, failed_exp_stage, mocker, capsys):
tmp_dir.gen("params.yaml", "foo: 2")
with pytest.raises(ReproductionError):
dvc.experiments.run(failed_exp_stage.addressing)
@@ -445,13 +438,7 @@ def test_subrepo(tmp_dir, request, scm, workspace):
name="copy-file",
no_exec=True,
)
scm.add(
[
subrepo / "dvc.yaml",
subrepo / "copy.py",
subrepo / "params.yaml",
]
)
scm.add([subrepo / "dvc.yaml", subrepo / "copy.py", subrepo / "params.yaml"])
scm.commit("init")
results = subrepo.dvc.experiments.run(
@@ -593,11 +580,7 @@ def test_experiment_name_invalid(tmp_dir, scm, dvc, exp_stage, mocker):
new_mock = mocker.spy(BaseStashQueue, "_stash_exp")
with pytest.raises(InvalidArgumentError):
dvc.experiments.run(
exp_stage.addressing,
name="fo^o",
params=["foo=3"],
)
dvc.experiments.run(exp_stage.addressing, name="fo^o", params=["foo=3"])
new_mock.assert_not_called()
@@ -651,10 +634,7 @@ def test_run_env(tmp_dir, dvc, scm, mocker):
)
(tmp_dir / "dump_run_env.py").write_text(dump_run_env)
baseline = scm.get_rev()
dvc.stage.add(
cmd="python dump_run_env.py",
name="run_env",
)
dvc.stage.add(cmd="python dump_run_env.py", name="run_env")
dvc.experiments.run()
assert (tmp_dir / DVC_EXP_BASELINE_REV).read_text().strip() == baseline
assert (tmp_dir / DVC_EXP_NAME).read_text().strip()
@@ -728,11 +708,7 @@ def test_local_config_is_propagated_to_tmp(tmp_dir, scm, dvc):
@pytest.mark.parametrize("tmp", [True, False])
def test_untracked_top_level_files_are_included_in_exp(tmp_dir, scm, dvc, tmp):
(tmp_dir / "dvc.yaml").dump(
{
"metrics": ["metrics.json"],
"params": ["params.yaml"],
"plots": ["plots.csv"],
}
{"metrics": ["metrics.json"], "params": ["params.yaml"], "plots": ["plots.csv"]}
)
stage = dvc.stage.add(
cmd="touch metrics.json && touch params.yaml && touch plots.csv",
@@ -748,10 +724,7 @@ def test_untracked_top_level_files_are_included_in_exp(tmp_dir, scm, dvc, tmp):
@pytest.mark.parametrize("tmp", [True, False])
def test_copy_paths(tmp_dir, scm, dvc, tmp):
stage = dvc.stage.add(
cmd="cat file && ls dir",
name="foo",
)
stage = dvc.stage.add(cmd="cat file && ls dir", name="foo")
scm.add_commit(["dvc.yaml"], message="add dvc.yaml")
(tmp_dir / "dir").mkdir()
@@ -770,10 +743,7 @@ def test_copy_paths(tmp_dir, scm, dvc, tmp):
def test_copy_paths_errors(tmp_dir, scm, dvc, mocker):
stage = dvc.stage.add(
cmd="echo foo",
name="foo",
)
stage = dvc.stage.add(cmd="echo foo", name="foo")
scm.add_commit(["dvc.yaml"], message="add dvc.yaml")
with pytest.raises(DvcException, match="Unable to copy"):
@@ -814,10 +784,7 @@ def test_mixed_git_dvc_out(tmp_dir, scm, dvc, exp_stage):
@pytest.mark.parametrize("tmp", [True, False])
def test_custom_commit_message(tmp_dir, scm, dvc, tmp):
stage = dvc.stage.add(
cmd="echo foo",
name="foo",
)
stage = dvc.stage.add(cmd="echo foo", name="foo")
scm.add_commit(["dvc.yaml"], message="add dvc.yaml")
exp = first(
+4 -24
View File
@@ -10,15 +10,7 @@ def to_dict(tasks):
@pytest.mark.parametrize("follow", [True, False])
def test_celery_logs(
tmp_dir,
scm,
dvc,
failed_exp_stage,
follow,
capsys,
test_queue,
):
def test_celery_logs(tmp_dir, scm, dvc, failed_exp_stage, follow, capsys, test_queue):
celery_queue = dvc.experiments.celery_queue
dvc.experiments.run(failed_exp_stage.addressing, queue=True, name="foo")
dvc.experiments.run(run_all=True)
@@ -37,23 +29,14 @@ def test_queue_doesnt_remove_untracked_params_file(tmp_dir, dvc, scm):
"""Regression test for https://github.com/iterative/dvc/issues/7842"""
tmp_dir.gen("params.yaml", "foo: 1")
stage = dvc.run(cmd="echo ${foo}", params=["foo"], name="echo-foo")
scm.add(
[
"dvc.yaml",
"dvc.lock",
".gitignore",
]
)
scm.add(["dvc.yaml", "dvc.lock", ".gitignore"])
scm.commit("init")
dvc.experiments.run(stage.addressing, params=["foo=2"], queue=True)
assert (tmp_dir / "params.yaml").exists()
def test_copy_paths_queue(tmp_dir, scm, dvc):
stage = dvc.stage.add(
cmd="cat file && ls dir",
name="foo",
)
stage = dvc.stage.add(cmd="cat file && ls dir", name="foo")
scm.add_commit(["dvc.yaml"], message="add dvc.yaml")
(tmp_dir / "dir").mkdir()
@@ -72,10 +55,7 @@ def test_copy_paths_queue(tmp_dir, scm, dvc):
def test_custom_commit_message_queue(tmp_dir, scm, dvc):
stage = dvc.stage.add(
cmd="echo foo",
name="foo",
)
stage = dvc.stage.add(cmd="echo foo", name="foo")
scm.add_commit(["dvc.yaml"], message="add dvc.yaml")
dvc.experiments.run(stage.addressing, queue=True, message="custom commit message")
+1 -5
View File
@@ -356,11 +356,7 @@ def test_get(tmp_dir, scm, dvc, exp_stage, erepo_dir, use_ref):
exp_ref = first(exp_refs_by_rev(scm, exp_rev))
with erepo_dir.chdir():
Repo.get(
str(tmp_dir),
"params.yaml",
rev=exp_ref.name if use_ref else exp_rev,
)
Repo.get(str(tmp_dir), "params.yaml", rev=exp_ref.name if use_ref else exp_rev)
assert (erepo_dir / "params.yaml").read_text().strip() == "foo: 2"
+2 -9
View File
@@ -121,11 +121,7 @@ def test_exp_save_include_untracked_warning(tmp_dir, dvc, scm, mocker):
def test_untracked_top_level_files_are_included_in_exp(tmp_dir, scm, dvc):
(tmp_dir / "dvc.yaml").dump(
{
"metrics": ["metrics.json"],
"params": ["params.yaml"],
"plots": ["plots.csv"],
}
{"metrics": ["metrics.json"], "params": ["params.yaml"], "plots": ["plots.csv"]}
)
stage = dvc.stage.add(
cmd="touch metrics.json && touch params.yaml && touch plots.csv",
@@ -140,10 +136,7 @@ def test_untracked_top_level_files_are_included_in_exp(tmp_dir, scm, dvc):
def test_untracked_dvclock_is_included_in_exp(tmp_dir, scm, dvc):
stage = dvc.stage.add(
cmd="echo foo",
name="foo",
)
stage = dvc.stage.add(cmd="echo foo", name="foo")
scm.add_commit(["dvc.yaml"], message="add dvc.yaml")
dvc.reproduce(stage.addressing)
+1 -5
View File
@@ -103,11 +103,7 @@ def test_hydra_sweep(
patched = mocker.patch.object(dvc.experiments, "queue_one")
if hydra_enabled:
hydra_setup(
tmp_dir,
config_dir="conf",
config_name="config",
)
hydra_setup(tmp_dir, config_dir="conf", config_name="config")
with dvc.config.edit() as conf:
conf["hydra"]["enabled"] = True
+9 -47
View File
@@ -49,11 +49,7 @@ def make_executor(local=None, **kwargs):
local_executor.update(local)
else:
local_executor = ANY
data = {
"state": ANY,
"local": local_executor,
"name": ANY,
}
data = {"state": ANY, "local": local_executor, "name": ANY}
data.update(kwargs)
return data
@@ -62,13 +58,7 @@ def make_data(params=None, **kwargs):
params = {"data": params or {"foo": 1}}
data = {
"rev": ANY,
"deps": {
"copy.py": {
"hash": ANY,
"size": ANY,
"nfiles": None,
}
},
"deps": {"copy.py": {"hash": ANY, "size": ANY, "nfiles": None}},
"metrics": {"metrics.yaml": params},
"outs": {},
"params": {"params.yaml": params},
@@ -233,23 +223,14 @@ def test_show_failed_experiment(tmp_dir, scm, dvc, failed_exp_stage, test_queue)
"experiments": None,
}
],
"executor": make_executor(
state="failed",
local={"returncode": 255},
),
"executor": make_executor(state="failed", local={"returncode": 255}),
"name": ANY,
}
],
}
def test_show_filter(
tmp_dir,
scm,
dvc,
capsys,
copy_script,
):
def test_show_filter(tmp_dir, scm, dvc, capsys, copy_script):
capsys.readouterr()
params_file = tmp_dir / "params.yaml"
@@ -487,10 +468,7 @@ def test_show_csv(tmp_dir, scm, dvc, exp_stage, capsys):
def test_show_only_changed(tmp_dir, dvc, scm, capsys, copy_script):
params_file = tmp_dir / "params.yaml"
params_data = {
"foo": 1,
"goobar": 1,
}
params_data = {"foo": 1, "goobar": 1}
(tmp_dir / params_file).dump(params_data)
dvc.run(
@@ -534,10 +512,7 @@ def test_show_only_changed(tmp_dir, dvc, scm, capsys, copy_script):
@pytest.mark.vscode
def test_show_outs(tmp_dir, dvc, scm, erepo_dir, copy_script):
params_file = tmp_dir / "params.yaml"
params_data = {
"foo": 1,
"bar": 1,
}
params_data = {"foo": 1, "bar": 1}
(tmp_dir / params_file).dump(params_data)
dvc.run(
@@ -641,9 +616,7 @@ def test_show_outs(tmp_dir, dvc, scm, erepo_dir, copy_script):
def test_metrics_renaming(tmp_dir, dvc, scm, capsys, copy_script):
params_file = tmp_dir / "params.yaml"
params_data = {
"foo": 1,
}
params_data = {"foo": 1}
(tmp_dir / params_file).dump(params_data)
dvc.run(
@@ -674,14 +647,7 @@ def test_metrics_renaming(tmp_dir, dvc, scm, capsys, copy_script):
name="copy-file",
deps=["copy.py"],
)
scm.add(
[
"dvc.yaml",
"dvc.lock",
"params.yaml",
"scores.yaml",
]
)
scm.add(["dvc.yaml", "dvc.lock", "params.yaml", "scores.yaml"])
scm.commit("scores.yaml")
scores_rev = scm.get_rev()
@@ -709,11 +675,7 @@ def test_show_sorted_deps(tmp_dir, dvc, scm, capsys):
tmp_dir.gen("c", "c")
tmp_dir.gen("z", "z")
dvc.run(
cmd="echo foo",
name="deps",
deps=["a", "b", "z", "c"],
)
dvc.run(cmd="echo foo", name="deps", deps=["a", "b", "z", "c"])
capsys.readouterr()
assert main(["exp", "show", "--csv"]) == 0
+3 -13
View File
@@ -9,11 +9,7 @@ from dvc.exceptions import ReproductionError
@pytest.mark.parametrize("staged", [True, False])
def test_deleted(tmp_dir, scm, dvc, tmp, staged):
tmp_dir.scm_gen("file", "file", commit="commit file")
stage = dvc.stage.add(
cmd="cat file",
deps=["file"],
name="foo",
)
stage = dvc.stage.add(cmd="cat file", deps=["file"], name="foo")
scm.add_commit(["dvc.yaml"], message="add dvc.yaml")
file = tmp_dir / "file"
@@ -33,10 +29,7 @@ def test_deleted(tmp_dir, scm, dvc, tmp, staged):
@pytest.mark.parametrize("staged", [True, False])
def test_modified(tmp_dir, scm, dvc, caplog, tmp, staged):
tmp_dir.scm_gen("file", "file", commit="commit file")
stage = dvc.stage.add(
cmd="cat file",
name="foo",
)
stage = dvc.stage.add(cmd="cat file", name="foo")
scm.add_commit(["dvc.yaml"], message="add dvc.yaml")
(tmp_dir / "file").write_text("modified_file")
@@ -52,10 +45,7 @@ def test_modified(tmp_dir, scm, dvc, caplog, tmp, staged):
@pytest.mark.parametrize("tmp", [True, False])
def test_staged_new_file(tmp_dir, scm, dvc, tmp):
stage = dvc.stage.add(
cmd="cat file",
name="foo",
)
stage = dvc.stage.add(cmd="cat file", name="foo")
scm.add_commit(["dvc.yaml"], message="add dvc.yaml")
(tmp_dir / "file").write_text("file")
+1 -10
View File
@@ -3,16 +3,7 @@ from funcy import first
def test_generate_random_exp_name(tmp_dir, dvc, scm, exp_stage, mocker):
mocked_generator = mocker.MagicMock()
mocked_generator.choice.side_effect = [
0,
0,
0,
0,
1,
1,
0,
0,
]
mocked_generator.choice.side_effect = [0, 0, 0, 0, 1, 1, 0, 0]
mocker.patch(
"dvc.repo.experiments.utils.random.Random", return_value=mocked_generator
)
+2 -11
View File
@@ -160,13 +160,7 @@ def test_missing_cache(tmp_dir, dvc, run_copy_metrics):
result = dvc.metrics.show()
metrics2 = result[""]["data"].pop("metrics2.yaml")
assert isinstance(metrics2["error"], FileNotFoundError)
assert result == {
"": {
"data": {
"metrics.yaml": {"data": 1.1},
}
}
}
assert result == {"": {"data": {"metrics.yaml": {"data": 1.1}}}}
@pytest.mark.parametrize("use_dvc", [True, False])
@@ -276,10 +270,7 @@ def test_metrics_show_overlap(tmp_dir, dvc, run_copy_metrics, clear_before_run):
)
with (tmp_dir / "dvc.yaml").modify() as d:
# trying to make an output overlaps error
d["stages"]["corrupted-stage"] = {
"cmd": "mkdir data",
"outs": ["data"],
}
d["stages"]["corrupted-stage"] = {"cmd": "mkdir data", "outs": ["data"]}
# running by clearing and not clearing stuffs
# so as it works even for optimized cases
+1 -5
View File
@@ -238,11 +238,7 @@ def test_diff_targeted(tmp_dir, scm, dvc, run_copy):
def test_diff_without_targets_specified(tmp_dir, dvc, scm, file):
params_file = tmp_dir / file
params_file.dump({"foo": {"bar": "bar"}, "x": "0"})
dvc.stage.add(
name="test",
cmd=f"echo {file}",
params=[{file: None}],
)
dvc.stage.add(name="test", cmd=f"echo {file}", params=[{file: None}])
scm.add_commit([params_file, "dvc.yaml"], message="foo")
params_file.dump({"foo": {"bar": "baz"}, "y": "100"})
+1 -5
View File
@@ -123,11 +123,7 @@ def test_show_without_targets_specified(tmp_dir, dvc, scm, file):
params_file = tmp_dir / file
data = {"foo": {"bar": "bar"}, "x": "0"}
params_file.dump(data)
dvc.stage.add(
name="test",
cmd=f"echo {file}",
params=[{file: None}],
)
dvc.stage.add(name="test", cmd=f"echo {file}", params=[{file: None}])
assert dvc.params.show() == {"": {"data": {file: {"data": data}}}}
+1 -3
View File
@@ -71,9 +71,7 @@ def test_load_vars_with_relpath(tmp_dir, scm, dvc):
revisions = ["HEAD", "workspace"]
for rev in dvc.brancher(revs=["HEAD"]):
assert rev == revisions.pop()
d = {
"vars": [f"../{DEFAULT_PARAMS_FILE}"],
}
d = {"vars": [f"../{DEFAULT_PARAMS_FILE}"]}
resolver = DataResolver(dvc, "subdir", d)
assert resolver.context == deepcopy(DATA)
+2 -10
View File
@@ -155,10 +155,7 @@ def test_plots_show_overlap(tmp_dir, dvc, run_copy_metrics, clear_before_run):
)
with (tmp_dir / "dvc.yaml").modify() as d:
# trying to make an output overlaps error
d["stages"]["corrupted-stage"] = {
"cmd": "mkdir data",
"outs": ["data"],
}
d["stages"]["corrupted-stage"] = {"cmd": "mkdir data", "outs": ["data"]}
# running by clearing and not clearing stuffs
# so as it works even for optimized cases
@@ -356,12 +353,7 @@ def test_collect_non_existing_dir(tmp_dir, dvc, run_copy_metrics):
),
],
)
def test_top_level_plots(
tmp_dir,
dvc,
plot_config,
expected_datafiles,
):
def test_top_level_plots(tmp_dir, dvc, plot_config, expected_datafiles):
data = {
"data1.json": [
{"a": 1, "b": 0.1, "c": 0.01},
+25 -121
View File
@@ -364,10 +364,7 @@ def test_repro_multiple_params(tmp_dir, dvc):
name="read_params",
deps=["foo"],
outs=["bar"],
params=[
"params2.yaml:lists,floats,name",
"answer,floats,nested.nested1",
],
params=["params2.yaml:lists,floats,name", "answer,floats,nested.nested1"],
cmd="cat params2.yaml params.yaml > bar",
)
@@ -528,11 +525,7 @@ def test_repro_skip_pull_if_no_run_cache_is_passed(tmp_dir, dvc, mocker, local_r
assert not spy_pull.called
def test_repro_no_commit(
tmp_dir,
dvc,
copy_script,
):
def test_repro_no_commit(tmp_dir, dvc, copy_script):
tmp_dir.gen("bar", "bar")
tmp_dir.dvc_gen("foo", "foo")
stage = dvc.run(
@@ -548,16 +541,9 @@ def test_repro_no_commit(
assert not os.path.isdir(dvc.cache.local.path)
def test_repro_all_pipelines(
mocker,
dvc,
):
def test_repro_all_pipelines(mocker, dvc):
stages = [
dvc.run(
outs=["start.txt"],
cmd="echo start > start.txt",
name="start",
),
dvc.run(outs=["start.txt"], cmd="echo start > start.txt", name="start"),
dvc.run(
deps=["start.txt"],
outs=["middle.txt"],
@@ -588,10 +574,7 @@ def test_repro_all_pipelines(
class TestReproAlreadyCached:
def test(
self,
dvc,
):
def test(self, dvc):
stage = dvc.run(
always_changed=True,
deps=[],
@@ -604,11 +587,7 @@ class TestReproAlreadyCached:
assert run_out.hash_info != repro_out.hash_info
def test_force_with_dependencies(
self,
tmp_dir,
dvc,
):
def test_force_with_dependencies(self, tmp_dir, dvc):
tmp_dir.dvc_gen("foo", "foo")
stage = dvc.run(
name="datetime",
@@ -654,11 +633,7 @@ def test_repro_shell(tmp_dir, monkeypatch, dvc):
assert (tmp_dir / "shell.txt").read_text().rstrip() == shell
def test_cmd_repro(
tmp_dir,
dvc,
copy_script,
):
def test_cmd_repro(tmp_dir, dvc, copy_script):
tmp_dir.gen("bar", "bar")
tmp_dir.dvc_gen("foo", "foo")
stage = dvc.run(
@@ -679,11 +654,7 @@ def test_cmd_repro(
assert ret != 0
def test_repro_dep_under_dir(
tmp_dir,
dvc,
copy_script,
):
def test_repro_dep_under_dir(tmp_dir, dvc, copy_script):
tmp_dir.gen("foo", "foo")
tmp_dir.dvc_gen("data", {"file": "file", "sub": {"foo": "foo"}})
@@ -741,11 +712,7 @@ def test_repro_force(tmp_dir, dvc, copy_script):
assert len(stages) == 2
def test_repro_changed_code(
tmp_dir,
dvc,
copy_script,
):
def test_repro_changed_code(tmp_dir, dvc, copy_script):
tmp_dir.gen("bar", "bar")
tmp_dir.dvc_gen("foo", "foo")
stage = dvc.run(
@@ -762,11 +729,7 @@ def test_repro_changed_code(
assert len(stages) == 1
def test_repro_changed_data(
tmp_dir,
dvc,
copy_script,
):
def test_repro_changed_data(tmp_dir, dvc, copy_script):
tmp_dir.gen("bar", "bar")
tmp_dir.dvc_gen("foo", "foo")
stage = dvc.run(
@@ -783,11 +746,7 @@ def test_repro_changed_data(
assert len(stages) == 2
def test_repro_dry(
tmp_dir,
dvc,
copy_script,
):
def test_repro_dry(tmp_dir, dvc, copy_script):
tmp_dir.gen("bar", "bar")
tmp_dir.dvc_gen("foo", "foo")
stage = dvc.run(
@@ -808,11 +767,7 @@ def test_repro_dry(
assert not filecmp.cmp("file1", "bar", shallow=False)
def test_repro_up_to_date(
tmp_dir,
dvc,
copy_script,
):
def test_repro_up_to_date(tmp_dir, dvc, copy_script):
tmp_dir.gen("bar", "bar")
tmp_dir.dvc_gen("foo", "foo")
stage = dvc.run(
@@ -871,11 +826,7 @@ def test_repro_dry_no_exec(tmp_dir, dvc):
assert ret == 0
def test_repro_changed_deep_data(
tmp_dir,
dvc,
copy_script,
):
def test_repro_changed_deep_data(tmp_dir, dvc, copy_script):
tmp_dir.gen("bar", "bar")
tmp_dir.dvc_gen("foo", "foo")
dvc.run(
@@ -955,11 +906,7 @@ def test_repro_force_downstream_do_not_force_independent_stages(tmp_dir, dvc, ru
assert dvc.reproduce(force_downstream=True) == [foo1, foo2, cat]
def test_repro_pipeline(
tmp_dir,
dvc,
copy_script,
):
def test_repro_pipeline(tmp_dir, dvc, copy_script):
tmp_dir.gen("bar", "bar")
tmp_dir.dvc_gen("foo", "foo")
dvc.run(
@@ -978,11 +925,7 @@ def test_repro_pipeline(
assert len(stages) == 3
def test_repro_pipeline_cli(
tmp_dir,
dvc,
copy_script,
):
def test_repro_pipeline_cli(tmp_dir, dvc, copy_script):
tmp_dir.gen("bar", "bar")
tmp_dir.dvc_gen("foo", "foo")
stage = dvc.run(
@@ -995,11 +938,7 @@ def test_repro_pipeline_cli(
assert ret == 0
def test_repro_pipelines(
tmp_dir,
dvc,
copy_script,
):
def test_repro_pipelines(tmp_dir, dvc, copy_script):
foo_stage, bar_stage = tmp_dir.dvc_gen({"foo": "foo", "bar": "bar"})
file1_stage = dvc.run(
outs=["file1"],
@@ -1021,11 +960,7 @@ def test_repro_pipelines(
}
def test_repro_pipelines_cli(
tmp_dir,
dvc,
copy_script,
):
def test_repro_pipelines_cli(tmp_dir, dvc, copy_script):
tmp_dir.dvc_gen({"foo": "foo", "bar": "bar"})
dvc.run(
outs=["file1"],
@@ -1062,18 +997,11 @@ def test_freeze_non_existing(dvc, target):
assert ret != 0
def test_repro_frozen_callback(
tmp_dir,
dvc,
copy_script,
):
def test_repro_frozen_callback(tmp_dir, dvc, copy_script):
tmp_dir.gen("foo", "foo")
# NOTE: purposefully not specifying deps or outs
# to create a callback stage.
stage = dvc.run(
cmd="python copy.py foo file1",
name="copy-FOO-file1",
)
stage = dvc.run(cmd="python copy.py foo file1", name="copy-FOO-file1")
stages = dvc.reproduce(stage.addressing)
assert len(stages) == 1
@@ -1087,11 +1015,7 @@ def test_repro_frozen_callback(
assert len(stages) == 1
def test_repro_frozen_unchanged(
tmp_dir,
dvc,
copy_script,
):
def test_repro_frozen_unchanged(tmp_dir, dvc, copy_script):
"""
Check that freezing/unfreezing doesn't affect stage state
"""
@@ -1155,11 +1079,7 @@ def test_repro_metrics_add_unchanged(tmp_dir, dvc, copy_script):
assert len(stages) == 0
def test_repro_phony(
tmp_dir,
dvc,
copy_script,
):
def test_repro_phony(tmp_dir, dvc, copy_script):
tmp_dir.gen("bar", "bar")
tmp_dir.dvc_gen("foo", "foo")
dvc.run(
@@ -1176,11 +1096,7 @@ def test_repro_phony(
assert filecmp.cmp("file1", "bar", shallow=False)
def test_non_existing_output(
tmp_dir,
dvc,
copy_script,
):
def test_non_existing_output(tmp_dir, dvc, copy_script):
tmp_dir.gen("bar", "bar")
tmp_dir.dvc_gen("foo", "foo")
stage = dvc.run(
@@ -1195,11 +1111,7 @@ def test_non_existing_output(
dvc.reproduce(stage.addressing)
def test_repro_data_source(
tmp_dir,
dvc,
copy_script,
):
def test_repro_data_source(tmp_dir, dvc, copy_script):
tmp_dir.gen("bar", "bar")
tmp_dir.dvc_gen("foo", "foo")
stage = dvc.run(
@@ -1216,11 +1128,7 @@ def test_repro_data_source(
assert stages[0].outs[0].hash_info.value == file_md5("bar")
def test_repro_changed_dir(
tmp_dir,
dvc,
copy_script,
):
def test_repro_changed_dir(tmp_dir, dvc, copy_script):
tmp_dir.gen({"foo": "foo", "bar": "bar"})
shutil.copyfile("foo", "file")
@@ -1241,11 +1149,7 @@ def test_repro_changed_dir(
assert len(stages) == 1
def test_repro_changed_dir_data(
tmp_dir,
dvc,
copy_script,
):
def test_repro_changed_dir_data(tmp_dir, dvc, copy_script):
tmp_dir.gen({"data": {"foo": "foo"}, "bar": "bar"})
stage = dvc.run(
outs=["dir"],
+2 -8
View File
@@ -754,10 +754,7 @@ def test_add_file_in_symlink_dir(make_tmp_dir, tmp_dir, dvc):
def test_add_with_cache_link_error(tmp_dir, dvc, mocker, capsys):
tmp_dir.gen("foo", "foo")
mocker.patch(
"dvc_data.hashfile.checkout.test_links",
return_value=[],
)
mocker.patch("dvc_data.hashfile.checkout.test_links", return_value=[])
dvc.add("foo")
err = capsys.readouterr()[1]
assert "reconfigure cache types" in err
@@ -981,10 +978,7 @@ def test_add_does_not_remove_stage_file_on_failure(tmp_dir, dvc, mocker, target)
dvcfile_contents = (tmp_dir / stage.path).read_text()
exc_msg = f"raising error from mocked '{target}'"
mocker.patch(
target,
side_effect=DvcException(exc_msg),
)
mocker.patch(target, side_effect=DvcException(exc_msg))
with pytest.raises(DvcException, match=exc_msg):
dvc.add("foo")
+2 -12
View File
@@ -186,12 +186,7 @@ def test_checkout_empty_dir(tmp_dir, dvc):
def test_checkout_not_cached_file(tmp_dir, dvc):
tmp_dir.dvc_gen("foo", "foo")
dvc.run(
cmd="cp foo bar",
deps=["foo"],
outs_no_cache=["bar"],
name="copy-file",
)
dvc.run(cmd="cp foo bar", deps=["foo"], outs_no_cache=["bar"], name="copy-file")
stats = dvc.checkout(force=True)
assert not any(stats.values())
@@ -520,12 +515,7 @@ def test_checkout_with_relink_existing(tmp_dir, dvc, link):
def test_checkout_with_deps(tmp_dir, dvc):
tmp_dir.dvc_gen({"foo": "foo"})
dvc.run(
cmd="echo foo > bar",
outs=["bar"],
deps=["foo"],
name="copy-file",
)
dvc.run(cmd="echo foo > bar", outs=["bar"], deps=["foo"], name="copy-file")
(tmp_dir / "bar").unlink()
(tmp_dir / "foo").unlink()
+2 -7
View File
@@ -10,9 +10,7 @@ from dvc.cli import main
from dvc.exceptions import CheckoutError
from dvc.repo.open_repo import clean_repos
from dvc.stage.exceptions import StageNotFound
from dvc.testing.remote_tests import ( # noqa: F401
TestRemote,
)
from dvc.testing.remote_tests import TestRemote # noqa: F401
from dvc.utils.fs import remove
from dvc_data.hashfile.db import HashFileDB
from dvc_data.hashfile.db.local import LocalHashFileDB
@@ -177,10 +175,7 @@ def test_missing_cache(tmp_dir, dvc, local_remote, caplog):
assert bar in caplog.text
caplog.clear()
assert dvc.status(cloud=True) == {
"bar": "missing",
"foo": "missing",
}
assert dvc.status(cloud=True) == {"bar": "missing", "foo": "missing"}
assert header not in caplog.text
assert foo not in caplog.text
assert bar not in caplog.text
+6 -23
View File
@@ -84,10 +84,7 @@ def test_directory(M, tmp_dir, dvc, scm):
assert dvc.data_status(granular=True, untracked_files="all") == {
**EMPTY_STATUS,
"committed": {
"added": M.unordered(
join("dir", "bar"),
join("dir", "foobar"),
),
"added": M.unordered(join("dir", "bar"), join("dir", "foobar")),
"modified": [join("dir", "")],
},
"uncommitted": {
@@ -137,10 +134,7 @@ def test_new_empty_git_repo(M, tmp_dir, scm):
dvc = Repo.init()
assert dvc.data_status() == {
**EMPTY_STATUS,
"git": M.dict(
is_empty=True,
is_dirty=True,
),
"git": M.dict(is_empty=True, is_dirty=True),
}
@@ -180,10 +174,7 @@ def test_outs_with_no_hashes(M, tmp_dir, dvc, scm):
dvc.stage.add(single_stage=True, outs=["bar"])
dvc.stage.add(deps=["bar"], outs=["foo"], name="copy", cmd="cp foo bar")
expected_output = {
**EMPTY_STATUS,
"git": M.dict(),
}
expected_output = {**EMPTY_STATUS, "git": M.dict()}
assert dvc.data_status() == expected_output
assert dvc.data_status(granular=True) == expected_output
@@ -251,10 +242,7 @@ def test_missing_cache_workspace_exists(M, tmp_dir, dvc, scm):
"untracked": M.unordered("foobar.dvc", "dir.dvc", ".gitignore"),
"committed": {"added": M.unordered("foobar", join("dir", ""))},
"uncommitted": {"unknown": M.unordered(join("dir", "foo"), join("dir", "bar"))},
"not_in_cache": M.unordered(
"foobar",
join("dir", ""),
),
"not_in_cache": M.unordered("foobar", join("dir", "")),
"git": M.dict(),
}
@@ -297,10 +285,7 @@ def test_git_committed_missing_cache_workspace_exists(M, tmp_dir, dvc, scm):
}
assert dvc.data_status(granular=True) == {
**EMPTY_STATUS,
"not_in_cache": M.unordered(
"foobar",
join("dir", ""),
),
"not_in_cache": M.unordered("foobar", join("dir", "")),
"uncommitted": {"unknown": M.unordered(join("dir", "foo"), join("dir", "bar"))},
"git": M.dict(),
"unchanged": M.unordered("foobar", join("dir", "")),
@@ -389,9 +374,7 @@ def test_missing_dir_object_from_index(M, tmp_dir, dvc, scm):
}
assert dvc.data_status(granular=True) == {
**EMPTY_STATUS,
"committed": {
"modified": [join("dir", "")],
},
"committed": {"modified": [join("dir", "")]},
"uncommitted": {"unknown": [join("dir", "foobar")]},
"not_in_cache": [join("dir", "")],
"git": M.dict(),
+1 -4
View File
@@ -106,10 +106,7 @@ def test_load_all_multistage(tmp_dir, dvc):
metrics=["bar2"],
always_changed=True,
)
assert set(load_file(dvc, PROJECT_FILE).stages.values()) == {
stage2,
stage1,
}
assert set(load_file(dvc, PROJECT_FILE).stages.values()) == {stage2, stage1}
def test_load_all_singlestage(tmp_dir, dvc):
+3 -12
View File
@@ -93,10 +93,7 @@ def test_pull_subdir_file(tmp_dir, erepo_dir):
dest = tmp_dir / "file"
with external_repo(os.fspath(erepo_dir)) as repo:
repo.dvcfs.get(
"subdir/file",
os.fspath(dest),
)
repo.dvcfs.get("subdir/file", os.fspath(dest))
assert dest.is_file()
assert dest.read_text() == "contents"
@@ -191,10 +188,7 @@ def test_subrepos_are_ignored(tmp_dir, erepo_dir):
subrepo.dvc_gen({"file": "file"}, commit="add files on subrepo")
with external_repo(os.fspath(erepo_dir)) as repo:
repo.dvcfs.get(
"dir",
os.fspath(tmp_dir / "out"),
)
repo.dvcfs.get("dir", os.fspath(tmp_dir / "out"))
expected_files = {"foo": "foo", "bar": "bar", ".gitignore": "/foo\n"}
assert (tmp_dir / "out").read_text() == expected_files
@@ -246,9 +240,6 @@ def test_subrepos_are_ignored_for_git_tracked_dirs(tmp_dir, erepo_dir):
subrepo.dvc_gen({"file": "file"}, commit="add files on subrepo")
with external_repo(os.fspath(erepo_dir)) as repo:
repo.dvcfs.get(
"dir",
os.fspath(tmp_dir / "out"),
)
repo.dvcfs.get("dir", os.fspath(tmp_dir / "out"))
# subrepo files should not be here
assert (tmp_dir / "out").read_text() == scm_files
+2 -13
View File
@@ -243,15 +243,7 @@ def test_get_url_positive(tmp_dir, erepo_dir, caplog, local_cloud):
def test_get_url_not_existing(tmp_dir, erepo_dir, caplog):
with caplog.at_level(logging.ERROR, logger="dvc"):
assert (
main(
[
"get",
os.fspath(erepo_dir),
"not-existing-file",
"--show-url",
]
)
!= 0
main(["get", os.fspath(erepo_dir), "not-existing-file", "--show-url"]) != 0
)
@@ -332,7 +324,4 @@ def test_get_complete_repo(tmp_dir, dvc, erepo_dir):
}
Repo.get(os.fspath(erepo_dir), ".", out="out")
assert (tmp_dir / "out").read_text() == {
".gitignore": "/foo\n",
"foo": "foo",
}
assert (tmp_dir / "out").read_text() == {".gitignore": "/foo\n", "foo": "foo"}
+1 -4
View File
@@ -240,10 +240,7 @@ def test_ignore_resurface_subrepo(tmp_dir, scm, dvc):
files = ["foo"]
dirs = ["bar"]
root = os.fspath(subrepo_dir)
assert dvc.dvcignore(root, dirs, files, ignore_subrepos=False) == (
dirs,
files,
)
assert dvc.dvcignore(root, dirs, files, ignore_subrepos=False) == (dirs, files)
assert dvc.dvcignore(root, dirs, files) == ([], [])
assert dvc.dvcignore.is_ignored_dir(os.fspath(subrepo_dir / "bar"))
+3 -13
View File
@@ -273,11 +273,7 @@ def test_pull_import_no_download(tmp_dir, scm, dvc, erepo_dir):
assert stage.outs[0].meta.isdir
def test_pull_import_no_download_rev_lock(
tmp_dir,
dvc,
erepo_dir,
):
def test_pull_import_no_download_rev_lock(tmp_dir, dvc, erepo_dir):
with erepo_dir.chdir():
erepo_dir.dvc_gen("foo", "foo content", commit="add")
@@ -558,10 +554,7 @@ def test_import_complete_repo(tmp_dir, dvc, erepo_dir):
}
dvc.imp(os.fspath(erepo_dir), os.curdir, out="out")
assert (tmp_dir / "out").read_text() == {
".gitignore": "/foo\n",
"foo": "foo",
}
assert (tmp_dir / "out").read_text() == {".gitignore": "/foo\n", "foo": "foo"}
def test_import_with_no_exec(tmp_dir, dvc, erepo_dir):
@@ -707,10 +700,7 @@ def test_import_configs(tmp_dir, scm, dvc, erepo_dir, options, def_repo):
stage = dvc.imp(
os.fspath(erepo_dir), "foo", "foo_imported", no_exec=True, **options
)
assert stage.deps[0].def_repo == {
"url": os.fspath(erepo_dir),
**def_repo,
}
assert stage.deps[0].def_repo == {"url": os.fspath(erepo_dir), **def_repo}
def test_import_invalid_configs(tmp_dir, scm, dvc, erepo_dir):
+1 -11
View File
@@ -46,17 +46,7 @@ def load_data(file, output_format):
({"table": "model"}, "model"),
],
)
def test(
M,
tmp_dir,
scm,
dvc,
db_connection,
seed_db,
output_format,
args,
file_name,
):
def test(M, tmp_dir, scm, dvc, db_connection, seed_db, output_format, args, file_name):
seed_db(values=range(5))
if output_format == "json":
file_size = 96, 192
+1 -3
View File
@@ -220,9 +220,7 @@ def test_import_url_no_download(tmp_dir, scm, dvc, local_workspace):
assert out.meta.size is None
status = dvc.status()
assert status["file.dvc"] == [
{"changed outs": {"file": "deleted"}},
]
assert status["file.dvc"] == [{"changed outs": {"file": "deleted"}}]
def test_partial_import_pull(tmp_dir, scm, dvc, local_workspace):
+2 -10
View File
@@ -119,10 +119,7 @@ def test_ls_repo_with_new_path_dir(tmp_dir, dvc, scm):
tmp_dir.gen({"mysub/sub": {"foo": "content"}})
files = Repo.ls(os.fspath(tmp_dir), path="mysub/sub")
match_files(
files,
((("foo",), False),),
)
match_files(files, ((("foo",), False),))
def test_ls_repo_with_path_dir(tmp_dir, dvc, scm):
@@ -225,12 +222,7 @@ def test_ls_repo_with_missed_path_dvc_only(tmp_dir, dvc, scm):
tmp_dir.dvc_gen(DVC_STRUCTURE, commit="dvc")
with pytest.raises(FileNotFoundError):
Repo.ls(
os.fspath(tmp_dir),
path="missed_path",
recursive=True,
dvc_only=True,
)
Repo.ls(os.fspath(tmp_dir), path="missed_path", recursive=True, dvc_only=True)
def test_ls_repo_with_removed_dvc_dir(tmp_dir, dvc, scm):
+1 -6
View File
@@ -36,12 +36,7 @@ def test_cmd_move(tmp_dir, dvc):
def test_move_not_data_source(tmp_dir, dvc):
tmp_dir.dvc_gen("foo", "foo")
dvc.run(
cmd="cp foo file1",
outs=["file1"],
deps=["foo"],
name="copy-foo-file1",
)
dvc.run(cmd="cp foo file1", outs=["file1"], deps=["foo"], name="copy-foo-file1")
with pytest.raises(MoveNotDataSourceError):
dvc.move("file1", "dst")
+2 -10
View File
@@ -14,16 +14,8 @@ from dvc_objects.errors import ObjectFormatError
def test_cache(tmp_dir, dvc):
cache1_md5 = "123"
cache2_md5 = "234"
cache1 = os.path.join(
dvc.cache.local.path,
cache1_md5[0:2],
cache1_md5[2:],
)
cache2 = os.path.join(
dvc.cache.local.path,
cache2_md5[0:2],
cache2_md5[2:],
)
cache1 = os.path.join(dvc.cache.local.path, cache1_md5[:2], cache1_md5[2:])
cache2 = os.path.join(dvc.cache.local.path, cache2_md5[:2], cache2_md5[2:])
tmp_dir.gen({cache1: "1", cache2: "2"})
assert os.path.exists(cache1)
+4 -19
View File
@@ -190,23 +190,13 @@ def test_view_granular_dir(tmp_dir, scm, dvc, run_copy):
# view should exclude any siblings of the target
view = index.targets_view("dir/subdir")
assert view.data_keys == {
"repo": {
("dir", "subdir"),
}
}
assert view.data_keys == {"repo": {("dir", "subdir")}}
data_index = view.data["repo"]
assert ("dir",) in data_index
assert (
"dir",
"subdir",
) in data_index
assert ("dir", "subdir") in data_index
assert ("dir", "subdir", "in-subdir") in data_index
assert (
"dir",
"in-dir",
) not in data_index
assert ("dir", "in-dir") not in data_index
def test_view_onerror(tmp_dir, scm, dvc):
@@ -342,12 +332,7 @@ params:
def test_data_index(tmp_dir, dvc, local_cloud, erepo_dir):
tmp_dir.dvc_gen(
{
"foo": b"foo",
"dir": {"bar": b"bar", "subdir": {"baz": b"baz"}},
}
)
tmp_dir.dvc_gen({"foo": b"foo", "dir": {"bar": b"bar", "subdir": {"baz": b"baz"}}})
with erepo_dir.chdir():
erepo_dir.dvc_gen("efoo", b"efoo", commit="create efoo")
+5 -28
View File
@@ -56,13 +56,7 @@ def test_run(tmp_dir, dvc, copy_script):
def test_run_empty(dvc):
dvc.run(
cmd="echo hello world",
deps=[],
outs=[],
outs_no_cache=[],
name="empty",
)
dvc.run(cmd="echo hello world", deps=[], outs=[], outs_no_cache=[], name="empty")
def test_run_missing_dep(dvc):
@@ -264,11 +258,7 @@ class TestRunDuplicatedArguments:
class TestRunBadWdir:
def test(self, make_tmp_dir, dvc):
with pytest.raises(StagePathOutsideError):
dvc.run(
cmd="command",
wdir=make_tmp_dir("tmp"),
name="bad-wdir",
)
dvc.run(cmd="command", wdir=make_tmp_dir("tmp"), name="bad-wdir")
def test_same_prefix(self, tmp_dir, dvc):
path = f"{tmp_dir}-{uuid.uuid4()}"
@@ -287,21 +277,12 @@ class TestRunBadWdir:
path = path / str(uuid.uuid4())
path.touch()
with pytest.raises(StagePathNotDirectoryError):
dvc.run(
cmd="command",
wdir=os.fspath(path),
name="bad-wdir",
)
dvc.run(cmd="command", wdir=os.fspath(path), name="bad-wdir")
class TestCmdRunWorkingDirectory:
def test_default_wdir_is_not_written(self, tmp_dir, dvc):
dvc.run(
cmd="echo test > foo",
outs=["foo"],
wdir=".",
name="echo-foo",
)
dvc.run(cmd="echo test > foo", outs=["foo"], wdir=".", name="echo-foo")
d = load_yaml("dvc.yaml")
assert "wdir" not in get_in(d, ["stages", "echo-foo"])
@@ -520,11 +501,7 @@ def test_run_overwrite_preserves_meta_and_comment(tmp_dir, dvc, run_copy):
assert (tmp_dir / PROJECT_FILE).read_text() == text.format(src="foo1", dest="bar1")
def test_run_external_outputs(
tmp_dir,
dvc,
local_workspace,
):
def test_run_external_outputs(tmp_dir, dvc, local_workspace):
hash_name = "md5"
foo_hash = "acbd18db4cc2f85cedef654fccc4a4d8"
bar_hash = "37b51d194a7513e45b56f6524f2d51f2"
+4 -13
View File
@@ -42,10 +42,7 @@ def test_collect(tmp_dir, scm, dvc, run_copy):
run_copy("foo", "foobar", name="copy-foo-foobar")
assert collect_outs(":copy-foo-foobar") == {"foobar"}
assert collect_outs(":copy-foo-foobar", with_deps=True) == {
"foobar",
"foo",
}
assert collect_outs(":copy-foo-foobar", with_deps=True) == {"foobar", "foo"}
assert collect_outs("dvc.yaml:copy-foo-foobar", recursive=True) == {"foobar"}
assert collect_outs("copy-foo-foobar") == {"foobar"}
assert collect_outs("copy-foo-foobar", with_deps=True) == {"foobar", "foo"}
@@ -68,11 +65,7 @@ def test_collect_dir_recursive(tmp_dir, dvc, run_head):
with (tmp_dir / "dir").chdir():
stage2 = run_head("foo", name="head-foo")
stage3 = run_head("foo-1", name="head-foo1")
assert set(dvc.stage.collect("dir", recursive=True)) == {
stage1,
stage2,
stage3,
}
assert set(dvc.stage.collect("dir", recursive=True)) == {stage1, stage2, stage3}
def test_collect_with_not_existing_output_or_stage_name(tmp_dir, dvc, run_copy):
@@ -368,8 +361,7 @@ def test_collect_optimization(tmp_dir, dvc, mocker):
# Forget cached stages and graph and error out on collection
dvc._reset()
mocker.patch(
"dvc.repo.Repo.index",
property(raiser(Exception("Should not collect"))),
"dvc.repo.Repo.index", property(raiser(Exception("Should not collect")))
)
# Should read stage directly instead of collecting the whole graph
@@ -383,8 +375,7 @@ def test_collect_optimization_on_stage_name(tmp_dir, dvc, mocker, run_copy):
# Forget cached stages and graph and error out on collection
dvc._reset()
mocker.patch(
"dvc.repo.Repo.index",
property(raiser(Exception("Should not collect"))),
"dvc.repo.Repo.index", property(raiser(Exception("Should not collect")))
)
# Should read stage directly instead of collecting the whole graph
+7 -33
View File
@@ -303,16 +303,10 @@ examples = {
"deps_as_dict": (DEPS_AS_DICT, DEPS_AS_DICT_OUTPUT),
"outs_as_str": (OUTS_AS_STR, OUTS_AS_STR_OUTPUT),
"null_value_on_outs": (NULL_VALUE_ON_OUTS, NULL_VALUE_ON_OUTS_OUTPUT),
"additional_key_on_outs": (
ADDITIONAL_KEY_ON_OUTS,
ADDITIONAL_KEY_ON_OUTS_OUTPUT,
),
"additional_key_on_outs": (ADDITIONAL_KEY_ON_OUTS, ADDITIONAL_KEY_ON_OUTS_OUTPUT),
"foreach_scalar": (FOREACH_SCALAR_VALUE, FOREACH_SCALAR_VALUE_OUTPUT),
"foreach_do_do_null": (FOREACH_DO_NULL, FOREACH_DO_NULL_OUTPUT),
"foreach_do_missing_cmd": (
FOREACH_DO_MISSING_CMD,
FOREACH_DO_MISSING_CMD_OUTPUT,
),
"foreach_do_missing_cmd": (FOREACH_DO_MISSING_CMD, FOREACH_DO_MISSING_CMD_OUTPUT),
"foreach_unknown_cmd_missing_do": (
FOREACH_WITH_CMD_DO_MISSING,
FOREACH_WITH_CMD_DO_MISSING_OUTPUT,
@@ -325,10 +319,7 @@ examples = {
@pytest.fixture
def force_posixpath(mocker):
# make it always return posix path, easier for validating error messages
mocker.patch(
"dvc.utils.strictyaml.make_relpath",
return_value="./dvc.yaml",
)
mocker.patch("dvc.utils.strictyaml.make_relpath", return_value="./dvc.yaml")
@pytest.fixture
@@ -343,13 +334,7 @@ def fixed_width_term(mocker):
@pytest.mark.parametrize("text, expected", examples.values(), ids=examples.keys())
def test_exceptions(
tmp_dir,
dvc,
capsys,
force_posixpath,
fixed_width_term,
text,
expected,
tmp_dir, dvc, capsys, force_posixpath, fixed_width_term, text, expected
):
tmp_dir.gen("dvc.yaml", text)
@@ -369,21 +354,11 @@ def test_exceptions(
"text, expected",
[
(DUPLICATE_KEYS, "'./dvc.yaml' is invalid in revision '{short_rev}'."),
(
MISSING_CMD,
"'./dvc.yaml' validation failed in revision '{short_rev}'.",
),
(MISSING_CMD, "'./dvc.yaml' validation failed in revision '{short_rev}'."),
],
)
def test_on_revision(
tmp_dir,
scm,
dvc,
force_posixpath,
fixed_width_term,
capsys,
text,
expected,
tmp_dir, scm, dvc, force_posixpath, fixed_width_term, capsys, text, expected
):
tmp_dir.scm_gen("dvc.yaml", text, commit="add dvc.yaml")
capsys.readouterr() # clear outputs
@@ -413,8 +388,7 @@ def test_fallback_exception_message(tmp_dir, dvc, mocker, caplog):
# When trying to pretty print exception messages, we fallback to old way
# of printing things.
mocker.patch(
"dvc.utils.strictyaml.YAMLSyntaxError.__pretty_exc__",
side_effect=ValueError,
"dvc.utils.strictyaml.YAMLSyntaxError.__pretty_exc__", side_effect=ValueError
)
mocker.patch(
"dvc.utils.strictyaml.YAMLValidationError.__pretty_exc__",
+2 -14
View File
@@ -206,13 +206,7 @@ def repo_with_dvclive_plots(tmp_dir, scm, dvc, run_copy_metrics):
metrics_path.parent.mkdir(parents=True)
metrics_path.dump_json(metrics)
plots_config_v1 = [
{
"plots/metrics": {
"x": "step",
}
}
]
plots_config_v1 = [{"plots/metrics": {"x": "step"}}]
from dvc.utils.serialize import modify_yaml
@@ -227,13 +221,7 @@ def repo_with_dvclive_plots(tmp_dir, scm, dvc, run_copy_metrics):
"configs": {dvcyaml_path_v1: plots_config_v1},
}
plots_config_v2 = [
{
"dvclive/plots/metrics": {
"x": "step",
}
}
]
plots_config_v2 = [{"dvclive/plots/metrics": {"x": "step"}}]
dvcyaml_path_v1.unlink()
dvcyaml_path_v2 = tmp_dir / "dvc.yaml"
+4 -30
View File
@@ -97,13 +97,7 @@ def _remove_blanks(text: str):
def verify_vega(
versions,
html_result,
json_result,
split_json_result,
title,
x_label,
y_label,
versions, html_result, json_result, split_json_result, title, x_label, y_label
):
if isinstance(versions, str):
versions = [versions]
@@ -144,13 +138,7 @@ def verify_vega(
.replace("<DVC_METRIC_Y_LABEL>", y_label)
.replace(
'"<DVC_METRIC_ZOOM_AND_PAN>"',
json.dumps(
{
"name": "grid",
"select": "interval",
"bind": "scales",
}
),
json.dumps({"name": "grid", "select": "interval", "bind": "scales"}),
)
)
for path in paths:
@@ -373,22 +361,8 @@ def test_repo_with_plots(tmp_dir, scm, dvc, capsys, run_copy_metrics, repo_with_
x_label,
y_label,
)
verify_image(
path,
"workspace",
"../image.png",
image_v2,
html_path,
json_data,
)
verify_image(
path,
"HEAD",
"../image.png",
image_v1,
html_path,
json_data,
)
verify_image(path, "workspace", "../image.png", image_v2, html_path, json_data)
verify_image(path, "HEAD", "../image.png", image_v1, html_path, json_data)
@pytest.mark.vscode
+1 -5
View File
@@ -1,8 +1,4 @@
from dvc_ssh.tests.fixtures import ( # noqa: F401
make_ssh,
ssh,
ssh_server,
)
from dvc_ssh.tests.fixtures import make_ssh, ssh, ssh_server # noqa: F401
from .git_server import git_server, git_ssh # noqa: F401
+2 -10
View File
@@ -42,11 +42,7 @@ def test_remote_missing_deps_are_correctly_reported(tmp_dir, caplog, mocker, pkg
mocker.patch("dvc.PKG", pkg)
mocker.patch(
"dvc.cli.parse_args",
return_value=Namespace(
func=raiser(error),
quiet=False,
verbose=True,
),
return_value=Namespace(func=raiser(error), quiet=False, verbose=True),
)
assert main() == 255
@@ -73,11 +69,7 @@ def test_ignore_in_collected_dir_error_is_logged(tmp_dir, caplog, mocker):
error = IgnoreInCollectedDirError(".dvcignore", "dir")
mocker.patch(
"dvc.cli.parse_args",
return_value=Namespace(
func=raiser(error),
quiet=False,
verbose=True,
),
return_value=Namespace(func=raiser(error), quiet=False, verbose=True),
)
assert main() == 255
expected = ".dvcignore file should not be in collected dir path: 'dir'"
+1 -6
View File
@@ -143,12 +143,7 @@ def test_show_colors(mocker, capsys, monkeypatch):
{"isdir": False, "isexec": 0, "isout": False, "path": "README.md"},
{"isdir": True, "isexec": 0, "isout": True, "path": "data"},
{"isdir": False, "isexec": 0, "isout": True, "path": "structure.xml"},
{
"isdir": False,
"isexec": 0,
"isout": False,
"path": "structure.xml.dvc",
},
{"isdir": False, "isexec": 0, "isout": False, "path": "structure.xml.dvc"},
{"isdir": True, "isexec": 0, "isout": False, "path": "src"},
{"isdir": False, "isexec": 1, "isout": False, "path": "run.sh"},
]
+2 -17
View File
@@ -5,14 +5,7 @@ from dvc.commands.add import CmdAdd
def test_add(mocker, dvc):
cli_args = parse_args(
[
"add",
"--no-commit",
"--glob",
"data",
]
)
cli_args = parse_args(["add", "--no-commit", "--glob", "data"])
assert cli_args.func == CmdAdd
cmd = cli_args.func(cli_args)
@@ -34,15 +27,7 @@ def test_add(mocker, dvc):
def test_add_to_remote(mocker, dvc):
cli_args = parse_args(
[
"add",
"s3://bucket/foo",
"--to-remote",
"--out",
"bar",
"--remote",
"remote",
]
["add", "s3://bucket/foo", "--to-remote", "--out", "bar", "--remote", "remote"]
)
assert cli_args.func == CmdAdd
+1 -7
View File
@@ -43,13 +43,7 @@ def repo(tmp_dir, dvc):
dvc.run(no_exec=True, deps=["a", "c"], outs=["d", "e"], cmd="cmd1", name="1")
dvc.run(no_exec=True, deps=["b", "c"], outs=["f", "g"], cmd="cmd2", name="2")
dvc.run(
no_exec=True,
deps=["a", "b", "c"],
outs=["h", "i"],
cmd="cmd3",
name="3",
)
dvc.run(no_exec=True, deps=["a", "b", "c"], outs=["h", "i"], cmd="cmd3", name="3")
dvc.run(no_exec=True, deps=["a", "h"], outs=["j"], cmd="cmd4", name="4")
return dvc
+2 -14
View File
@@ -306,13 +306,7 @@ def test_experiments_push(dvc, scm, mocker):
run_cache=True,
)
cli_args = parse_args(
[
"experiments",
"push",
"origin",
]
)
cli_args = parse_args(["experiments", "push", "origin"])
cmd = cli_args.func(cli_args)
assert cmd.run() == 0
@@ -358,13 +352,7 @@ def test_experiments_pull(dvc, scm, mocker):
run_cache=True,
)
cli_args = parse_args(
[
"experiments",
"pull",
"origin",
]
)
cli_args = parse_args(["experiments", "pull", "origin"])
cmd = cli_args.func(cli_args)
assert cmd.run() == 0
+2 -17
View File
@@ -8,15 +8,7 @@ from dvc.exceptions import DvcException
def test_import_url(mocker, dvc):
cli_args = parse_args(
[
"import-url",
"src",
"out",
"--jobs",
"4",
]
)
cli_args = parse_args(["import-url", "src", "out", "--jobs", "4"])
assert cli_args.func == CmdImportUrl
cmd = cli_args.func(cli_args)
@@ -62,14 +54,7 @@ def test_failed_import_url(mocker, caplog, dvc):
],
)
def test_import_url_no_exec_download_flags(mocker, flag, expected, dvc):
cli_args = parse_args(
[
"import-url",
flag,
"src",
"out",
]
)
cli_args = parse_args(["import-url", flag, "src", "out"])
cmd = cli_args.func(cli_args)
m = mocker.patch.object(cmd.repo, "imp_url", autospec=True)
+1 -4
View File
@@ -18,10 +18,7 @@ def plots_data():
"revision": {
"sources": {
"data": {
"plot.csv": {
"data": [{"val": 1}, {"val": 2}],
"props": {},
},
"plot.csv": {"data": [{"val": 1}, {"val": 2}], "props": {}},
"other.jpg": {"data": b"content"},
}
},
+9 -47
View File
@@ -11,42 +11,19 @@ from dvc.exceptions import InvalidArgumentError
def test_experiments_remove_flags(dvc, scm, mocker):
cli_args = parse_args(
[
"queue",
"remove",
"--queued",
"--success",
"--failed",
]
)
cli_args = parse_args(["queue", "remove", "--queued", "--success", "--failed"])
assert cli_args.func == CmdQueueRemove
cmd = cli_args.func(cli_args)
remove_mocker = mocker.patch(
"dvc.repo.experiments.queue.celery.LocalCeleryQueue.clear",
return_value={},
"dvc.repo.experiments.queue.celery.LocalCeleryQueue.clear", return_value={}
)
assert cmd.run() == 0
remove_mocker.assert_called_once_with(
success=True,
failed=True,
queued=True,
)
cli_args = parse_args(
[
"queue",
"remove",
"--all",
]
)
remove_mocker.assert_called_once_with(success=True, failed=True, queued=True)
cli_args = parse_args(["queue", "remove", "--all"])
cmd = cli_args.func(cli_args)
remove_mocker.reset_mock()
assert cmd.run() == 0
remove_mocker.assert_called_once_with(
success=True,
failed=True,
queued=True,
)
remove_mocker.assert_called_once_with(success=True, failed=True, queued=True)
def test_experiments_remove_invalid(dvc, scm, mocker):
@@ -114,28 +91,18 @@ def test_experiments_start(dvc, scm, mocker):
assert cli_args.func == CmdQueueStart
cmd = cli_args.func(cli_args)
m = mocker.patch(
"dvc.repo.experiments.queue.celery.LocalCeleryQueue._spawn_worker",
)
m = mocker.patch("dvc.repo.experiments.queue.celery.LocalCeleryQueue._spawn_worker")
assert cmd.run() == 0
assert m.call_count == 3
def test_experiments_stop(dvc, scm, mocker):
cli_args = parse_args(
[
"queue",
"stop",
"--kill",
]
)
cli_args = parse_args(["queue", "stop", "--kill"])
assert cli_args.func == CmdQueueStop
cmd = cli_args.func(cli_args)
m = mocker.patch(
"dvc.repo.experiments.queue.celery.LocalCeleryQueue.shutdown",
)
m = mocker.patch("dvc.repo.experiments.queue.celery.LocalCeleryQueue.shutdown")
assert cmd.run() == 0
m.assert_called_once_with(kill=True)
@@ -191,12 +158,7 @@ def test_worker_status(dvc, scm, worker_status, output, mocker, capsys):
def test_experiments_status(dvc, scm, mocker, capsys):
from datetime import datetime
cli_args = parse_args(
[
"queue",
"status",
]
)
cli_args = parse_args(["queue", "status"])
assert cli_args.func == CmdQueueStatus
cmd = cli_args.func(cli_args)
+1 -4
View File
@@ -103,10 +103,7 @@ def test_dumpd_with_info(dvc):
def test_dumpd_without_info(dvc):
dep = ParamsDependency(Stage(dvc), None, list(PARAMS.keys()))
assert dep.dumpd() == {
"path": DEFAULT_PARAMS_FILE,
"params": list(PARAMS.keys()),
}
assert dep.dumpd() == {"path": DEFAULT_PARAMS_FILE, "params": list(PARAMS.keys())}
def test_read_params_nonexistent_file(dvc):
+2 -10
View File
@@ -302,11 +302,7 @@ def test_walk_mixed_dir(tmp_dir, scm, dvc):
fs = DVCFileSystem(repo=dvc)
expected = [
"dir/foo",
"dir/bar",
"dir/.gitignore",
]
expected = ["dir/foo", "dir/bar", "dir/.gitignore"]
actual = []
for root, dirs, files in fs.walk("dir"):
for entry in dirs + files:
@@ -457,11 +453,7 @@ def test_subrepo_walk(tmp_dir, scm, dvc, dvcfiles, extra_expected):
]
actual = []
for root, dirs, files in fs.walk(
"dir",
dvcfiles=dvcfiles,
ignore_subrepos=False,
):
for root, dirs, files in fs.walk("dir", dvcfiles=dvcfiles, ignore_subrepos=False):
for entry in dirs + files:
actual.append(posixpath.join(root, entry))
+2 -13
View File
@@ -104,14 +104,7 @@ def test_info_git_dvc_mixed_dirs(dvcfs, path):
assert not info["isexec"]
@pytest.mark.parametrize(
"path",
[
"data",
"data/raw",
"data/processed",
],
)
@pytest.mark.parametrize("path", ["data", "data/raw", "data/processed"])
def test_info_dvc_only_dirs(dvcfs, path):
info = dvcfs.info(path)
@@ -128,11 +121,7 @@ def test_info_on_subrepos(make_tmp_dir, tmp_dir, dvc, scm, dvcfs):
subrepo.scm_gen("foo", "foo", commit="add foo on subrepo")
subrepo.dvc_gen("foobar", "foobar", commit="add foobar on subrepo")
for path in [
"subrepo",
"subrepo/foo",
"subrepo/foobar",
]:
for path in ["subrepo", "subrepo/foo", "subrepo/foobar"]:
info = dvcfs.info(path)
assert info["repo"].root_dir == str(
subrepo
+1 -4
View File
@@ -199,7 +199,4 @@ def test_version_aware_is_set_based_on_files(mocker):
# version_aware is passed as `True` if `files` is present`.
# This will be intentionally ignored in filesystems that don't handle it
# in `_prepare_credentials`.
assert get_fs_config.call_args_list[0][1] == {
"url": "path",
"version_aware": True,
}
assert get_fs_config.call_args_list[0][1] == {"url": "path", "version_aware": True}
+1 -4
View File
@@ -18,10 +18,7 @@ def test_remote_with_hash_jobs(dvc):
def test_remote_with_jobs(dvc):
dvc.config["remote"]["with_jobs"] = {
"url": "s3://bucket/name",
"jobs": 100,
}
dvc.config["remote"]["with_jobs"] = {"url": "s3://bucket/name", "jobs": 100}
cls, config, _ = get_cloud_fs(dvc.config, name="with_jobs")
fs = cls(**config)
+1 -4
View File
@@ -124,10 +124,7 @@ def test_ask_password_custom_auth_header(mocker):
def test_ssl_verify_custom_cert():
config = {
"url": url,
"ssl_verify": "/path/to/custom/cabundle.pem",
}
config = {"url": url, "ssl_verify": "/path/to/custom/cabundle.pem"}
fs = WebDAVFileSystem(**config)
assert fs.fs_args["verify"] == "/path/to/custom/cabundle.pem"
+1 -5
View File
@@ -3,11 +3,7 @@ from funcy import set_in
from dvc.render import FIELD, FILENAME, REVISION
from dvc.render.converter.vega import VegaConverter
from dvc.render.match import (
PlotsData,
_squash_plots_properties,
match_defs_renderers,
)
from dvc.render.match import PlotsData, _squash_plots_properties, match_defs_renderers
@pytest.mark.parametrize(
+1 -6
View File
@@ -513,12 +513,7 @@ def test_finding_lists(dictionary, expected_result):
),
],
)
def test_convert(
input_data,
properties,
expected_datapoints,
expected_properties,
):
def test_convert(input_data, properties, expected_datapoints, expected_properties):
converter = VegaConverter("f", input_data, properties)
datapoints, resolved_properties = converter.flat_datapoints("r")
+2 -10
View File
@@ -79,10 +79,7 @@ def session_app(tmp_path_factory) -> FSApp:
"dvc-exp-local",
wdir=wdir,
mkdir=True,
include=[
"dvc.repo.experiments.queue.tasks",
"dvc_task.proc.tasks",
],
include=["dvc.repo.experiments.queue.tasks", "dvc_task.proc.tasks"],
)
app.conf.update({"task_acks_late": True, "result_expires": None})
return app
@@ -124,12 +121,7 @@ def test_queue(tmp_dir, dvc, scm, mocker):
queue = dvc.experiments.celery_queue
mocker.patch.object(queue, "_spawn_worker")
f = partial(
_thread_worker,
queue.celery,
concurrency=1,
ping_task_timeout=20,
)
f = partial(_thread_worker, queue.celery, concurrency=1, ping_task_timeout=20)
exc = None
for _ in range(3):
try:
@@ -110,15 +110,8 @@ def test_celery_queue_kill(test_queue, mocker, force):
(mocker.Mock(headers={"id": "foobar"}), mock_entry_foobar),
],
)
mocker.patch.object(
AsyncResult,
"ready",
return_value=False,
)
mark_mocker = mocker.patch.object(
test_queue.celery.backend,
"mark_as_failure",
)
mocker.patch.object(AsyncResult, "ready", return_value=False)
mark_mocker = mocker.patch.object(test_queue.celery.backend, "mark_as_failure")
def kill_function(rev):
if rev == "foo":
@@ -148,11 +141,7 @@ def test_celery_queue_kill_invalid(test_queue, mocker, force):
mocker.patch.object(
test_queue,
"match_queue_entry_by_name",
return_value={
"bar": mock_entry_bar,
"foo": mock_entry_foo,
"foobar": None,
},
return_value={"bar": mock_entry_bar, "foo": mock_entry_foo, "foobar": None},
)
kill_mock = mocker.patch.object(test_queue, "_kill_entries")
@@ -81,10 +81,7 @@ def test_remove_done(test_queue, mocker):
remove_revs_mocker = mocker.patch.object(test_queue.failed_stash, "remove_revs")
purge_mocker = mocker.patch.object(test_queue.celery, "purge")
assert test_queue.remove(["failed3", "success2"]) == [
"failed3",
"success2",
]
assert test_queue.remove(["failed3", "success2"]) == ["failed3", "success2"]
remove_revs_mocker.assert_called_once_with([stash_dict["failed3"]])
purge_mocker.assert_has_calls(
[mocker.call("msg_failed3"), mocker.call("msg_success2")]
+1 -4
View File
@@ -57,10 +57,7 @@ def test_collect_stable_sorting(dvc, scm, mocker):
_assert_experiment_rev_order(collected[1].experiments, expected_revs)
def _assert_experiment_rev_order(
actual: list["ExpRange"],
expected_revs: list[str],
):
def _assert_experiment_rev_order(actual: list["ExpRange"], expected_revs: list[str]):
expected_revs = expected_revs.copy()
for actual_exp_range in actual:
@@ -48,19 +48,13 @@ def test_celery_queue_failure_status(dvc, scm, test_queue, failed_exp_stage):
def test_workspace_executor_success_status(dvc, scm, exp_stage, queue_type):
workspace_queue = getattr(dvc.experiments, queue_type)
queue_entry = workspace_queue.put(
params={"params.yaml": ["foo=1"]},
targets=exp_stage.addressing,
name="success",
params={"params.yaml": ["foo=1"]}, targets=exp_stage.addressing, name="success"
)
name = workspace_queue._EXEC_NAME or queue_entry.stash_rev
infofile = workspace_queue.get_infofile_path(name)
entry, executor = workspace_queue.get()
rev = entry.stash_rev
exec_result = executor.reproduce(
info=executor.info,
rev=rev,
infofile=infofile,
)
exec_result = executor.reproduce(info=executor.info, rev=rev, infofile=infofile)
executor_info = ExecutorInfo.load_json(infofile)
assert executor_info.status == TaskStatus.SUCCESS
if exec_result.ref_info:
@@ -74,10 +68,7 @@ def test_workspace_executor_success_status(dvc, scm, exp_stage, queue_type):
assert not os.path.exists(infofile)
@pytest.mark.parametrize(
"queue_type",
["workspace_queue", "tempdir_queue"],
)
@pytest.mark.parametrize("queue_type", ["workspace_queue", "tempdir_queue"])
def test_workspace_executor_failed_status(dvc, scm, failed_exp_stage, queue_type):
queue = getattr(dvc.experiments, queue_type)
queue.put(
@@ -91,11 +82,7 @@ def test_workspace_executor_failed_status(dvc, scm, failed_exp_stage, queue_type
rev = entry.stash_rev
with pytest.raises(ReproductionError):
executor.reproduce(
info=executor.info,
rev=rev,
infofile=infofile,
)
executor.reproduce(info=executor.info, rev=rev, infofile=infofile)
executor_info = ExecutorInfo.load_json(infofile)
assert executor_info.status == TaskStatus.FAILED
+1 -5
View File
@@ -41,11 +41,7 @@ def test_repro_plan(M):
assert plan_repro(g, [4], downstream=True) == [4, 2, 1]
assert plan_repro(g, [8], True) == plan_repro(g, [9], True) == [9, 8]
assert plan_repro(g, [2, 8], True) == [4, 5, 2, 6, 7, 3, 1, 9, 8]
assert plan_repro(g, [2, 3], downstream=True) == [
M.any_of(2, 3),
M.any_of(2, 3),
1,
]
assert plan_repro(g, [2, 3], downstream=True) == [M.any_of(2, 3), M.any_of(2, 3), 1]
def test_number_reproduces(tmp_dir, dvc, mocker):
+1 -5
View File
@@ -6,11 +6,7 @@ from dvc.repo.experiments import ExpRefInfo
from dvc.scm import iter_revs
def test_iter_revs(
tmp_dir,
scm,
mocker,
):
def test_iter_revs(tmp_dir, scm, mocker):
"""
new other
│ │
+7 -20
View File
@@ -7,10 +7,7 @@ import dvc.output as dvc_output
def test_stage_cache(tmp_dir, dvc, mocker):
tmp_dir.gen("dep", "dep")
tmp_dir.gen(
"script.py",
'open("out", "w+").write("out"); ',
)
tmp_dir.gen("script.py", 'open("out", "w+").write("out"); ')
stage = dvc.run(
cmd="python script.py",
deps=["script.py", "dep"],
@@ -31,8 +28,7 @@ def test_stage_cache(tmp_dir, dvc, mocker):
"c7a85d71de1912c43d9c5b6218c71630d6277e8fc11e4ccf5e12b3c202234838",
)
cache_file = os.path.join(
cache_dir,
"5e2824029f8da9ef6c57131a638ceb65f27c02f16c85d71e85671c27daed0501",
cache_dir, "5e2824029f8da9ef6c57131a638ceb65f27c02f16c85d71e85671c27daed0501"
)
assert os.path.isdir(cache_dir)
@@ -54,10 +50,7 @@ def test_stage_cache(tmp_dir, dvc, 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(
"script.py",
'open("out", "w+").write("out"); ',
)
tmp_dir.gen("script.py", 'open("out", "w+").write("out"); ')
stage = dvc.run(
cmd="python script.py",
params=["foo,bar", "myparams.yaml:baz,qux"],
@@ -78,8 +71,7 @@ def test_stage_cache_params(tmp_dir, dvc, mocker):
"8fdb377d1b4c0a303b788771b122dfba9bbbbc43f14ce41d35715cf4fea08459",
)
cache_file = os.path.join(
cache_dir,
"9ce1963a69beb1299800188647cd960b7afff101be19fd46226e32bb8be8ee44",
cache_dir, "9ce1963a69beb1299800188647cd960b7afff101be19fd46226e32bb8be8ee44"
)
assert os.path.isdir(cache_dir)
@@ -100,10 +92,7 @@ def test_stage_cache_params(tmp_dir, dvc, mocker):
def test_stage_cache_wdir(tmp_dir, dvc, mocker):
tmp_dir.gen("dep", "dep")
tmp_dir.gen(
"script.py",
'open("out", "w+").write("out"); ',
)
tmp_dir.gen("script.py", 'open("out", "w+").write("out"); ')
tmp_dir.gen({"wdir": {}})
stage = dvc.run(
cmd="python ../script.py",
@@ -126,8 +115,7 @@ def test_stage_cache_wdir(tmp_dir, dvc, mocker):
"6ad5cce3347e9e96c77d4353d84e5c8cae8c9151c486c4ea3d3d79e9051800f1",
)
cache_file = os.path.join(
cache_dir,
"1fa3e1a9f785f8364ad185d62bd0813ce8794afcfc79410e985eac0443cc5462",
cache_dir, "1fa3e1a9f785f8364ad185d62bd0813ce8794afcfc79410e985eac0443cc5462"
)
assert os.path.isdir(cache_dir)
@@ -168,8 +156,7 @@ def test_shared_stage_cache(tmp_dir, dvc, run_copy):
"6d4c6de74e7c0d60d2122e2063b4724a8c78a6799def6c7cf5093f45e7f2f3b7",
)
cache_file = os.path.join(
cache_dir,
"435e34f80692059e79ec53346cbfe29fd9ee65b62f5f06f17f5950ce5a7408ea",
cache_dir, "435e34f80692059e79ec53346cbfe29fd9ee65b62f5f06f17f5950ce5a7408ea"
)
# sanity check
@@ -198,7 +198,4 @@ def test_order_deps_outs(dvc, typ):
stage = create_stage(PipelineStage, dvc, **kwargs, **extra)
assert typ not in to_pipeline_file(stage)["something"]
assert list(to_pipeline_file(stage)["something"].keys()) == [
"cmd",
*all_types,
]
assert list(to_pipeline_file(stage)["something"].keys()) == ["cmd", *all_types]
+1 -4
View File
@@ -77,10 +77,7 @@ def test_stage_update(dvc, mocker):
@pytest.mark.skipif(
not isinstance(
threading.current_thread(),
threading._MainThread,
),
not isinstance(threading.current_thread(), threading._MainThread),
reason="Not running in the main thread.",
)
def test_stage_run_ignore_sigint(dvc, mocker):
+1 -6
View File
@@ -31,12 +31,7 @@ def test_get_stage_files(tmp_dir, dvc):
outs=["dvc-out"],
outs_no_cache=["other-out"],
)
assert _get_stage_files(stage) == [
"dvc.yaml",
"dvc.lock",
"other-dep",
"other-out",
]
assert _get_stage_files(stage) == ["dvc.yaml", "dvc.lock", "other-dep", "other-out"]
def test_get_stage_files_wdir(tmp_dir, dvc):
+2 -6
View File
@@ -99,8 +99,7 @@ def test_s3_ssl_verify(tmp_dir, dvc):
def test_load_unicode_error(tmp_dir, dvc, mocker):
config = Config.from_cwd(validate=False)
mocker.patch(
"configobj.ConfigObj",
side_effect=UnicodeDecodeError("", b"", 0, 0, ""),
"configobj.ConfigObj", side_effect=UnicodeDecodeError("", b"", 0, 0, "")
)
with pytest.raises(ConfigError):
with config.edit():
@@ -111,10 +110,7 @@ def test_load_configob_error(tmp_dir, dvc, mocker):
from configobj import ConfigObjError
config = Config.from_cwd(validate=False)
mocker.patch(
"configobj.ConfigObj",
side_effect=ConfigObjError(),
)
mocker.patch("configobj.ConfigObj", side_effect=ConfigObjError())
with pytest.raises(ConfigError):
with config.edit():
pass
+3 -12
View File
@@ -151,18 +151,9 @@ def test_check(mocker, updater):
("deb", "To upgrade, run 'apt-get install --only-upgrade dvc'."),
("conda", "To upgrade, run 'conda update dvc'."),
("choco", "To upgrade, run 'choco upgrade dvc'."),
(
"osxpkg",
"To upgrade, uninstall dvc and reinstall from https://dvc.org.",
),
(
"exe",
"To upgrade, uninstall dvc and reinstall from https://dvc.org.",
),
(
"binary",
"To upgrade, uninstall dvc and reinstall from https://dvc.org.",
),
("osxpkg", "To upgrade, uninstall dvc and reinstall from https://dvc.org."),
("exe", "To upgrade, uninstall dvc and reinstall from https://dvc.org."),
("binary", "To upgrade, uninstall dvc and reinstall from https://dvc.org."),
(
None,
(