From bc8edde311235193f01fcf0170a729be35cdaedb Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 4 Jan 2018 18:20:25 -0800 Subject: [PATCH 1/2] dvc repro: report status and command --- dvc/stage.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dvc/stage.py b/dvc/stage.py index e0fdfa883..27b4eb9c0 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -8,6 +8,7 @@ from dvc.data_cloud import file_md5 from dvc.exceptions import DvcException from dvc.executor import Executor + class OutputError(DvcException): def __init__(self, path, msg): super(OutputError, self).__init__('Output file \'{}\' error: {}'.format(path, msg)) @@ -200,6 +201,10 @@ class Stage(object): self.deps = deps self.locked = locked + @property + def relpath(self): + return os.path.relpath(self.path, '.') + @staticmethod def is_stage_file(path): if not os.path.isfile(path): @@ -236,8 +241,10 @@ class Stage(object): if self.cmd: # Removing outputs only if we actually have command to reproduce self.remove_outs() + + self.project.logger.info("Reproducing {}:\n\t{}".format(self.relpath, self.cmd)) self.run() - self.project.logger.debug("{} reproduced".format(self.path)) + self.project.logger.debug("{} was reproduced".format(self.relpath)) @staticmethod def loadd(project, d, path): From 789b2e0b5b9b830819d26bb485a72cbb77f41ef2 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 4 Jan 2018 18:33:25 -0800 Subject: [PATCH 2/2] Bugfix: do not touch cache file if it does not exist --- dvc/stage.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dvc/stage.py b/dvc/stage.py index 27b4eb9c0..749555df3 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -178,6 +178,16 @@ class Output(object): return stage return None + def remove(self): + if not os.path.exists(self.path): + return + + self.project.logger.debug("Removing '{}'".format(self.path)) + os.chmod(self.path, stat.S_IWUSR) + os.unlink(self.path) + if os.path.exists(self.cache): + os.chmod(self.cache, stat.S_IREAD) + class Dependency(Output): pass @@ -224,11 +234,7 @@ class Stage(object): def remove_outs(self): for out in self.outs: - if os.path.exists(out.path): - self.project.logger.debug("Removing '{}'".format(out.path)) - os.chmod(out.path, stat.S_IWUSR) - os.unlink(out.path) - os.chmod(out.cache, stat.S_IREAD) + out.remove() def remove(self): self.remove_outs()