From c5fff5183b178546823e686c79130587d3741ef8 Mon Sep 17 00:00:00 2001 From: pawel Date: Fri, 28 Feb 2020 17:54:45 +0100 Subject: [PATCH] pipelines: fix edges gathering --- dvc/command/pipeline.py | 2 +- tests/func/test_pipeline.py | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/dvc/command/pipeline.py b/dvc/command/pipeline.py index d5b7dbe86e..027f82954e 100644 --- a/dvc/command/pipeline.py +++ b/dvc/command/pipeline.py @@ -61,7 +61,7 @@ def _build_graph(self, target, commands, outs): for out in stage.outs: edges.append((str(out), str(dep))) else: - for from_stage, to_stage in networkx.dfs_edges(G, target_stage): + for from_stage, to_stage in networkx.edge_dfs(G, target_stage): if commands: if to_stage.cmd is None: continue diff --git a/tests/func/test_pipeline.py b/tests/func/test_pipeline.py index 31ed66748e..64d099ba51 100644 --- a/tests/func/test_pipeline.py +++ b/tests/func/test_pipeline.py @@ -237,3 +237,29 @@ def locked_stage(self): pipelines = self.dvc.pipelines self.assertEqual(len(pipelines), 0) + + +def test_split_pipeline(tmp_dir, dvc): + tmp_dir.dvc_gen("data", "source file content") + dvc.run( + deps=["data"], + outs=["data_train", "data_valid"], + cmd="echo train >> data_train && echo valid >> data_valid", + ) + stage = dvc.run( + deps=["data_train", "data_valid"], + outs=["result"], + cmd="echo result >> result", + ) + + command = CmdPipelineShow([]) + nodes, edges, is_tree = command._build_graph( + stage.path, commands=False, outs=True + ) + assert set(nodes) == {"data", "data_train", "data_valid", "result"} + assert set(edges) == { + ("result", "data_train"), + ("result", "data_valid"), + ("data_train", "data"), + ("data_valid", "data"), + }