diff --git a/dvc/cli.py b/dvc/cli.py index 4d4cf04bd..ba42d9f5b 100644 --- a/dvc/cli.py +++ b/dvc/cli.py @@ -103,8 +103,8 @@ def parse_args(argv=None): action='append', default=[], help='Declare output data file (sync to cloud) for reproducible cmd.') - run_parser.add_argument('-r', - '--reg', + run_parser.add_argument('-g', + '--out-git', action='append', default=[], help='Declare output regular file (sync to Git) for reproducible cmd.') diff --git a/dvc/command/checkout.py b/dvc/command/checkout.py index fac80661e..9796c35fa 100644 --- a/dvc/command/checkout.py +++ b/dvc/command/checkout.py @@ -53,8 +53,7 @@ class CmdCheckout(CmdBase): for item in removed_items_set: path = item.data.relative if not os.path.exists(path): - print(u'Remove \'{}\'.'.format(path)) - Logger.warn(u'File \'{}\' does not exist'.format(path)) + Logger.debug(u'File \'{}\' does not exist'.format(path)) else: Logger.info(u'Remove \'{}\''.format(path)) os.remove(path) diff --git a/dvc/command/common/command_file.py b/dvc/command/common/command_file.py index 62aee62e8..4008f2b85 100644 --- a/dvc/command/common/command_file.py +++ b/dvc/command/common/command_file.py @@ -9,14 +9,14 @@ class CommandFile(StateFileBase): PARAM_CMD = 'cmd' PARAM_OUT = 'out' - PARAM_REG = 'reg' + PARAM_OUT_GIT = 'out-git' PARAM_DEPS = 'deps' PARAM_LOCK = 'locked' - def __init__(self, cmd, out, reg, deps, locked, fname): + def __init__(self, cmd, out, out_git, deps, locked, fname): self.cmd = cmd self.out = out - self.reg = reg + self.out_git = out_git self.deps = deps self.locked = locked self.fname = fname @@ -26,7 +26,7 @@ class CommandFile(StateFileBase): data = { self.PARAM_CMD: self.cmd, self.PARAM_OUT: self.out, - self.PARAM_REG: self.reg, + self.PARAM_OUT_GIT: self.out_git, self.PARAM_DEPS: self.deps, self.PARAM_LOCK: self.locked } @@ -44,7 +44,7 @@ class CommandFile(StateFileBase): def loadd(data, fname=None): return CommandFile(data.get(CommandFile.PARAM_CMD, None), data.get(CommandFile.PARAM_OUT, None), - data.get(CommandFile.PARAM_REG, None), + data.get(CommandFile.PARAM_OUT_GIT, None), data.get(CommandFile.PARAM_DEPS, None), data.get(CommandFile.PARAM_LOCK, None), fname) diff --git a/dvc/command/repro.py b/dvc/command/repro.py index 78c52ff4a..bdeba08ee 100644 --- a/dvc/command/repro.py +++ b/dvc/command/repro.py @@ -166,7 +166,7 @@ class ReproChange(object): ReproChange(item, self._cmd_obj, self._recursive, self._force).reproduce() if md5 != os.path.basename(item.cache.relative): - self.log_repro_reason('data item {} was changed'.format(path)) + self.log_repro_reason('data item {} was changed - md5 sum doesn\'t match'.format(path)) return True return False diff --git a/dvc/command/run.py b/dvc/command/run.py index ddb00c352..193bd0cde 100644 --- a/dvc/command/run.py +++ b/dvc/command/run.py @@ -21,7 +21,7 @@ class CmdRun(CmdBase): command = CommandFile.load(cmd) except Exception as exc: Logger.debug("Failed to load {}: {}".format(cmd, str(exc))) - command = CommandFile(cmd, self.parsed_args.out, self.parsed_args.reg, + command = CommandFile(cmd, self.parsed_args.out, self.parsed_args.out_git, self.parsed_args.deps, self.parsed_args.lock, None) self.run_command(self.settings, command) @@ -32,7 +32,7 @@ class CmdRun(CmdBase): Executor.exec_cmd_only_success(command.cmd, shell=True) CmdRun.apply_to_files(command.out, command, CmdRun._create_cache_and_state_files, settings) - CmdRun.apply_to_files(command.reg, command, CmdRun._create_state_file, settings) + CmdRun.apply_to_files(command.out_git, command, CmdRun._create_state_file, settings) @staticmethod def apply_to_files(files, command, func, settings): diff --git a/dvc/executor.py b/dvc/executor.py index 09dcfe38a..813829801 100644 --- a/dvc/executor.py +++ b/dvc/executor.py @@ -58,5 +58,6 @@ class Executor(object): code, out, err = Executor.exec_cmd(cmd, stdout_file=stdout_file, stderr_file=stderr_file, cwd=cwd, shell=shell) if code != 0: - raise ExecutorError('Git command error ({}):\n{}\n{}'.format(' '.join(cmd), out, err)) + cmd_str = ' '.join(cmd) if type(cmd) == list else cmd + raise ExecutorError('Git command error ({}):\n{}\n{}'.format(cmd_str, out, err)) return out diff --git a/dvc/git_wrapper.py b/dvc/git_wrapper.py index 5230da715..f9800b04d 100644 --- a/dvc/git_wrapper.py +++ b/dvc/git_wrapper.py @@ -427,7 +427,7 @@ class GitWrapper(GitWrapperI): git_cmd = u'git ls-tree --name-only -r {}'.format(commit) lines = Executor.exec_cmd_only_success(git_cmd.split()).split('\n') - return filter(lambda s: s.startswith(ConfigI.STATE_DIR), lines) + return list(filter(lambda s: s.startswith(ConfigI.STATE_DIR), lines)) @staticmethod def branches(regexp): @@ -443,7 +443,7 @@ class GitWrapper(GitWrapperI): return lines reg = re.compile(regexp) - return filter(reg.search, lines) + return list(filter(reg.search, lines)) @staticmethod def get_file_content(fname, branch): diff --git a/dvc/path/factory.py b/dvc/path/factory.py index 48c0657a5..85da563ab 100644 --- a/dvc/path/factory.py +++ b/dvc/path/factory.py @@ -1,4 +1,5 @@ import os +import re from dvc.config import ConfigI from dvc.path.data_item import DataItem, DataItemError, DataDirError @@ -72,9 +73,10 @@ class PathFactory(object): return data_items def data_items_from_states(self, states, existing=True): - return map(lambda s: self.data_item_from_dvc_path(self.state_path_to_dvc_path(s), existing), - states) + return [self.data_item_from_dvc_path(self.state_path_to_dvc_path(s), existing) + for s in states] @staticmethod def state_path_to_dvc_path(state): - return os.path.relpath(state, ConfigI.STATE_DIR)[:-len(DataItem.STATE_FILE_SUFFIX)] + filename = os.path.relpath(state, ConfigI.STATE_DIR) + return re.sub(DataItem.STATE_FILE_SUFFIX + '$', '', filename) diff --git a/dvc/utils.py b/dvc/utils.py index 3a42db73a..2a43660ec 100644 --- a/dvc/utils.py +++ b/dvc/utils.py @@ -83,7 +83,7 @@ def map_progress(func, targets, n_threads): finally: progress.finish() - return zip(targets, ret) + return list(zip(targets, ret)) def parse_target_metric_file(file_name):