mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
[pre-commit.ci] pre-commit autoupdate (#9632)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/asottile/pyupgrade: v3.3.1 → v3.9.0](https://github.com/asottile/pyupgrade/compare/v3.3.1...v3.9.0) - https://github.com/charliermarsh/ruff-pre-commit → https://github.com/astral-sh/ruff-pre-commit - [github.com/astral-sh/ruff-pre-commit: v0.0.261 → v0.0.277](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.261...v0.0.277) - [github.com/codespell-project/codespell: v2.2.4 → v2.2.5](https://github.com/codespell-project/codespell/compare/v2.2.4...v2.2.5) * fix ruff complaints --------- 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
f1764bdc77
commit
ca3704997b
@@ -187,7 +187,7 @@ def test_params_show_stages(params_repo):
|
||||
|
||||
|
||||
def test_params_show_stage_addressing(tmp_dir, dvc):
|
||||
for subdir in {"subdir1", "subdir2"}:
|
||||
for subdir in ("subdir1", "subdir2"):
|
||||
subdir = tmp_dir / subdir
|
||||
subdir.mkdir()
|
||||
with subdir.chdir():
|
||||
@@ -195,7 +195,7 @@ def test_params_show_stage_addressing(tmp_dir, dvc):
|
||||
|
||||
dvc.run(name="stage-0", cmd="echo stage-0", params=["foo"])
|
||||
|
||||
for s in {"subdir1", "subdir2"}:
|
||||
for s in ("subdir1", "subdir2"):
|
||||
dvcyaml = os.path.join(s, "dvc.yaml")
|
||||
assert api.params_show(stages=f"{dvcyaml}:stage-0") == {"foo": 1}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ def test_reproduce(tmp_dir, scm, dvc, cloud, exp_stage, mocker):
|
||||
rev,
|
||||
fs_factory=partial(_ssh_factory, cloud),
|
||||
)
|
||||
assert mock_execute.called_once()
|
||||
mock_execute.assert_called_once()
|
||||
_name, args, _kwargs = mock_execute.mock_calls[0]
|
||||
assert f"dvc exp exec-run --infofile {infofile}" in args[0]
|
||||
|
||||
@@ -148,7 +148,7 @@ def test_run_machine(tmp_dir, scm, dvc, cloud, exp_stage, mocker):
|
||||
|
||||
tmp_dir.gen("params.yaml", "foo: 2")
|
||||
dvc.experiments.run(exp_stage.addressing, machine="foo")
|
||||
assert mock_repro.called_once()
|
||||
mock_repro.assert_called_once()
|
||||
_name, _args, kwargs = mock_repro.mock_calls[0]
|
||||
info = kwargs["info"]
|
||||
url = urlparse(info.git_url)
|
||||
|
||||
@@ -488,16 +488,6 @@ def test_run_celery(tmp_dir, scm, dvc, exp_stage, mocker):
|
||||
assert expected == metrics
|
||||
|
||||
|
||||
def test_run_metrics(tmp_dir, scm, dvc, exp_stage, mocker):
|
||||
from dvc.cli import main
|
||||
|
||||
mocker.patch.object(dvc.experiments, "run", return_value={"abc123": "abc123"})
|
||||
show_mock = mocker.patch.object(dvc.metrics, "show", return_value={})
|
||||
|
||||
main(["exp", "run", "-m"])
|
||||
assert show_mock.called_once()
|
||||
|
||||
|
||||
def test_checkout_targets_deps(tmp_dir, scm, dvc, exp_stage):
|
||||
from dvc.utils.fs import remove
|
||||
|
||||
|
||||
@@ -452,7 +452,7 @@ def test_show_csv(tmp_dir, scm, dvc, exp_stage, capsys):
|
||||
assert "metrics.yaml:foo,params.yaml:foo,copy.py" in cap.out
|
||||
assert f",workspace,baseline,,,3,3,{data_hash}" in cap.out
|
||||
assert (
|
||||
",master,baseline,{},,1,1,{}".format(
|
||||
",master,baseline,{},,1,1,{}".format( # noqa: UP032
|
||||
_get_rev_isotimestamp(baseline_rev), data_hash
|
||||
)
|
||||
in cap.out
|
||||
@@ -682,7 +682,7 @@ def test_metrics_renaming(tmp_dir, dvc, scm, capsys, copy_script):
|
||||
|
||||
assert f",master,baseline,{_get_rev_isotimestamp(scores_rev)},,1,,1" in cap.out
|
||||
assert (
|
||||
",{},baseline,{},,,1,1".format(
|
||||
",{},baseline,{},,,1,1".format( # noqa: UP032
|
||||
metrics_rev[:7], _get_rev_isotimestamp(metrics_rev)
|
||||
)
|
||||
in cap.out
|
||||
|
||||
@@ -848,9 +848,7 @@ def test_repro_dry_no_exec(tmp_dir, dvc):
|
||||
idir,
|
||||
"-o",
|
||||
odir,
|
||||
'python -c \'import shutil; shutil.copytree("{}", "{}")\''.format(
|
||||
idir, odir
|
||||
),
|
||||
f'python -c \'import shutil; shutil.copytree("{idir}", "{odir}")\'',
|
||||
]
|
||||
)
|
||||
assert ret == 0
|
||||
|
||||
@@ -377,7 +377,7 @@ def test_repo_with_removed_plots(tmp_dir, capsys, repo_with_plots):
|
||||
remove("confusion.json")
|
||||
remove("image.png")
|
||||
|
||||
for s in {"show", "diff"}:
|
||||
for s in ("show", "diff"):
|
||||
_, json_result, split_json_result = call(capsys, subcommand=s)
|
||||
errors = [
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ def test_post_run_after_kill(test_queue):
|
||||
except ProcessLookupError:
|
||||
time.sleep(0.1)
|
||||
if time.time() > timeout:
|
||||
raise TimeoutError()
|
||||
raise TimeoutError
|
||||
|
||||
assert result_foo.get(timeout=10) == "foo"
|
||||
|
||||
@@ -132,9 +132,11 @@ def test_celery_queue_kill(test_queue, mocker, force):
|
||||
)
|
||||
with pytest.raises(CannotKillTasksError, match="Task 'foobar' is initializing,"):
|
||||
test_queue.kill(["bar", "foo", "foobar"], force=force)
|
||||
assert kill_mock.called_once_with(mock_entry_foo.stash_rev)
|
||||
assert kill_mock.called_once_with(mock_entry_bar.stash_rev)
|
||||
assert kill_mock.called_once_with(mock_entry_foobar.stash_rev)
|
||||
assert kill_mock.call_args_list == [
|
||||
mocker.call(mock_entry_bar.stash_rev),
|
||||
mocker.call(mock_entry_foo.stash_rev),
|
||||
mocker.call(mock_entry_foobar.stash_rev),
|
||||
]
|
||||
mark_mocker.assert_called_once_with("bar", None)
|
||||
|
||||
|
||||
@@ -157,7 +159,7 @@ def test_celery_queue_kill_invalid(test_queue, mocker, force):
|
||||
|
||||
with pytest.raises(UnresolvedExpNamesError):
|
||||
test_queue.kill(["bar", "foo", "foobar"], force=force)
|
||||
assert kill_mock.called_once_with(
|
||||
kill_mock.assert_called_once_with(
|
||||
{mock_entry_foo: "foo", mock_entry_bar: "bar"}, force
|
||||
)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ from dvc.repo.experiments.utils import check_ref_format, resolve_name, to_studio
|
||||
def commit_exp_ref(tmp_dir, scm, file="foo", contents="foo", name="foo"):
|
||||
tmp_dir.scm_gen(file, contents, commit="init")
|
||||
rev = scm.get_rev()
|
||||
ref = "/".join([EXPS_NAMESPACE, "ab", "c123", name])
|
||||
ref = f"{EXPS_NAMESPACE}/ab/c123/{name}"
|
||||
scm.gitpython.set_ref(ref, rev)
|
||||
return ref, rev
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ def test_unhashable(tmp_dir, dvc, mocker, kwargs):
|
||||
stage = create_stage(Stage, path="stage.dvc", repo=dvc, **kwargs)
|
||||
get_stage_hash = mocker.patch("dvc.stage.cache._get_stage_hash")
|
||||
assert cache.save(stage) is None
|
||||
assert get_stage_hash.not_called
|
||||
get_stage_hash.assert_not_called()
|
||||
with pytest.raises(RunCacheNotFoundError):
|
||||
cache.restore(stage)
|
||||
assert get_stage_hash.not_called
|
||||
get_stage_hash.assert_not_called()
|
||||
|
||||
@@ -69,7 +69,7 @@ def test_stage_update(dvc, mocker):
|
||||
is_repo_import.return_value = True
|
||||
with dvc.lock:
|
||||
stage.update()
|
||||
assert reproduce.called_once_with()
|
||||
reproduce.assert_called_once_with(no_download=None, jobs=None)
|
||||
|
||||
is_repo_import.return_value = False
|
||||
with pytest.raises(StageUpdateError):
|
||||
@@ -92,8 +92,8 @@ def test_stage_run_ignore_sigint(dvc, mocker):
|
||||
|
||||
dvc.run(cmd="path", name="train")
|
||||
|
||||
assert popen.called_once()
|
||||
assert communicate.called_once_with()
|
||||
popen.assert_called_once()
|
||||
communicate.assert_called_once_with()
|
||||
signal_mock.assert_any_call(signal.SIGINT, signal.SIG_IGN)
|
||||
assert signal.getsignal(signal.SIGINT) == signal.default_int_handler
|
||||
|
||||
|
||||
Reference in New Issue
Block a user