@@ -239,9 +239,9 @@ def generate_example_input(
239239
240240
241241def realize_input_schema (
242- input_types : MutableSequence [CWLObjectType ],
242+ input_types : MutableSequence [Union [ str , CWLObjectType ] ],
243243 schema_defs : MutableMapping [str , CWLObjectType ],
244- ) -> MutableSequence [CWLObjectType ]:
244+ ) -> MutableSequence [Union [ str , CWLObjectType ] ]:
245245 """Replace references to named typed with the actual types."""
246246 for index , entry in enumerate (input_types ):
247247 if isinstance (entry , str ):
@@ -251,32 +251,33 @@ def realize_input_schema(
251251 input_type_name = entry
252252 if input_type_name in schema_defs :
253253 entry = input_types [index ] = schema_defs [input_type_name ]
254- if isinstance (entry , Mapping ):
254+ if isinstance (entry , MutableMapping ):
255255 if isinstance (entry ["type" ], str ) and "#" in entry ["type" ]:
256256 _ , input_type_name = entry ["type" ].split ("#" )
257257 if input_type_name in schema_defs :
258- input_types [ index ] ["type" ] = cast (
258+ entry ["type" ] = cast (
259259 CWLOutputAtomType ,
260260 realize_input_schema (
261261 cast (
262- MutableSequence [CWLObjectType ],
262+ MutableSequence [Union [ str , CWLObjectType ] ],
263263 schema_defs [input_type_name ],
264264 ),
265265 schema_defs ,
266266 ),
267267 )
268268 if isinstance (entry ["type" ], MutableSequence ):
269- input_types [ index ] ["type" ] = cast (
269+ entry ["type" ] = cast (
270270 CWLOutputAtomType ,
271271 realize_input_schema (
272- cast (MutableSequence [CWLObjectType ], entry ["type" ]), schema_defs
272+ cast (MutableSequence [Union [str , CWLObjectType ]], entry ["type" ]),
273+ schema_defs ,
273274 ),
274275 )
275276 if isinstance (entry ["type" ], Mapping ):
276- input_types [ index ] ["type" ] = cast (
277+ entry ["type" ] = cast (
277278 CWLOutputAtomType ,
278279 realize_input_schema (
279- [cast (CWLObjectType , input_types [ index ] ["type" ])], schema_defs
280+ [cast (CWLObjectType , entry ["type" ])], schema_defs
280281 ),
281282 )
282283 if entry ["type" ] == "array" :
@@ -285,17 +286,20 @@ def realize_input_schema(
285286 if not isinstance (entry ["items" ], str )
286287 else [entry ["items" ]]
287288 )
288- input_types [ index ] ["items" ] = cast (
289+ entry ["items" ] = cast (
289290 CWLOutputAtomType ,
290291 realize_input_schema (
291- cast (MutableSequence [CWLObjectType ], items ), schema_defs
292+ cast (MutableSequence [Union [str , CWLObjectType ]], items ),
293+ schema_defs ,
292294 ),
293295 )
294296 if entry ["type" ] == "record" :
295- input_types [ index ] ["fields" ] = cast (
297+ entry ["fields" ] = cast (
296298 CWLOutputAtomType ,
297299 realize_input_schema (
298- cast (MutableSequence [CWLObjectType ], entry ["fields" ]),
300+ cast (
301+ MutableSequence [Union [str , CWLObjectType ]], entry ["fields" ]
302+ ),
299303 schema_defs ,
300304 ),
301305 )
@@ -305,8 +309,11 @@ def realize_input_schema(
305309def generate_input_template (tool : Process ) -> CWLObjectType :
306310 """Generate an example input object for the given CWL process."""
307311 template = ruamel .yaml .comments .CommentedMap ()
308- for inp in realize_input_schema (tool .tool ["inputs" ], tool .schemaDefs ):
309- name = shortname (cast (str , inp ["id" ]))
312+ for inp in cast (
313+ List [MutableMapping [str , str ]],
314+ realize_input_schema (tool .tool ["inputs" ], tool .schemaDefs ),
315+ ):
316+ name = shortname (inp ["id" ])
310317 value , comment = generate_example_input (inp ["type" ], inp .get ("default" , None ))
311318 template .insert (0 , name , value , comment )
312319 return template
@@ -454,7 +461,7 @@ def init_job_order(
454461 job_order_object = {}
455462 job_order_object [shortname (inp ["id" ])] = inp ["default" ]
456463
457- if job_order_object is None :
464+ if len ( job_order_object ) == 0 :
458465 if process .tool ["inputs" ]:
459466 if toolparser is not None :
460467 print (f"\n Options for { args .workflow } " )
@@ -697,6 +704,7 @@ def setup_loadingContext(
697704 runtimeContext : RuntimeContext ,
698705 args : argparse .Namespace ,
699706) -> LoadingContext :
707+ """Prepare a LoadingContext from the given arguments."""
700708 if loadingContext is None :
701709 loadingContext = LoadingContext (vars (args ))
702710 loadingContext .singularity = runtimeContext .singularity
@@ -1277,12 +1285,7 @@ def loc_to_path(obj: CWLObjectType) -> None:
12771285 # Unsetting the Generation from final output object
12781286 visit_class (out , ("File" ,), MutationManager ().unset_generation )
12791287
1280- if isinstance (out , str ):
1281- stdout .write (out )
1282- else :
1283- stdout .write (
1284- json_dumps (out , indent = 4 , ensure_ascii = False , default = str )
1285- )
1288+ stdout .write (json_dumps (out , indent = 4 , ensure_ascii = False , default = str ))
12861289 stdout .write ("\n " )
12871290 if hasattr (stdout , "flush" ):
12881291 stdout .flush ()
0 commit comments