@@ -234,9 +234,9 @@ def make_job_runner(self,
234
234
): # type: (...) -> Type[JobBase]
235
235
dockerReq , _ = self .get_requirement ("DockerRequirement" )
236
236
if not dockerReq and runtimeContext .use_container :
237
- if runtimeContext .find_default_container :
237
+ if runtimeContext .find_default_container is not None :
238
238
default_container = runtimeContext .find_default_container (self )
239
- if default_container :
239
+ if default_container is not None :
240
240
self .requirements .insert (0 , {
241
241
"class" : "DockerRequirement" ,
242
242
"dockerPull" : default_container
@@ -248,7 +248,7 @@ def make_job_runner(self,
248
248
DEFAULT_CONTAINER_MSG , windows_default_container_id ,
249
249
windows_default_container_id )
250
250
251
- if dockerReq and runtimeContext .use_container :
251
+ if dockerReq is not None and runtimeContext .use_container :
252
252
if runtimeContext .singularity :
253
253
return SingularityCommandLineJob
254
254
return DockerCommandLineJob
@@ -285,7 +285,7 @@ def job(self,
285
285
if self .metadata ["cwlVersion" ] == "v1.0" :
286
286
require_prefix = "http://commonwl.org/cwltool#"
287
287
288
- workReuse = self .get_requirement (require_prefix + "WorkReuse" )[ 0 ]
288
+ workReuse , _ = self .get_requirement (require_prefix + "WorkReuse" )
289
289
enableReuse = workReuse .get ("enableReuse" , True ) if workReuse else True
290
290
291
291
jobname = uniquename (runtimeContext .name or shortname (self .tool .get ("id" , "job" )))
@@ -304,15 +304,15 @@ def job(self,
304
304
("File" , "Directory" ), _check_adjust )
305
305
306
306
cmdline = flatten (list (map (cachebuilder .generate_arg , cachebuilder .bindings )))
307
- ( docker_req , _ ) = self .get_requirement ("DockerRequirement" )
308
- if docker_req and runtimeContext .use_container :
307
+ docker_req , _ = self .get_requirement ("DockerRequirement" )
308
+ if docker_req is not None and runtimeContext .use_container :
309
309
dockerimg = docker_req .get ("dockerImageId" ) or docker_req .get ("dockerPull" )
310
310
elif runtimeContext .default_container is not None and runtimeContext .use_container :
311
311
dockerimg = runtimeContext .default_container
312
312
else :
313
313
dockerimg = None
314
314
315
- if dockerimg :
315
+ if dockerimg is not None :
316
316
cmdline = ["docker" , "run" , dockerimg ] + cmdline
317
317
# not really run using docker, just for hashing purposes
318
318
keydict = {u"cmdline" : cmdline }
@@ -329,7 +329,7 @@ def job(self,
329
329
and 'checksum' in e
330
330
and e ['checksum' ] != 'sha1$hash' ), None )
331
331
fobj_stat = os .stat (fobj .resolved )
332
- if checksum :
332
+ if checksum is not None :
333
333
keydict [fobj .resolved ] = [fobj_stat .st_size , checksum ]
334
334
else :
335
335
keydict [fobj .resolved ] = [fobj_stat .st_size ,
@@ -413,8 +413,8 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
413
413
414
414
visit_class ([builder .files , builder .bindings ], ("File" , "Directory" ), _check_adjust )
415
415
416
- initialWorkdir = self .get_requirement ("InitialWorkDirRequirement" )[ 0 ]
417
- if initialWorkdir :
416
+ initialWorkdir , _ = self .get_requirement ("InitialWorkDirRequirement" )
417
+ if initialWorkdir is not None :
418
418
ls = [] # type: List[Dict[Text, Any]]
419
419
if isinstance (initialWorkdir ["listing" ], string_types ):
420
420
ls = builder .do_eval (initialWorkdir ["listing" ])
@@ -482,8 +482,8 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
482
482
if debug :
483
483
_logger .debug (u"[job %s] command line bindings is %s" , j .name ,
484
484
json_dumps (builder .bindings , indent = 4 ))
485
- dockerReq = self .get_requirement ("DockerRequirement" )[ 0 ]
486
- if dockerReq and runtimeContext .use_container :
485
+ dockerReq , _ = self .get_requirement ("DockerRequirement" )
486
+ if dockerReq is not None and runtimeContext .use_container :
487
487
out_prefix = getdefault (runtimeContext .tmp_outdir_prefix , 'tmp' )
488
488
j .outdir = runtimeContext .outdir or \
489
489
tempfile .mkdtemp (prefix = out_prefix ) # type: ignore
@@ -496,16 +496,16 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
496
496
j .tmpdir = builder .tmpdir
497
497
j .stagedir = builder .stagedir
498
498
499
- inplaceUpdateReq = self .get_requirement ("http://commonwl.org/cwltool#InplaceUpdateRequirement" )[ 0 ]
499
+ inplaceUpdateReq , _ = self .get_requirement ("http://commonwl.org/cwltool#InplaceUpdateRequirement" )
500
500
501
- if inplaceUpdateReq :
501
+ if inplaceUpdateReq is not None :
502
502
j .inplace_update = inplaceUpdateReq ["inplaceUpdate" ]
503
503
normalizeFilesDirs (j .generatefiles )
504
504
505
505
readers = {} # type: Dict[Text, Any]
506
506
muts = set () # type: Set[Text]
507
507
508
- if builder .mutation_manager :
508
+ if builder .mutation_manager is not None :
509
509
def register_mut (f ):
510
510
muts .add (f ["location" ])
511
511
builder .mutation_manager .register_mutation (j .name , f )
@@ -529,30 +529,30 @@ def register_reader(f):
529
529
adjustDirObjs (builder .files , register_reader )
530
530
adjustDirObjs (builder .bindings , register_reader )
531
531
532
- timelimit = self .get_requirement (require_prefix + "TimeLimit" )[ 0 ]
533
- if timelimit :
532
+ timelimit , _ = self .get_requirement (require_prefix + "TimeLimit" )
533
+ if timelimit is not None :
534
534
with SourceLine (timelimit , "timelimit" , validate .ValidationException , debug ):
535
535
j .timelimit = builder .do_eval (timelimit ["timelimit" ])
536
536
if not isinstance (j .timelimit , int ) or j .timelimit < 0 :
537
537
raise Exception ("timelimit must be an integer >= 0, got: %s" % j .timelimit )
538
538
539
539
if self .metadata ["cwlVersion" ] == "v1.0" :
540
540
j .networkaccess = True
541
- networkaccess = self .get_requirement (require_prefix + "NetworkAccess" )[ 0 ]
542
- if networkaccess :
541
+ networkaccess , _ = self .get_requirement (require_prefix + "NetworkAccess" )
542
+ if networkaccess is not None :
543
543
with SourceLine (networkaccess , "networkAccess" , validate .ValidationException , debug ):
544
544
j .networkaccess = builder .do_eval (networkaccess ["networkAccess" ])
545
545
if not isinstance (j .networkaccess , bool ):
546
546
raise Exception ("networkAccess must be a boolean, got: %s" % j .networkaccess )
547
547
548
548
j .environment = {}
549
- evr = self .get_requirement ("EnvVarRequirement" )[ 0 ]
550
- if evr :
549
+ evr , _ = self .get_requirement ("EnvVarRequirement" )
550
+ if evr is not None :
551
551
for t in evr ["envDef" ]:
552
552
j .environment [t ["envName" ]] = builder .do_eval (t ["envValue" ])
553
553
554
- shellcmd = self .get_requirement ("ShellCommandRequirement" )[ 0 ]
555
- if shellcmd :
554
+ shellcmd , _ = self .get_requirement ("ShellCommandRequirement" )
555
+ if shellcmd is not None :
556
556
cmd = [] # type: List[Text]
557
557
for b in builder .bindings :
558
558
arg = builder .generate_arg (b )
0 commit comments