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

Added support for creating slurm launch scripts.

parent 82cb7119
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -228,8 +228,6 @@ def start_task(task):
 
        if task.container.type == 'singularity':

            

            # Set pass if any
            if task.auth_pass:
                authstring = ' export SINGULARITYENV_AUTH_PASS={} && '.format(task.auth_pass)
@@ -238,13 +236,19 @@ def start_task(task):

            import socket
            hostname = socket.gethostname()
            my_ip = socket.gethostbyname(hostname)
            webapp_ip = socket.gethostbyname(hostname)

            run_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {} '.format(user_keys.private_key_file, host)
            run_command+= '"echo \"wget {}:8080/api/v1/base/agent/?task_uuid={} -O /tmp/agent_{}.py && TASK_PORT=$(python /tmp/agent_{}.py) && '.format(my_ip, task.uuid, task.uuid, task.uuid)
            run_command += 'export SINGULARITY_NOHTTPS=true && export SINGULARITYENV_TASK_PORT=$TASK_PORT && {} '.format(authstring)

            run_command += '"echo \\"wget {}:8080/api/v1/base/agent/?task_uuid={} -O /tmp/agent_{}.py &> /dev/null && export TASK_PORT=\\\\\\$(python /tmp/agent_{}.py 2> /tmp/{}.log) && '.format(webapp_ip, task.uuid, task.uuid, task.uuid, task.uuid)
            run_command += 'export SINGULARITY_NOHTTPS=true && export SINGULARITYENV_TASK_PORT=\\\\\\$TASK_PORT && {} '.format(authstring)
            run_command += 'exec nohup singularity run --pid --writable-tmpfs --containall --cleanenv '

            # ssh -i /rosetta/.ssh/id_rsa -4 -o StrictHostKeyChecking=no slurmclustermaster-main "echo \"wget 172.18.0.5:8080/api/v1/base/agent/?task_uuid=558c65c3-8b72-4d6b-8119-e1dcf6f81177 -O /tmp/agent_558c65c3-8b72-4d6b-8119-e1dcf6f81177.py &> /dev/null
            #  && export TASK_PORT=\\\$(python /tmp/agent_558c65c3-8b72-4d6b-8119-e1dcf6f81177.py 2> /tmp/558c65c3-8b72-4d6b-8119-e1dcf6f81177.log) && export SINGULARITY_NOHTTPS=true && export SINGULARITYENV_TASK_PORT=\\\$TASK_PORT &&  export SINGULARITYENV_AUTH_PASS=testpass 
            #  && exec nohup singularity run --pid --writable-tmpfs --containall --cleanenv docker://dregistry:5000/rosetta/metadesktop &> /tmp/558c65c3-8b72-4d6b-8119-e1dcf6f81177.log\" > /tmp/558c65c3-8b72-4d6b-8119-e1dcf6f81177.sh"

            
            # Set registry
            if task.container.registry == 'docker_local':
                registry = 'docker://dregistry:5000/'
@@ -253,7 +257,7 @@ def start_task(task):
            else:
                raise NotImplementedError('Registry {} not supported'.format(task.container.registry))
    
            run_command+='{}{} &> /tmp/{}.log & echo \$!" > '.format(registry, task.container.image, task.uuid)
            run_command+='{}{} &> /tmp/{}.log\\" > /tmp/{}.sh"'.format(registry, task.container.image, task.uuid, task.uuid)

            
        else:
+1 −1
Original line number Diff line number Diff line
@@ -292,7 +292,7 @@ def tasks(request):
            elif action=='connect':
    
                # Create task tunnel
                if task.computing.type in ['local', 'remote']:
                if task.computing.type in ['local', 'remote', 'slurm']:
    
                    # If there is no tunnel port allocated yet, find one
                    if not task.tunnel_port: