Use output filename as a default stage file name but do not change dir

This commit is contained in:
Dmitry
2017-12-24 18:31:15 -08:00
parent 33ccb61d45
commit 863e0e4b14
2 changed files with 22 additions and 2 deletions
-1
View File
@@ -118,7 +118,6 @@ def parse_args(argv=None):
help='Lock data item - disable reproduction.')
run_parser.add_argument('-f',
'--file',
default=Stage.STAGE_FILE,
help='Specify name of the state file')
run_parser.add_argument('-c',
'--cwd',
+22 -1
View File
@@ -1,14 +1,35 @@
import os
from dvc.command.common.base import CmdBase
from dvc.logger import Logger
from dvc.stage import Stage
class CmdRun(CmdBase):
def run(self):
fname = self.get_stage_file(self.args.file, self.args.outs, self.args.outs_no_cache)
self.project.run(cmd=' '.join(self.args.command),
outs=self.args.outs,
outs_no_cache=self.args.outs_no_cache,
deps=self.args.deps,
deps_no_cache=self.args.deps_no_cache,
locked=self.args.lock,
fname=self.args.file,
fname=fname,
cwd=self.args.cwd)
return 0
@staticmethod
def get_stage_file(args_file, args_out, args_outs_no_cache):
if args_file:
return args_file
if args_out or args_outs_no_cache:
result = args_out[0] if args_out else args_outs_no_cache[0]
result = os.path.basename(result)
result += Stage.STAGE_FILE_SUFFIX
else:
result = Stage.STAGE_FILE
Logger.info(u'Using \'{}\' as a stage file'.format(result))
return result