mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-11 07:18:28 +01:00
Merge pull request #319 from dataversioncontrol/new_design_fixes_2
New design fixes 2
This commit is contained in:
+2
-2
@@ -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.')
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-2
@@ -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):
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
+2
-2
@@ -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):
|
||||
|
||||
+5
-3
@@ -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)
|
||||
|
||||
+1
-1
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user