9
9
import re
10
10
import shutil
11
11
import tempfile
12
+ import threading
12
13
from functools import cmp_to_key , partial
13
14
from typing import (Any , Callable , Dict , # pylint: disable=unused-import
14
15
Generator , List , Optional , Set , Text , Type , TYPE_CHECKING ,
49
50
ACCEPTLIST_EN_STRICT_RE = re .compile (r"^[a-zA-Z0-9._+-]+$" )
50
51
ACCEPTLIST_EN_RELAXED_RE = re .compile (r".*" ) # Accept anything
51
52
ACCEPTLIST_RE = ACCEPTLIST_EN_STRICT_RE
52
- DEFAULT_CONTAINER_MSG = \
53
- """ We are on Microsoft Windows and not all components of this CWL description have a
53
+ DEFAULT_CONTAINER_MSG = """
54
+ We are on Microsoft Windows and not all components of this CWL description have a
54
55
container specified. This means that these steps will be executed in the default container,
55
56
which is %s.
56
57
@@ -295,10 +296,10 @@ def job(self,
295
296
separateDirs = False )
296
297
_check_adjust = partial (check_adjust , cachebuilder )
297
298
visit_class ([cachebuilder .files , cachebuilder .bindings ],
298
- ("File" , "Directory" ), _check_adjust )
299
+ ("File" , "Directory" ), _check_adjust )
299
300
300
301
cmdline = flatten (list (map (cachebuilder .generate_arg , cachebuilder .bindings )))
301
- (docker_req , docker_is_req ) = self .get_requirement ("DockerRequirement" )
302
+ (docker_req , _ ) = self .get_requirement ("DockerRequirement" )
302
303
if docker_req and runtimeContext .use_container :
303
304
dockerimg = docker_req .get ("dockerImageId" ) or docker_req .get ("dockerPull" )
304
305
elif runtimeContext .default_container is not None and runtimeContext .use_container :
@@ -311,19 +312,23 @@ def job(self,
311
312
# not really run using docker, just for hashing purposes
312
313
keydict = {u"cmdline" : cmdline }
313
314
314
- if "stdout" in self .tool :
315
- keydict ["stdout" ] = self .tool ["stdout" ]
316
- for location , f in cachebuilder .pathmapper .items ():
317
- if f .type == "File" :
318
- checksum = next ((e ['checksum' ] for e in cachebuilder .files
319
- if 'location' in e and e ['location' ] == location
320
- and 'checksum' in e
321
- and e ['checksum' ] != 'sha1$hash' ), None )
322
- st = os .stat (f .resolved )
315
+ for shortcut in ["stdout" , "stderr" ]: # later, add "stdin"
316
+ if shortcut in self .tool :
317
+ keydict [shortcut ] = self .tool [shortcut ]
318
+
319
+ for location , fobj in cachebuilder .pathmapper .items ():
320
+ if fobj .type == "File" :
321
+ checksum = next (
322
+ (e ['checksum' ] for e in cachebuilder .files
323
+ if 'location' in e and e ['location' ] == location
324
+ and 'checksum' in e
325
+ and e ['checksum' ] != 'sha1$hash' ), None )
326
+ fobj_stat = os .stat (fobj .resolved )
323
327
if checksum :
324
- keydict [f .resolved ] = [st .st_size , checksum ]
328
+ keydict [fobj .resolved ] = [fobj_stat .st_size , checksum ]
325
329
else :
326
- keydict [f .resolved ] = [st .st_size , int (st .st_mtime * 1000 )]
330
+ keydict [fobj .resolved ] = [fobj_stat .st_size ,
331
+ int (fobj_stat .st_mtime * 1000 )]
327
332
328
333
interesting = {"DockerRequirement" ,
329
334
"EnvVarRequirement" ,
@@ -342,7 +347,8 @@ def job(self,
342
347
keydictstr , cachekey )
343
348
344
349
jobcache = os .path .join (runtimeContext .cachedir , cachekey )
345
- jobcachepending = jobcache + ".pending"
350
+ jobcachepending = "{}.{}.pending" .format (
351
+ jobcache , threading .current_thread ().ident )
346
352
347
353
if os .path .isdir (jobcache ) and not os .path .isfile (jobcachepending ):
348
354
if docker_req and runtimeContext .use_container :
0 commit comments