| 5 | |
| 6 | |
| 7 | def test_apply(tmp_dir, scm, dvc, exp_stage): |
| 8 | from dvc.exceptions import InvalidArgumentError |
| 9 | |
| 10 | results = dvc.experiments.run(exp_stage.addressing, params=["foo=2"], tmp_dir=True) |
| 11 | exp_a = first(results) |
| 12 | |
| 13 | dvc.experiments.run( |
| 14 | exp_stage.addressing, params=["foo=3"], tmp_dir=True, name="foo" |
| 15 | ) |
| 16 | |
| 17 | with pytest.raises(InvalidArgumentError): |
| 18 | dvc.experiments.apply("bar") |
| 19 | |
| 20 | dvc.experiments.apply(exp_a) |
| 21 | assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 2" |
| 22 | assert (tmp_dir / "metrics.yaml").read_text().strip() == "foo: 2" |
| 23 | |
| 24 | dvc.experiments.apply("foo") |
| 25 | assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 3" |
| 26 | assert (tmp_dir / "metrics.yaml").read_text().strip() == "foo: 3" |
| 27 | |
| 28 | |
| 29 | def test_apply_failed(tmp_dir, scm, dvc, failed_exp_stage, mocker): |