exp: Generate a human-readable name beforehand.

- Add `get_random_exp_name` to utils.
Generates a name (`f"{adjective}-{noun}"`) by randomly chosing pairs of adjetive, noun.
Recieves `scm` and `baseline_rev` and retries the random choice until a non-existing ref is found.

Closes https://github.com/iterative/dvc/issues/8650
This commit is contained in:
David de la Iglesia Castro
2022-12-09 10:32:38 +01:00
parent 334f297ad3
commit bb7512687c
6 changed files with 67 additions and 24 deletions
+2 -2
View File
@@ -684,7 +684,7 @@ def test_experiments_workspace_not_log_exception(caplog, dvc, scm):
assert not caplog.text
def test_run_env(tmp_dir, dvc, scm):
def test_run_env(tmp_dir, dvc, scm, mocker):
dump_run_env = dedent(
"""\
import os
@@ -703,7 +703,7 @@ def test_run_env(tmp_dir, dvc, scm):
)
dvc.experiments.run()
assert (tmp_dir / "DVC_EXP_BASELINE_REV").read_text().strip() == baseline
assert (tmp_dir / "DVC_EXP_NAME").read_text().strip() == ""
assert (tmp_dir / "DVC_EXP_NAME").read_text().strip() != ""
dvc.experiments.run(name="foo")
assert (tmp_dir / "DVC_EXP_BASELINE_REV").read_text().strip() == baseline