diff --git a/dvc/output.py b/dvc/output.py index 95d3f2dea..3448e1fe2 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -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' diff --git a/dvc/project.py b/dvc/project.py index 3edabeae4..e5aace784 100644 --- a/dvc/project.py +++ b/dvc/project.py @@ -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)