dvc: reuse collected stages

Fixes #710
Fixes #711

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-05-17 00:40:47 +03:00
parent 679bcae9d4
commit bde70498cb
2 changed files with 9 additions and 10 deletions
-7
View File
@@ -135,13 +135,6 @@ class Dependency(object):
def loads_from(cls, project, s_list, cwd=os.curdir):
return [cls.loads(project, x, cwd=cwd) for x in s_list]
def stage(self):
for stage in self.project.stages():
for out in stage.outs:
if self.path == out.path:
return stage
return None
class Output(Dependency):
PARAM_CACHE = 'cache'
+9 -3
View File
@@ -239,7 +239,7 @@ class Project(object):
else:
stages = self.stages()
for stage in self.stages():
for stage in stages:
status.update(stage.status())
return status
@@ -326,12 +326,18 @@ class Project(object):
def graph(self):
G = nx.DiGraph()
stages = self.stages()
for stage in self.stages():
outs_map = {}
for stage in stages:
for o in stage.outs:
outs_map[o.path] = stage
for stage in stages:
node = os.path.relpath(stage.path, self.root_dir)
G.add_node(node, stage=stage)
for dep in stage.deps:
dep_stage = dep.stage()
dep_stage = outs_map.get(dep.path, None)
if not dep_stage:
continue
dep_node = os.path.relpath(dep_stage.path, self.root_dir)