Adapt changes to command/ argument creation in docker sandbox also for singularity.
@@ -162,18 +162,21 @@ class SingularitySandbox(Sandbox):
cdir = cdir.replace("${PY}", dst(python_dir)).replace("${BIN}", dst(bin_dir))
mount(hdir, cdir)
+ # extend by arguments needed for both env loading and executing the job
+ args.extend(self.common_args())
+ args = " ".join(args)
+
+ # build commands to set up environment
+ setup_cmds = "; ".join(self._build_setup_cmds(env))
+
# handle scheduling within the container
ls_flag = "--local-scheduler"
if self.force_local_scheduler() and ls_flag not in proxy_cmd:
proxy_cmd.append(ls_flag)
-
- # build commands to set up environment
- pre_cmds = self.pre_cmds(env)
- pre_cmds.extend(self.task.sandbox_setup_cmds)
+ proxy_cmd = " ".join(proxy_cmd)
# build the final command
- cmd = "singularity exec -e {args} {image} bash -l -c '{pre_cmd}; {proxy_cmd}'".format(
- args=" ".join(args), image=self.image, pre_cmd="; ".join(pre_cmds),
- proxy_cmd=" ".join(proxy_cmd))
+ cmd = "singularity exec -e {args} {image} bash -l -c '{setup_cmds}; {proxy_cmd}'".format(
+ args=args, image=self.image, setup_cmds=setup_cmds, proxy_cmd=proxy_cmd)
return cmd
