@@ -83,31 +83,49 @@ def workflow_clean(document): # type: (MutableMapping[Text, Any]) -> None
8383 step = new_step
8484 step_id = step .pop ("id" )
8585 step_id_len = len (step_id )+ 1
86- step ["out" ] = [outp ["id" ][step_id_len :] for outp in
87- step ["outputs" ]]
86+ step ["out" ] = []
87+ for outp in step ["outputs" ]:
88+ clean_outp_id = outp ["id" ]
89+ if clean_outp_id .startswith (step_id ):
90+ clean_outp_id = clean_outp_id [step_id_len :]
91+ step ["out" ].append (clean_outp_id )
8892 del step ["outputs" ]
8993 ins = CommentedMap ()
9094 for inp in step ["inputs" ]:
91- ident = inp ["id" ][step_id_len :] # remove step id prefix
95+ ident = inp ["id" ]
96+ if ident .startswith (step_id ):
97+ ident = ident [step_id_len :]
9298 if 'source' in inp :
9399 inp ["source" ] = inp ["source" ].lstrip ('#' ).replace ("." , "/" )
94100 del inp ["id" ]
95101 if len (inp ) > 1 :
96102 ins [ident ] = inp
97103 elif len (inp ) == 1 :
98- ins [ident ] = inp .popitem ()[1 ]
104+ if "source" in inp :
105+ ins [ident ] = inp .popitem ()[1 ]
106+ else :
107+ ins [ident ] = inp
99108 else :
100109 ins [ident ] = {}
101110 step ["in" ] = ins
102111 del step ["inputs" ]
103112 if "scatter" in step :
104113 if isinstance (step ["scatter" ], (str , Text )) == 1 :
105- step ["scatter" ] = step ["scatter" ][step_id_len :]
114+ source = step ["scatter" ]
115+ if source .startswith (step_id ):
116+ source = source [step_id_len :]
117+ step ["scatter" ] = source
106118 elif isinstance (step ["scatter" ], list ) and len (step ["scatter" ]) > 1 :
107- step ["scatter" ] = [source [step_id_len :] for
108- source in step ["scatter" ]]
119+ step ["scatter" ] = []
120+ for source in step ["scatter" ]:
121+ if source .startswith (step_id ):
122+ source = source [step_id_len :]
123+ step ["scatter" ].append (source )
109124 else :
110- step ["scatter" ] = step ["scatter" ][0 ][step_id_len :]
125+ source = step ["scatter" ][0 ]
126+ if source .startswith (step_id ):
127+ source = source [step_id_len :]
128+ step ["scatter" ] = source
111129 if "description" in step :
112130 step ["doc" ] = step .pop ("description" )
113131 new_steps [step_id .lstrip ('#' )] = step
0 commit comments