Commit a812b1a2 authored by Stefano Alberto Russo's avatar Stefano Alberto Russo
Browse files

Added support for bindings in Singularity sys conf.

parent 192f21f7
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -332,12 +332,17 @@ class SlurmComputingManager(ComputingManager):
            else:
                authstring = ''

            bindings = task.computing.get_conf_param('bindings', from_sys_only=True )
            if not bindings:
                bindings = ''
            else:
                bindings = '-B {}'.format(bindings)

            run_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {}@{} '.format(user_keys.private_key_file, user, host)

            run_command += '\'bash -c "echo \\"#!/bin/bash\nwget {}/api/v1/base/agent/?task_uuid={} -O \$HOME/agent_{}.py &> \$HOME/{}.log && export BASE_PORT=\\\\\\$(python \$HOME/agent_{}.py 2> \$HOME/{}.log) && '.format(webapp_conn_string, task.uuid, task.uuid, task.uuid, task.uuid, task.uuid)
            run_command += 'export SINGULARITY_NOHTTPS=true && export SINGULARITYENV_BASE_PORT=\\\\\\$BASE_PORT && {} '.format(authstring)
            run_command += 'exec nohup singularity run --pid --writable-tmpfs --containall --cleanenv '
            run_command += 'exec nohup singularity run {} --pid --writable-tmpfs --containall --cleanenv '.format(bindings)
            
            # Double to escape for python six for shell (double times three as \\\ escapes a single slash in shell)

+8 −2
Original line number Diff line number Diff line
@@ -152,11 +152,17 @@ class Computing(models.Model):
            self._user_conf_data = None


    def get_conf_param(self, param):
    def get_conf_param(self, param, from_sys_only=False):
        try:
            param_value = self.sys_conf_data[param]
        except (TypeError, KeyError):
            if not from_sys_only:
                try:
                    param_value = self.user_conf_data[param]
                except (TypeError, KeyError):
                    return None
            else:
                return None
        return param_value