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

run: hide and forbid --file for multistage files #4086

Merged
merged 1 commit into from
Jun 23, 2020
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
4 changes: 1 addition & 3 deletions dvc/command/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ def add_parser(subparsers, parent_parser):
metavar="<path>",
)
run_parser.add_argument(
"--file",
help="Specify name of the DVC-file this command will generate.",
metavar="<filename>",
"--file", metavar="<filename>", help=argparse.SUPPRESS,
)
run_parser.add_argument(
"-w",
Expand Down
6 changes: 6 additions & 0 deletions dvc/repo/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ def run(self, fname=None, no_exec=False, single_stage=False, **kwargs):
"`-n|--name` is incompatible with `--single-stage`"
)

if stage_name and fname:
raise InvalidArgumentError(
"`--file` is currently incompatible with `-n|--name` "
"and requires `--single-stage`"
)

if not stage_name and not single_stage:
raise InvalidArgumentError("`-n|--name` is required")

Expand Down
Empty file added tests/unit/repo/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions tests/unit/repo/test_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest

from dvc.exceptions import InvalidArgumentError


def test_file(tmp_dir, dvc):
msg = (
"`--file` is currently incompatible with `-n|--name` "
"and requires `--single-stage`"
)
with pytest.raises(InvalidArgumentError, match=msg):
dvc.run(fname="path/dvc.yaml", name="my", cmd="mycmd")