8
8
logger = logging .getLogger (__name__ )
9
9
10
10
11
+ def _stage_repr (stage ):
12
+ from dvc .stage import PipelineStage
13
+
14
+ return (
15
+ "{}:{}" .format (stage .relpath , stage .name )
16
+ if isinstance (stage , PipelineStage )
17
+ else stage .relpath
18
+ )
19
+
20
+
11
21
class CmdPipelineShow (CmdBase ):
12
22
def _show (self , target , commands , outs , locked ):
13
23
import networkx
14
- from dvc .dvcfile import Dvcfile
24
+ from dvc import dvcfile
25
+ from dvc .utils import parse_target
15
26
16
- stage = Dvcfile (self .repo , target ).load ()
17
- G = self .repo .graph
27
+ path , name = parse_target (target )
28
+ stage = dvcfile .Dvcfile (self .repo , path ).load_one (name )
29
+ G = self .repo .pipeline_graph
18
30
stages = networkx .dfs_postorder_nodes (G , stage )
19
-
20
31
if locked :
21
32
stages = [s for s in stages if s .locked ]
22
33
@@ -29,14 +40,16 @@ def _show(self, target, commands, outs, locked):
29
40
for out in stage .outs :
30
41
logger .info (str (out ))
31
42
else :
32
- logger .info (stage . path_in_repo )
43
+ logger .info (_stage_repr ( stage ) )
33
44
34
- def _build_graph (self , target , commands , outs ):
45
+ def _build_graph (self , target , commands = False , outs = False ):
35
46
import networkx
36
- from dvc . dvcfile import Dvcfile
47
+ from dvc import dvcfile
37
48
from dvc .repo .graph import get_pipeline
49
+ from dvc .utils import parse_target
38
50
39
- target_stage = Dvcfile (self .repo , target ).load ()
51
+ path , name = parse_target (target )
52
+ target_stage = dvcfile .Dvcfile (self .repo , path ).load_one (name )
40
53
G = get_pipeline (self .repo .pipelines , target_stage )
41
54
42
55
nodes = set ()
@@ -49,7 +62,7 @@ def _build_graph(self, target, commands, outs):
49
62
for out in stage .outs :
50
63
nodes .add (str (out ))
51
64
else :
52
- nodes .add (stage . relpath )
65
+ nodes .add (_stage_repr ( stage ) )
53
66
54
67
edges = []
55
68
for from_stage , to_stage in networkx .edge_dfs (G , target_stage ):
@@ -62,7 +75,7 @@ def _build_graph(self, target, commands, outs):
62
75
for to_out in to_stage .outs :
63
76
edges .append ((str (from_out ), str (to_out )))
64
77
else :
65
- edges .append ((from_stage . relpath , to_stage . relpath ))
78
+ edges .append ((_stage_repr ( from_stage ), _stage_repr ( to_stage ) ))
66
79
67
80
return list (nodes ), edges , networkx .is_tree (G )
68
81
@@ -150,7 +163,7 @@ def run(self):
150
163
pipelines = self .repo .pipelines
151
164
for pipeline in pipelines :
152
165
for stage in pipeline :
153
- logger .info (stage . relpath )
166
+ logger .info (_stage_repr ( stage ) )
154
167
if len (pipeline ) != 0 :
155
168
logger .info ("=" * 80 )
156
169
logger .info ("{} pipelines total" .format (len (pipelines )))
0 commit comments