mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
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:
@@ -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'"
|
||||
|
||||
@@ -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"},
|
||||
]
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"},
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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")]
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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,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]
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user