35
35
ACCEPTLIST_EN_RELAXED_RE = re .compile (r".*" ) # Accept anything
36
36
ACCEPTLIST_RE = ACCEPTLIST_EN_STRICT_RE
37
37
DEFAULT_CONTAINER_MSG = """We are on Microsoft Windows and not all components of this CWL description have a
38
- container specified. This means that these steps will be executed in the default container,
38
+ container specified. This means that these steps will be executed in the default container,
39
39
which is %s.
40
40
41
41
Note, this could affect portability if this CWL description relies on non-POSIX features
@@ -116,17 +116,26 @@ def revmap_file(builder, outdir, f):
116
116
if not split .scheme :
117
117
outdir = file_uri (str (outdir ))
118
118
119
+ # builder.outdir is the inner (container/compute node) output directory
120
+ # outdir is the outer (host/storage system) output directory
121
+
119
122
if "location" in f :
120
123
if f ["location" ].startswith ("file://" ):
121
124
path = convert_pathsep_to_unix (uri_file_path (f ["location" ]))
122
125
revmap_f = builder .pathmapper .reversemap (path )
126
+
123
127
if revmap_f and not builder .pathmapper .mapper (revmap_f [0 ]).type .startswith ("Writable" ):
124
128
f ["basename" ] = os .path .basename (path )
125
- f ["location" ] = revmap_f [0 ]
129
+ f ["location" ] = revmap_f [1 ]
126
130
elif path == builder .outdir :
127
131
f ["location" ] = outdir
128
132
elif path .startswith (builder .outdir ):
129
133
f ["location" ] = builder .fs_access .join (outdir , path [len (builder .outdir ) + 1 :])
134
+ elif f ["location" ].startswith (outdir ):
135
+ revmap_f = builder .pathmapper .reversemap (builder .fs_access .join (builder .outdir , f ["location" ][len (outdir ) + 1 :]))
136
+ if revmap_f and not builder .pathmapper .mapper (revmap_f [0 ]).type .startswith ("Writable" ):
137
+ f ["basename" ] = os .path .basename (path )
138
+ f ["location" ] = revmap_f [1 ]
130
139
return f
131
140
132
141
if "path" in f :
@@ -350,6 +359,7 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
350
359
if "stagedir" in make_path_mapper_kwargs :
351
360
make_path_mapper_kwargs = make_path_mapper_kwargs .copy ()
352
361
del make_path_mapper_kwargs ["stagedir" ]
362
+
353
363
builder .pathmapper = self .makePathMapper (reffiles , builder .stagedir , ** make_path_mapper_kwargs )
354
364
builder .requirements = j .requirements
355
365
@@ -566,7 +576,10 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr
566
576
elif gb .startswith ("/" ):
567
577
raise WorkflowException ("glob patterns must not start with '/'" )
568
578
try :
579
+ prefix = fs_access .glob (outdir )
569
580
r .extend ([{"location" : g ,
581
+ "path" : fs_access .join (builder .outdir , g [len (prefix [0 ])+ 1 :]),
582
+ "basename" : os .path .basename (g ),
570
583
"class" : "File" if fs_access .isfile (g ) else "Directory" }
571
584
for g in fs_access .glob (fs_access .join (outdir , gb ))])
572
585
except (OSError , IOError ) as e :
@@ -576,12 +589,14 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr
576
589
raise
577
590
578
591
for files in r :
592
+ rfile = files .copy ()
593
+ revmap (rfile )
579
594
if files ["class" ] == "Directory" :
580
595
ll = builder .loadListing or (binding and binding .get ("loadListing" ))
581
596
if ll and ll != "no_listing" :
582
597
get_listing (fs_access , files , (ll == "deep_listing" ))
583
598
else :
584
- with fs_access .open (files ["location" ], "rb" ) as f :
599
+ with fs_access .open (rfile ["location" ], "rb" ) as f :
585
600
contents = b""
586
601
if binding .get ("loadContents" ) or compute_checksum :
587
602
contents = f .read (CONTENT_LIMIT )
@@ -625,28 +640,29 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr
625
640
else :
626
641
r = r [0 ]
627
642
628
- # Ensure files point to local references outside of the run environment
629
- adjustFileObjs (r , cast ( # known bug in mypy
630
- # https://github.com/python/mypy/issues/797
631
- Callable [[Any ], Any ], revmap ))
632
-
633
643
if "secondaryFiles" in schema :
634
644
with SourceLine (schema , "secondaryFiles" , WorkflowException ):
635
645
for primary in aslist (r ):
636
646
if isinstance (primary , dict ):
637
- primary [ "secondaryFiles" ] = []
647
+ primary . setdefault ( "secondaryFiles" , [])
638
648
for sf in aslist (schema ["secondaryFiles" ]):
639
649
if isinstance (sf , dict ) or "$(" in sf or "${" in sf :
640
650
sfpath = builder .do_eval (sf , context = primary )
641
651
if isinstance (sfpath , string_types ):
642
- sfpath = revmap ({ "location " : sfpath , "class" : "File" })
652
+ sfpath = { "path " : primary [ "path" ][ 0 : primary [ "path" ]. rindex ( "/" ) + 1 ] + sfpath , "class" : "File" }
643
653
else :
644
- sfpath = {"location" : substitute (primary ["location" ], sf ), "class" : "File" }
645
-
654
+ sfpath = {"path" : substitute (primary ["path" ], sf ), "class" : "File" }
646
655
for sfitem in aslist (sfpath ):
656
+ if "path" in sfitem and "location" not in sfitem :
657
+ revmap (sfitem )
647
658
if fs_access .exists (sfitem ["location" ]):
648
659
primary ["secondaryFiles" ].append (sfitem )
649
660
661
+ # Ensure files point to local references outside of the run environment
662
+ adjustFileObjs (r , cast ( # known bug in mypy
663
+ # https://github.com/python/mypy/issues/797
664
+ Callable [[Any ], Any ], revmap ))
665
+
650
666
if not r and optional :
651
667
r = None
652
668
0 commit comments