From cff3650f7f788ca6d148fe9a726af808355cc7de Mon Sep 17 00:00:00 2001 From: Stefano Alberto Russo <stefano.russo@gmail.com> Date: Wed, 29 Apr 2020 23:54:33 +0200 Subject: [PATCH] Added support for creating slurm launch scripts. --- services/webapp/code/rosetta/base_app/tasks.py | 18 +++++++++++------- services/webapp/code/rosetta/base_app/views.py | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/services/webapp/code/rosetta/base_app/tasks.py b/services/webapp/code/rosetta/base_app/tasks.py index 8cb820a..39f66fa 100644 --- a/services/webapp/code/rosetta/base_app/tasks.py +++ b/services/webapp/code/rosetta/base_app/tasks.py @@ -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,12 +236,18 @@ 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 = '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 &> /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': @@ -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: diff --git a/services/webapp/code/rosetta/base_app/views.py b/services/webapp/code/rosetta/base_app/views.py index 043ad2a..2782259 100644 --- a/services/webapp/code/rosetta/base_app/views.py +++ b/services/webapp/code/rosetta/base_app/views.py @@ -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: -- GitLab