Skip to content

Commit c5fff51

Browse files
committed
pipelines: fix edges gathering
1 parent 05cc023 commit c5fff51

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

dvc/command/pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _build_graph(self, target, commands, outs):
6161
for out in stage.outs:
6262
edges.append((str(out), str(dep)))
6363
else:
64-
for from_stage, to_stage in networkx.dfs_edges(G, target_stage):
64+
for from_stage, to_stage in networkx.edge_dfs(G, target_stage):
6565
if commands:
6666
if to_stage.cmd is None:
6767
continue

tests/func/test_pipeline.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,29 @@ def locked_stage(self):
237237

238238
pipelines = self.dvc.pipelines
239239
self.assertEqual(len(pipelines), 0)
240+
241+
242+
def test_split_pipeline(tmp_dir, dvc):
243+
tmp_dir.dvc_gen("data", "source file content")
244+
dvc.run(
245+
deps=["data"],
246+
outs=["data_train", "data_valid"],
247+
cmd="echo train >> data_train && echo valid >> data_valid",
248+
)
249+
stage = dvc.run(
250+
deps=["data_train", "data_valid"],
251+
outs=["result"],
252+
cmd="echo result >> result",
253+
)
254+
255+
command = CmdPipelineShow([])
256+
nodes, edges, is_tree = command._build_graph(
257+
stage.path, commands=False, outs=True
258+
)
259+
assert set(nodes) == {"data", "data_train", "data_valid", "result"}
260+
assert set(edges) == {
261+
("result", "data_train"),
262+
("result", "data_valid"),
263+
("data_train", "data"),
264+
("data_valid", "data"),
265+
}

0 commit comments

Comments
 (0)