diff --git a/dvc/command/experiments.py b/dvc/command/experiments.py index f4b85e045..7281d6d03 100644 --- a/dvc/command/experiments.py +++ b/dvc/command/experiments.py @@ -808,7 +808,7 @@ class CmdExperimentsInit(CmdBase): defaults = {} if not self.args.explicit: - config = {} # TODO + config = self.repo.config["exp"] defaults.update({**self.DEFAULTS, **config}) cli_args = compact( diff --git a/dvc/config_schema.py b/dvc/config_schema.py index 13d5a73ae..42c5ee37f 100644 --- a/dvc/config_schema.py +++ b/dvc/config_schema.py @@ -256,4 +256,13 @@ SCHEMA = { Optional("parametrization", default=True): Bool, }, "plots": {"html_template": str}, + "exp": { + "code": str, + "data": str, + "models": str, + "metrics": str, + "params": str, + "plots": str, + "live": str, + }, } diff --git a/tests/unit/command/test_experiments.py b/tests/unit/command/test_experiments.py index ca9e6bbd1..1439c9d76 100644 --- a/tests/unit/command/test_experiments.py +++ b/tests/unit/command/test_experiments.py @@ -405,3 +405,23 @@ def test_show_experiments(capsys): "3000,1,0.5843640011189556,0.9544670443829399,3000,1,20170428,100,36" in cap.out ) + + +def test_experiments_init_config(dvc, mocker): + with dvc.config.edit() as conf: + conf["exp"] = {"code": "new_src", "models": "new_models"} + + m = mocker.patch("dvc.repo.experiments.init.init") + cli_args = parse_args(["exp", "init", "cmd"]) + cmd = cli_args.func(cli_args) + + assert cmd.run() == 0 + assert m.call_args[1]["defaults"] == { + "code": "new_src", + "models": "new_models", + "data": "data", + "metrics": "metrics.json", + "params": "params.yaml", + "plots": "plots", + "live": "dvclive", + }