@@ -152,7 +152,7 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
152
152
153
153
154
154
def single_job_executor (t , job_order_object , ** kwargs ):
155
- # type: (Process, Dict[str, Any], **Any) -> Union[str,Dict[str,str]]
155
+ # type: (Process, Dict[unicode, Any], **Any) -> Union[str,Dict[str,str]]
156
156
final_output = []
157
157
final_status = []
158
158
@@ -238,7 +238,7 @@ def __call__(self, parser, namespace, values, option_string=None):
238
238
239
239
240
240
def generate_parser (toolparser , tool , namemap ):
241
- # type: (argparse.ArgumentParser, Process,Dict[str,str ]) -> argparse.ArgumentParser
241
+ # type: (argparse.ArgumentParser, Process, Dict[unicode, unicode ]) -> argparse.ArgumentParser
242
242
toolparser .add_argument ("job_order" , nargs = "?" , help = "Job input json file" )
243
243
namemap ["job_order" ] = "job_order"
244
244
@@ -298,8 +298,9 @@ def generate_parser(toolparser, tool, namemap):
298
298
else :
299
299
typekw = {}
300
300
301
- toolparser .add_argument (flag + name , required = required ,
302
- help = ahelp , action = action , default = default , ** typekw )
301
+ toolparser .add_argument ( # type: ignore
302
+ args = flag + name , required = required , help = ahelp , action = action ,
303
+ default = default , ** typekw )
303
304
304
305
return toolparser
305
306
@@ -313,9 +314,9 @@ def load_job_order(args, t, stdin, print_input_deps=False, relative_deps=False,
313
314
loader = Loader ({})
314
315
else :
315
316
jobloaderctx = {
316
- "path" : {"@type" : "@id" },
317
- "format" : {"@type" : "@id" },
318
- "id" : "@id" }
317
+ u "path" : {u "@type" : u "@id" },
318
+ u "format" : {u "@type" : u "@id" },
319
+ u "id" : u "@id" }
319
320
jobloaderctx .update (t .metadata .get ("$namespaces" , {}))
320
321
loader = Loader (jobloaderctx )
321
322
@@ -339,7 +340,7 @@ def load_job_order(args, t, stdin, print_input_deps=False, relative_deps=False,
339
340
toolparser = None
340
341
else :
341
342
input_basedir = args .basedir if args .basedir else os .getcwd ()
342
- namemap = {} # type: Dict[str,str ]
343
+ namemap = {} # type: Dict[unicode, unicode ]
343
344
toolparser = generate_parser (argparse .ArgumentParser (prog = args .workflow ), t , namemap )
344
345
if toolparser :
345
346
if args .tool_help :
@@ -419,7 +420,7 @@ def makeRelative(u):
419
420
420
421
stdout .write (json .dumps (deps , indent = 4 ))
421
422
422
- def flatten_deps (d , files ):
423
+ def flatten_deps (d , files ): # type: (Any, Set[unicode]) -> None
423
424
if isinstance (d , list ):
424
425
for s in d :
425
426
flatten_deps (s , files )
@@ -428,41 +429,44 @@ def flatten_deps(d, files):
428
429
if "secondaryFiles" in d :
429
430
flatten_deps (d ["secondaryFiles" ], files )
430
431
431
- def find_run (d , runs ):
432
+ def find_run (d , runs ): # type: (Any, Set[unicode]) -> None
432
433
if isinstance (d , list ):
433
434
for s in d :
434
435
find_run (s , runs )
435
436
elif isinstance (d , dict ):
436
- if "run" in d and isinstance (d ["run" ], basestring ):
437
+ if "run" in d and isinstance (d ["run" ], ( str , unicode ) ):
437
438
runs .add (d ["run" ])
438
439
for s in d .values ():
439
440
find_run (s , runs )
440
441
441
442
def replace_refs (d , rewrite , stem , newstem ):
443
+ # type: (Any, Dict[unicode, unicode], unicode, unicode) -> None
442
444
if isinstance (d , list ):
443
445
for s ,v in enumerate (d ):
444
- if isinstance (v , basestring ) and v .startswith (stem ):
446
+ if isinstance (v , ( str , unicode ) ) and v .startswith (stem ):
445
447
d [s ] = newstem + v [len (stem ):]
446
448
else :
447
449
replace_refs (v , rewrite , stem , newstem )
448
450
elif isinstance (d , dict ):
449
- if "run" in d and isinstance (d ["run" ], basestring ):
451
+ if "run" in d and isinstance (d ["run" ], ( str , unicode ) ):
450
452
d ["run" ] = rewrite [d ["run" ]]
451
453
for s ,v in d .items ():
452
- if isinstance (v , basestring ) and v .startswith (stem ):
454
+ if isinstance (v , ( str , unicode ) ) and v .startswith (stem ):
453
455
d [s ] = newstem + v [len (stem ):]
454
456
replace_refs (v , rewrite , stem , newstem )
455
457
456
458
def print_pack (document_loader , processobj , uri , metadata ):
459
+ # type: (Loader, Any, unicode, Dict[unicode, unicode]) -> str
457
460
def loadref (b , u ):
461
+ # type: (unicode, unicode) -> Union[Dict, List, unicode]
458
462
return document_loader .resolve_ref (u , base_url = b )[0 ]
459
463
deps = process .scandeps (uri , processobj ,
460
464
set (("run" ,)), set (), loadref )
461
465
462
466
fdeps = set ((uri ,))
463
467
flatten_deps (deps , fdeps )
464
468
465
- runs = set ()
469
+ runs = set () # type: Set[unicode]
466
470
for f in fdeps :
467
471
find_run (document_loader .idx [f ], runs )
468
472
@@ -476,9 +480,10 @@ def loadref(b, u):
476
480
for r in runs :
477
481
rewrite [r ] = "#" + shortname (r )
478
482
479
- packed = {"$graph" : [], "cwlVersion" : metadata ["cwlVersion" ]}
483
+ packed = {"$graph" : [], "cwlVersion" : metadata ["cwlVersion" ]
484
+ } # type: Dict[unicode, Any]
480
485
for r ,v in rewrite .items ():
481
- dc = copy .deepcopy (document_loader .idx [r ])
486
+ dc = cast ( Dict [ unicode , Any ], copy .deepcopy (document_loader .idx [r ]) )
482
487
dc ["id" ] = v
483
488
dc ["name" ] = v
484
489
replace_refs (dc , rewrite , r + "/" if "#" in r else r + "#" , v + "/" )
@@ -508,7 +513,7 @@ def main(argsl=None,
508
513
stderr = sys .stderr ,
509
514
versionfunc = versionstring ,
510
515
job_order_object = None ):
511
- # type: (List[str], argparse.namespace , Callable[..., Union[str, Dict[str, str]]], Callable[..., Process], Callable[[Dict[str, int]], Dict[str, int]], IO[Any], IO[Any], IO[Any], Callable[[], unicode], Union[int, Tuple[Dict[str, Any], str]]) -> int
516
+ # type: (List[str], argparse.Namespace , Callable[..., Union[str, Dict[str, str]]], Callable[..., Process], Callable[[Dict[str, int]], Dict[str, int]], IO[Any], IO[Any], IO[Any], Callable[[], unicode], Union[int, Tuple[Dict[str, Any], str]]) -> int
512
517
513
518
_logger .removeHandler (defaultStreamHandler )
514
519
stderr_handler = logging .StreamHandler (stderr )
@@ -611,14 +616,15 @@ def main(argsl=None,
611
616
612
617
if args .tmp_outdir_prefix != 'tmp' :
613
618
# Use user defined temp directory (if it exists)
614
- args .tmp_outdir_prefix = os .path .abspath (args .tmp_outdir_prefix )
619
+ setattr (args , 'tmp_outdir_prefix' ,
620
+ os .path .abspath (args .tmp_outdir_prefix ))
615
621
if not os .path .exists (args .tmp_outdir_prefix ):
616
622
_logger .error ("Intermediate output directory prefix doesn't exist." )
617
623
return 1
618
624
619
625
if args .tmpdir_prefix != 'tmp' :
620
626
# Use user defined prefix (if the folder exists)
621
- args . tmpdir_prefix = os .path .abspath (args .tmpdir_prefix )
627
+ setattr ( args , ' tmpdir_prefix' , os .path .abspath (args .tmpdir_prefix ) )
622
628
if not os .path .exists (args .tmpdir_prefix ):
623
629
_logger .error ("Temporary directory prefix doesn't exist." )
624
630
return 1
@@ -633,12 +639,13 @@ def main(argsl=None,
633
639
return job_order_object
634
640
635
641
if args .cachedir :
636
- args . cachedir = os .path .abspath (args .cachedir )
637
- args . move_outputs = False
642
+ setattr ( args , ' cachedir' , os .path .abspath (args .cachedir ) )
643
+ setattr ( args , ' move_outputs' , False )
638
644
639
645
try :
640
- args .tmp_outdir_prefix = args .cachedir if args .cachedir else args .tmp_outdir_prefix
641
- args .basedir = job_order_object [1 ]
646
+ setattr (args , 'tmp_outdir_prefix' ,
647
+ args .cachedir if args .cachedir else args .tmp_outdir_prefix )
648
+ setattr (args , 'basedir' , job_order_object [1 ])
642
649
del args .workflow
643
650
del args .job_order
644
651
out = executor (tool , job_order_object [0 ],
0 commit comments