Skip to content

Commit

Permalink
pipeline: fix --outs output (iterative#3507)
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop authored Mar 18, 2020
1 parent 498ee50 commit 7edee65
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
27 changes: 11 additions & 16 deletions dvc/command/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,21 @@ def _build_graph(self, target, commands, outs):
elif outs:
for out in stage.outs:
nodes.add(str(out))
for dep in stage.deps:
nodes.add(str(dep))
else:
nodes.add(stage.relpath)

edges = []

if outs:
for stage in networkx.dfs_preorder_nodes(G, target_stage):
for dep in stage.deps:
for out in stage.outs:
edges.append((str(out), str(dep)))
else:
for from_stage, to_stage in networkx.edge_dfs(G, target_stage):
if commands:
if to_stage.cmd is None:
continue
edges.append((from_stage.cmd, to_stage.cmd))
else:
edges.append((from_stage.relpath, to_stage.relpath))
for from_stage, to_stage in networkx.edge_dfs(G, target_stage):
if commands:
if to_stage.cmd is None:
continue
edges.append((from_stage.cmd, to_stage.cmd))
elif outs:
for from_out in from_stage.outs:
for to_out in to_stage.outs:
edges.append((str(from_out), str(to_out)))
else:
edges.append((from_stage.relpath, to_stage.relpath))

return list(nodes), edges, networkx.is_tree(G)

Expand Down
9 changes: 6 additions & 3 deletions tests/func/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,18 @@ def locked_stage(self):
self.assertEqual(len(pipelines), 0)


def test_split_pipeline(tmp_dir, dvc):
def test_split_pipeline(tmp_dir, scm, dvc):
tmp_dir.scm_gen("git_dep1", "git_dep1")
tmp_dir.scm_gen("git_dep2", "git_dep2")

tmp_dir.dvc_gen("data", "source file content")
dvc.run(
deps=["data"],
deps=["git_dep1", "data"],
outs=["data_train", "data_valid"],
cmd="echo train >> data_train && echo valid >> data_valid",
)
stage = dvc.run(
deps=["data_train", "data_valid"],
deps=["git_dep2", "data_train", "data_valid"],
outs=["result"],
cmd="echo result >> result",
)
Expand Down

0 comments on commit 7edee65

Please sign in to comment.