mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
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.
22 lines
866 B
Python
22 lines
866 B
Python
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]
|
|
mocker.patch(
|
|
"dvc.repo.experiments.utils.random.Random", return_value=mocked_generator
|
|
)
|
|
|
|
ref = first(dvc.experiments.run(exp_stage.addressing, params=["foo=1"]))
|
|
assert dvc.experiments.get_exact_name([ref])[ref] == "0-0"
|
|
|
|
# Causes 1 retry
|
|
ref = first(dvc.experiments.run(exp_stage.addressing, params=["foo=2"]))
|
|
assert dvc.experiments.get_exact_name([ref])[ref] == "1-1"
|
|
|
|
tmp_dir.scm_gen({"foo": "bar"}, commit="foo")
|
|
# Can use same name because of different baseline_rev
|
|
ref = first(dvc.experiments.run(exp_stage.addressing, params=["foo=1"]))
|
|
assert dvc.experiments.get_exact_name([ref])[ref] == "0-0"
|