@@ -119,38 +119,35 @@ def revmap_file(builder, outdir, f):
119
119
# builder.outdir is the inner (container/compute node) output directory
120
120
# outdir is the outer (host/storage system) output directory
121
121
122
- if "location" in f :
122
+ if "location" in f and "path" not in f :
123
123
if f ["location" ].startswith ("file://" ):
124
- path = convert_pathsep_to_unix (uri_file_path (f ["location" ]))
125
- revmap_f = builder .pathmapper .reversemap (path )
126
-
127
- if revmap_f and not builder .pathmapper .mapper (revmap_f [0 ]).type .startswith ("Writable" ):
128
- f ["basename" ] = os .path .basename (path )
129
- f ["location" ] = revmap_f [1 ]
130
- elif path == builder .outdir :
131
- f ["location" ] = outdir
132
- elif path .startswith (builder .outdir ):
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 ]
139
- return f
124
+ f ["path" ] = convert_pathsep_to_unix (uri_file_path (f ["location" ]))
125
+ else :
126
+ return f
140
127
141
128
if "path" in f :
142
129
path = f ["path" ]
130
+ uripath = file_uri (path )
143
131
del f ["path" ]
132
+
133
+ if "basename" not in f :
134
+ f ["basename" ] = os .path .basename (path )
135
+
144
136
revmap_f = builder .pathmapper .reversemap (path )
145
- if revmap_f :
137
+
138
+ if revmap_f and not builder .pathmapper .mapper (revmap_f [0 ]).type .startswith ("Writable" ):
146
139
f ["location" ] = revmap_f [1 ]
147
- return f
148
- elif path .startswith (builder .outdir ):
140
+ elif uripath == outdir or uripath .startswith (outdir + os .sep ):
141
+ f ["location" ] = file_uri (path )
142
+ elif path == builder .outdir or path .startswith (builder .outdir + os .sep ):
149
143
f ["location" ] = builder .fs_access .join (outdir , path [len (builder .outdir ) + 1 :])
150
- return f
144
+ elif not os .path .isabs (path ):
145
+ f ["location" ] = builder .fs_access .join (outdir , path )
151
146
else :
152
147
raise WorkflowException (u"Output file path %s must be within designated output directory (%s) or an input "
153
148
u"file pass through." % (path , builder .outdir ))
149
+ return f
150
+
154
151
155
152
raise WorkflowException (u"Output File object is missing both `location` and `path` fields: %s" % f )
156
153
0 commit comments