Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exp: preserve hidden alias -M for --message #10006

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dvc/commands/experiments/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,8 @@ def _add_run_common(parser):
default=None,
help="Custom commit message to use when committing the experiment.",
)
parser.add_argument(
"-M", # obsolete
dest="message",
help=argparse.SUPPRESS,
)
5 changes: 5 additions & 0 deletions dvc/commands/experiments/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ def add_parser(experiments_subparsers, parent_parser):
default=None,
help="Custom commit message to use when committing the experiment.",
)
save_parser.add_argument(
"-M", # obsolete
dest="message",
help=argparse.SUPPRESS,
)
save_parser.set_defaults(func=CmdExperimentsSave)
26 changes: 24 additions & 2 deletions tests/unit/command/test_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,27 @@ def test_experiments_run(dvc, scm, mocker):
cmd.repo.experiments.run.assert_called_with(**default_arguments)


@pytest.mark.parametrize("flag", ["-m", "-M", "--message"])
def test_experiments_run_message(dvc, scm, mocker, flag):
default_arguments = {
"params": [],
"name": None,
"queue": False,
"run_all": False,
"jobs": 1,
"tmp_dir": False,
"copy_paths": [],
"message": "mymessage",
}
default_arguments.update(repro_arguments)

cmd = CmdExperimentsRun(parse_args(["exp", "run", flag, "mymessage"]))
mocker.patch.object(cmd.repo, "reproduce")
mocker.patch.object(cmd.repo.experiments, "run")
cmd.run()
cmd.repo.experiments.run.assert_called_with(**default_arguments)


def test_experiments_branch(dvc, scm, mocker):
m = mocker.patch("dvc.repo.experiments.branch.branch", return_value={})

Expand Down Expand Up @@ -479,8 +500,9 @@ def test_experiments_save(dvc, scm, mocker):
)


def test_experiments_save_message(dvc, scm, mocker):
cli_args = parse_args(["exp", "save", "-m", "custom commit message"])
@pytest.mark.parametrize("flag", ["-m", "-M", "--message"])
def test_experiments_save_message(dvc, scm, mocker, flag):
cli_args = parse_args(["exp", "save", flag, "custom commit message"])
assert cli_args.func == CmdExperimentsSave

cmd = cli_args.func(cli_args)
Expand Down