@@ -244,6 +244,26 @@ def main() -> int:
244244 print (f"ERROR: SIF fetch failed: { e } " , file = sys .stderr )
245245 return 2
246246
247+ # ── Download S3 inputs to work_dir ───────────────────────
248+ local_inputs = {}
249+ for key , val in inputs .items ():
250+ if isinstance (val , str ) and val .startswith ("s3://" ):
251+ local_file = work_dir / Path (val ).name
252+ print (f"[generic_sif_runner] downloading input { key } : { val } → { local_file } " )
253+ try :
254+ import boto3
255+ from urllib .parse import urlparse
256+ u = urlparse (val )
257+ boto3 .client ("s3" ).download_file (u .netloc , u .path .lstrip ("/" ), str (local_file ))
258+ local_inputs [key ] = str (local_file )
259+ print (f"[generic_sif_runner] downloaded: { local_file } " )
260+ except Exception as e :
261+ print (f"[generic_sif_runner] S3 download failed for { val } : { e } " )
262+ local_inputs [key ] = val
263+ else :
264+ local_inputs [key ] = val
265+ inputs = local_inputs
266+
247267 # ── Resolve command template ──────────────────────────────
248268 try :
249269 resolved_cmd = _resolve_command (cmd_template , inputs , str (work_dir ), resources )
@@ -270,6 +290,7 @@ def main() -> int:
270290 # No Docker-in-Docker needed - just exec the command directly
271291 print (f"[generic_sif_runner] running directly (no singularity): { resolved_cmd } " )
272292 singularity_cmd = resolved_cmd
293+ local_sif = None # No SIF needed for direct exec
273294 else :
274295 singularity_cmd = [
275296 "singularity" , "exec" ,
@@ -280,18 +301,19 @@ def main() -> int:
280301 str (local_sif ),
281302 ] + resolved_cmd
282303
283- # Bind any input file paths that exist on host
284- for v in inputs .values ():
285- if isinstance (v , str ) and Path (v ).exists ():
286- parent = str (Path (v ).parent )
287- singularity_cmd .insert (
288- singularity_cmd .index (str (local_sif )),
289- "--bind"
290- )
291- singularity_cmd .insert (
292- singularity_cmd .index (str (local_sif )),
293- f"{ parent } :{ parent } :ro"
294- )
304+ # Bind any input file paths that exist on host (only for Singularity)
305+ if not use_docker and local_sif :
306+ for v in inputs .values ():
307+ if isinstance (v , str ) and Path (v ).exists ():
308+ parent = str (Path (v ).parent )
309+ singularity_cmd .insert (
310+ singularity_cmd .index (str (local_sif )),
311+ "--bind"
312+ )
313+ singularity_cmd .insert (
314+ singularity_cmd .index (str (local_sif )),
315+ f"{ parent } :{ parent } :ro"
316+ )
295317
296318 print (f"[generic_sif_runner] cmd: { ' ' .join (singularity_cmd )} " )
297319
0 commit comments