From 7edee656daec7a73ccfc9f1d4d730a59ff17a635 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 18 Mar 2020 23:03:41 +0200 Subject: [PATCH] pipeline: fix `--outs` output (#3507) Fixes #3497 --- dvc/command/pipeline.py | 27 +++++++++++---------------- tests/func/test_pipeline.py | 9 ++++++--- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/dvc/command/pipeline.py b/dvc/command/pipeline.py index 027f82954..6aedb086a 100644 --- a/dvc/command/pipeline.py +++ b/dvc/command/pipeline.py @@ -48,26 +48,21 @@ class CmdPipelineShow(CmdBase): 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) diff --git a/tests/func/test_pipeline.py b/tests/func/test_pipeline.py index 64d099ba5..51ee639fb 100644 --- a/tests/func/test_pipeline.py +++ b/tests/func/test_pipeline.py @@ -239,15 +239,18 @@ class TestDvcRepoPipeline(TestDvc): 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", )