mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
apply: add --no-force deprecation message
This commit is contained in:
committed by
Peter Rowlands (변기호)
parent
d3182e0dd9
commit
e218431f64
@@ -4,12 +4,20 @@ import logging
|
|||||||
from dvc.cli import completion
|
from dvc.cli import completion
|
||||||
from dvc.cli.command import CmdBase
|
from dvc.cli.command import CmdBase
|
||||||
from dvc.cli.utils import append_doc_link
|
from dvc.cli.utils import append_doc_link
|
||||||
|
from dvc.ui import ui
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CmdExperimentsApply(CmdBase):
|
class CmdExperimentsApply(CmdBase):
|
||||||
def run(self):
|
def run(self):
|
||||||
|
if not self.args.force:
|
||||||
|
ui.write(
|
||||||
|
"The --no-force option is deprecated and will be removed in a future"
|
||||||
|
" DVC release. To revert the result of 'exp apply', run:\n"
|
||||||
|
"\n\tgit reset --hard\n"
|
||||||
|
"\tgit stash apply refs/exps/apply/stash\n"
|
||||||
|
)
|
||||||
self.repo.experiments.apply(self.args.experiment)
|
self.repo.experiments.apply(self.args.experiment)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -24,6 +32,12 @@ def add_parser(experiments_subparsers, parent_parser):
|
|||||||
help=EXPERIMENTS_APPLY_HELP,
|
help=EXPERIMENTS_APPLY_HELP,
|
||||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
)
|
)
|
||||||
|
experiments_apply_parser.add_argument(
|
||||||
|
"--no-force",
|
||||||
|
action="store_false",
|
||||||
|
dest="force",
|
||||||
|
help="Fail if this command would overwrite conflicting changes.",
|
||||||
|
)
|
||||||
experiments_apply_parser.add_argument(
|
experiments_apply_parser.add_argument(
|
||||||
"experiment", help="Experiment to be applied."
|
"experiment", help="Experiment to be applied."
|
||||||
).complete = completion.EXPERIMENT
|
).complete = completion.EXPERIMENT
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ from .test_repro import common_arguments as repro_arguments
|
|||||||
|
|
||||||
|
|
||||||
def test_experiments_apply(dvc, scm, mocker):
|
def test_experiments_apply(dvc, scm, mocker):
|
||||||
cli_args = parse_args(["experiments", "apply", "--no-force", "exp_rev"])
|
cli_args = parse_args(["experiments", "apply", "exp_rev"])
|
||||||
assert cli_args.func == CmdExperimentsApply
|
assert cli_args.func == CmdExperimentsApply
|
||||||
|
|
||||||
cmd = cli_args.func(cli_args)
|
cmd = cli_args.func(cli_args)
|
||||||
@@ -35,7 +35,7 @@ def test_experiments_apply(dvc, scm, mocker):
|
|||||||
|
|
||||||
assert cmd.run() == 0
|
assert cmd.run() == 0
|
||||||
|
|
||||||
m.assert_called_once_with(cmd.repo, "exp_rev", force=False)
|
m.assert_called_once_with(cmd.repo, "exp_rev")
|
||||||
|
|
||||||
|
|
||||||
def test_experiments_diff(dvc, scm, mocker):
|
def test_experiments_diff(dvc, scm, mocker):
|
||||||
|
|||||||
Reference in New Issue
Block a user