mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
[pre-commit.ci] pre-commit autoupdate (#10869)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.12.12 → v0.13.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.12...v0.13.0) * fix ruff errors --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Saugat Pachhai (सौगात) <[email protected]>
This commit is contained in:
co-authored by
Saugat Pachhai
parent
336c8695da
commit
6e896d396c
@@ -1,3 +1,5 @@
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
||||
from dvc import api
|
||||
@@ -13,7 +15,7 @@ def test_exp_save(tmp_dir, dvc, scm):
|
||||
api.exp_save("foo")
|
||||
with pytest.raises(
|
||||
ExperimentExistsError,
|
||||
match="Experiment conflicts with existing experiment 'foo'.",
|
||||
match=re.escape("Experiment conflicts with existing experiment 'foo'."),
|
||||
):
|
||||
api.exp_save("foo")
|
||||
api.exp_save("foo", force=True)
|
||||
|
||||
@@ -204,10 +204,10 @@ def test_remove_multi_rev(tmp_dir, scm, dvc, exp_stage):
|
||||
@pytest.mark.parametrize(
|
||||
"keep, expected_removed",
|
||||
[
|
||||
[["exp1"], ["exp2", "exp3"]],
|
||||
[["exp1", "exp2"], ["exp3"]],
|
||||
[["exp1", "exp2", "exp3"], []],
|
||||
[[], []], # remove does nothing if no experiments are specified
|
||||
(["exp1"], ["exp2", "exp3"]),
|
||||
(["exp1", "exp2"], ["exp3"]),
|
||||
(["exp1", "exp2", "exp3"], []),
|
||||
([], []), # remove does nothing if no experiments are specified
|
||||
],
|
||||
)
|
||||
def test_keep_selected_by_name(tmp_dir, scm, dvc, exp_stage, keep, expected_removed):
|
||||
@@ -239,14 +239,14 @@ def test_keep_selected_by_nonexistent_name(tmp_dir, scm, dvc, exp_stage):
|
||||
@pytest.mark.parametrize(
|
||||
"num_exps, rev, num, expected_removed",
|
||||
[
|
||||
[2, "exp1", 1, ["exp2"]],
|
||||
[3, "exp3", 1, ["exp1", "exp2"]],
|
||||
[3, "exp3", 2, ["exp1"]],
|
||||
[3, "exp3", 3, []],
|
||||
[3, "exp2", 2, ["exp3"]],
|
||||
[4, "exp2", 2, ["exp3", "exp4"]],
|
||||
[4, "exp4", 2, ["exp1", "exp2"]],
|
||||
[1, None, 1, []], # remove does nothing if no experiments are specified
|
||||
(2, "exp1", 1, ["exp2"]),
|
||||
(3, "exp3", 1, ["exp1", "exp2"]),
|
||||
(3, "exp3", 2, ["exp1"]),
|
||||
(3, "exp3", 3, []),
|
||||
(3, "exp2", 2, ["exp3"]),
|
||||
(4, "exp2", 2, ["exp3", "exp4"]),
|
||||
(4, "exp4", 2, ["exp1", "exp2"]),
|
||||
(1, None, 1, []), # remove does nothing if no experiments are specified
|
||||
],
|
||||
)
|
||||
def test_keep_selected_by_rev(
|
||||
|
||||
@@ -18,7 +18,7 @@ def test_exp_save_unchanged(tmp_dir, dvc, scm):
|
||||
dvc.experiments.save()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", (None, "test"))
|
||||
@pytest.mark.parametrize("name", [None, "test"])
|
||||
def test_exp_save(tmp_dir, dvc, scm, name):
|
||||
setup_stage(tmp_dir, dvc, scm)
|
||||
baseline = scm.get_rev()
|
||||
@@ -47,13 +47,13 @@ def test_exp_save_overwrite_experiment(tmp_dir, dvc, scm):
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"name",
|
||||
(
|
||||
[
|
||||
"invalid/name",
|
||||
"invalid..name",
|
||||
"invalid~name",
|
||||
"invalid?name",
|
||||
"invalidname.",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_exp_save_invalid_name(tmp_dir, dvc, scm, name):
|
||||
setup_stage(tmp_dir, dvc, scm)
|
||||
|
||||
@@ -7,8 +7,8 @@ from tests.func.utils.test_hydra import hydra_setup
|
||||
@pytest.mark.parametrize(
|
||||
"changes, expected",
|
||||
[
|
||||
[["foo=baz"], "foo: baz\ngoo:\n bag: 3.0\nlorem: false"],
|
||||
[["params.yaml:foo=baz"], "foo: baz\ngoo:\n bag: 3.0\nlorem: false"],
|
||||
(["foo=baz"], "foo: baz\ngoo:\n bag: 3.0\nlorem: false"),
|
||||
(["params.yaml:foo=baz"], "foo: baz\ngoo:\n bag: 3.0\nlorem: false"),
|
||||
],
|
||||
)
|
||||
def test_modify_params(params_repo, dvc, changes, expected):
|
||||
|
||||
@@ -289,14 +289,14 @@ def test_metrics_show_overlap(tmp_dir, dvc, run_copy_metrics, clear_before_run):
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"file,error_path,err_type",
|
||||
(
|
||||
[
|
||||
(PROJECT_FILE, ["workspace", "error", "type"], "YAMLSyntaxError"),
|
||||
(
|
||||
"metrics.yaml",
|
||||
["workspace", "data", "metrics.yaml", "error", "type"],
|
||||
"YAMLFileCorruptedError",
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_log_errors(
|
||||
tmp_dir, scm, dvc, capsys, run_copy_metrics, file, error_path, err_type
|
||||
|
||||
@@ -300,13 +300,13 @@ def test_ignore_parsing_error(tmp_dir, dvc, run_copy_metrics):
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"file,path_kwargs",
|
||||
(
|
||||
[
|
||||
(PROJECT_FILE, {"revision": "workspace", "endkey": "error"}),
|
||||
(
|
||||
"plot.yaml",
|
||||
{"revision": "workspace", "file": "plot.yaml", "endkey": "error"},
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_log_errors(tmp_dir, scm, dvc, run_copy_metrics, file, path_kwargs, capsys):
|
||||
metric = [{"val": 2}, {"val": 3}]
|
||||
|
||||
@@ -628,7 +628,7 @@ def test_chained_import(tmp_dir, dvc, make_tmp_dir, erepo_dir, local_cloud):
|
||||
assert (dst / "bar").read_text() == "bar"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("paths", ([], ["dir"]))
|
||||
@pytest.mark.parametrize("paths", [[], ["dir"]])
|
||||
def test_parameterized_repo(tmp_dir, dvc, scm, erepo_dir, paths):
|
||||
path = erepo_dir.joinpath(*paths)
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -38,7 +38,7 @@ def load_data(file, output_format):
|
||||
return pd.read_csv(file)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("output_format", ("csv", "json"))
|
||||
@pytest.mark.parametrize("output_format", ["csv", "json"])
|
||||
@pytest.mark.parametrize(
|
||||
"args,file_name",
|
||||
[
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -37,7 +38,7 @@ def test_remove_file_target(tmp_dir, dvc):
|
||||
|
||||
with pytest.raises(
|
||||
StageFileIsNotDvcFileError,
|
||||
match="'foo' is not a .dvc file. Do you mean 'foo.dvc'?",
|
||||
match=re.escape("'foo' is not a .dvc file. Do you mean 'foo.dvc'?"),
|
||||
):
|
||||
dvc.remove("foo")
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -228,7 +229,7 @@ def test_parent_repo_collect_stages(tmp_dir, scm, dvc):
|
||||
assert deep_subrepo_stages != []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("with_deps", (False, True))
|
||||
@pytest.mark.parametrize("with_deps", [False, True])
|
||||
def test_collect_symlink(tmp_dir, dvc, with_deps):
|
||||
from dvc.exceptions import StageNotFoundError
|
||||
|
||||
@@ -339,6 +340,8 @@ def test_stage_add_duplicated_output(tmp_dir, dvc):
|
||||
|
||||
with pytest.raises(
|
||||
OutputDuplicationError,
|
||||
match="Use `dvc remove foo.dvc` to stop tracking the overlapping output.",
|
||||
match=re.escape(
|
||||
"Use `dvc remove foo.dvc` to stop tracking the overlapping output."
|
||||
),
|
||||
):
|
||||
dvc.stage.add(name="duplicated", cmd="echo bar > foo", outs=["foo"])
|
||||
|
||||
@@ -156,7 +156,7 @@ def test_update_unchanged(tmp_dir, dvc, erepo_dir, mocker):
|
||||
assert not spy.called
|
||||
|
||||
|
||||
@pytest.mark.parametrize("outs_exist", (False, True))
|
||||
@pytest.mark.parametrize("outs_exist", [False, True])
|
||||
def test_update_no_download(tmp_dir, dvc, erepo_dir, outs_exist, mocker):
|
||||
with erepo_dir.chdir():
|
||||
erepo_dir.dvc_gen("file", "file content", commit="add file")
|
||||
@@ -204,7 +204,7 @@ def test_update_import_url(tmp_dir, dvc, workspace):
|
||||
assert dst.read_text() == "updated file content"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("outs_exist", (False, True))
|
||||
@pytest.mark.parametrize("outs_exist", [False, True])
|
||||
def test_update_import_url_no_download(tmp_dir, dvc, workspace, outs_exist, mocker):
|
||||
workspace.gen("file", "file content")
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import re
|
||||
from contextlib import nullcontext as does_not_raise
|
||||
|
||||
import pytest
|
||||
@@ -214,7 +215,9 @@ def hydra_setup_dir_basic(tmp_dir, config_subdir, config_name, config_content):
|
||||
None,
|
||||
pytest.raises(
|
||||
ValueError,
|
||||
match="Either `config_dir` or `config_module` should be provided.",
|
||||
match=re.escape(
|
||||
"Either `config_dir` or `config_module` should be provided."
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user