mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 15:28:28 +01:00
run: introduce --force option
Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
+8
-1
@@ -268,9 +268,16 @@ def parse_args(argv=None):
|
||||
'--yes',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help="Automatic 'yes' answer to all prompts. E.g. "
|
||||
help="(OBSOLETED, use --force instead) Automatic "
|
||||
"'yes' answer to all prompts. E.g. "
|
||||
"when '.dvc' file exists and dvc asks if you "
|
||||
"want to overwrite it.")
|
||||
run_parser.add_argument(
|
||||
'--force',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help="Overwrite existing dvc file without asking "
|
||||
"for confirmation.")
|
||||
run_parser.add_argument(
|
||||
'command',
|
||||
nargs=argparse.REMAINDER,
|
||||
|
||||
+2
-4
@@ -21,9 +21,6 @@ class CmdRun(CmdBase):
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
if self.args.yes:
|
||||
self.project.prompt.default = True
|
||||
|
||||
self.project.run(cmd=self._joined_cmd(),
|
||||
outs=self.args.outs,
|
||||
outs_no_cache=self.args.outs_no_cache,
|
||||
@@ -31,7 +28,8 @@ class CmdRun(CmdBase):
|
||||
deps=self.args.deps,
|
||||
fname=self.args.file,
|
||||
cwd=self.args.cwd,
|
||||
no_exec=self.args.no_exec)
|
||||
no_exec=self.args.no_exec,
|
||||
overwrite=(self.args.yes or self.args.force))
|
||||
except DvcException as ex:
|
||||
self.project.logger.error('Failed to run command', ex)
|
||||
return 1
|
||||
|
||||
@@ -185,6 +185,23 @@ class TestCmdRun(TestDvc):
|
||||
self.assertEqual(ret, 252)
|
||||
|
||||
|
||||
class TestCmdRunOverwrite(TestDvc):
|
||||
def test(self):
|
||||
ret = main(['run',
|
||||
'-d', self.FOO,
|
||||
'-d', self.CODE,
|
||||
'-o', 'out',
|
||||
'-f', 'out.dvc',
|
||||
'python', self.CODE, self.FOO, 'out'])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
ret = main(['run',
|
||||
'--force',
|
||||
'-f', 'out.dvc',
|
||||
'-d', self.BAR])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
|
||||
class TestRunDeterministicBase(TestDvc):
|
||||
def setUp(self):
|
||||
super(TestRunDeterministicBase, self).setUp()
|
||||
|
||||
Reference in New Issue
Block a user