Skip to content
Snippets Groups Projects
Commit 3fbee378 authored by Stefano Alberto Russo's avatar Stefano Alberto Russo
Browse files

Added support for setting container runtimes on a per-task basis in the...

Added support for setting container runtimes on a per-task basis in the computing options. Minor improvements in the UX.
parent 742febba
Branches
Tags
No related merge requests found
...@@ -111,7 +111,7 @@ class InternalStandaloneComputingManager(StandaloneComputingManager): ...@@ -111,7 +111,7 @@ class InternalStandaloneComputingManager(StandaloneComputingManager):
#run_command += ' -v {}/user-{}:/data'.format(settings.LOCAL_USER_DATA_DIR, task.user.id) #run_command += ' -v {}/user-{}:/data'.format(settings.LOCAL_USER_DATA_DIR, task.user.id)
# Host name, image entry command # Host name, image entry command
run_command += ' -h task-{} -d -t {}/{}:{}'.format(task.uuid, task.container.registry, task.container.image_name, task.container.image_tag) run_command += ' -h task-{} -d -t {}/{}:{}'.format(task.short_uuid, task.container.registry, task.container.image_name, task.container.image_tag)
# Debug # Debug
logger.debug('Running new task with command="{}"'.format(run_command)) logger.debug('Running new task with command="{}"'.format(run_command))
...@@ -294,7 +294,7 @@ class SSHStandaloneComputingManager(StandaloneComputingManager, SSHComputingMana ...@@ -294,7 +294,7 @@ class SSHStandaloneComputingManager(StandaloneComputingManager, SSHComputingMana
run_command += '/bin/bash -c \'"rm -rf /tmp/{}_data && mkdir /tmp/{}_data && chmod 700 /tmp/{}_data && '.format(task.uuid, task.uuid, task.uuid) run_command += '/bin/bash -c \'"rm -rf /tmp/{}_data && mkdir /tmp/{}_data && chmod 700 /tmp/{}_data && '.format(task.uuid, task.uuid, task.uuid)
run_command += 'wget {}/api/v1/base/agent/?task_uuid={} -O /tmp/{}_data/agent.py &> /dev/null && export TASK_PORT=\$(python /tmp/{}_data/agent.py 2> /tmp/{}_data/task.log) && '.format(webapp_conn_string, task.uuid, task.uuid, task.uuid, task.uuid) run_command += 'wget {}/api/v1/base/agent/?task_uuid={} -O /tmp/{}_data/agent.py &> /dev/null && export TASK_PORT=\$(python /tmp/{}_data/agent.py 2> /tmp/{}_data/task.log) && '.format(webapp_conn_string, task.uuid, task.uuid, task.uuid, task.uuid)
run_command += '{} docker run -p \$TASK_PORT:{} {} {} '.format(prefix, task.container.interface_port, authstring, binds) run_command += '{} docker run -p \$TASK_PORT:{} {} {} '.format(prefix, task.container.interface_port, authstring, binds)
run_command += '-h task-{} -d -t {}/{}:{}'.format(task.uuid, task.container.registry, task.container.image_name, task.container.image_tag) run_command += '-h task-{} -d -t {}/{}:{}'.format(task.short_uuid, task.container.registry, task.container.image_name, task.container.image_tag)
run_command += '"\'' run_command += '"\''
else: else:
......
...@@ -331,6 +331,10 @@ class Task(models.Model): ...@@ -331,6 +331,10 @@ class Task(models.Model):
def __str__(self): def __str__(self):
return str('Task "{}" of user "{}" running on "{}" in status "{}" created at "{}"'.format(self.name, self.user.email, self.computing, self.status, self.created)) return str('Task "{}" of user "{}" running on "{}" in status "{}" created at "{}"'.format(self.name, self.user.email, self.computing, self.status, self.created))
@property
def short_uuid(self):
return str(self.uuid)[0:8]
@property @property
def color(self): def color(self):
string_int_hash = hash_string_to_int(self.name) string_int_hash = hash_string_to_int(self.name)
...@@ -339,7 +343,7 @@ class Task(models.Model): ...@@ -339,7 +343,7 @@ class Task(models.Model):
@property @property
def sharable_link(self): def sharable_link(self):
return 'https://{}/t/{}'.format(settings.ROSETTA_HOST, str(self.uuid)[0:8]) return 'https://{}/t/{}'.format(settings.ROSETTA_HOST, self.short_uuid)
@property @property
def tcp_tunnel_host(self): def tcp_tunnel_host(self):
......
...@@ -93,8 +93,8 @@ ...@@ -93,8 +93,8 @@
<br/> <br/>
{% endif %} {% endif %}
<div class="image-version-box"> <div class="image-version-box">
<b>Type:</b> {{ computing.type }}<br/> <b>Type:</b> {{ computing.type }} <font style="font-size:0.9em">({{ computing.arch }})</font>
<b>Arch:</b> {{ computing.arch }} <!-- <br/><b>Arch:</b> {{ computing.arch }} -->
<br/> <br/>
<b>Storages:</b> <b>Storages:</b>
{% if not computing.storages.all %} {% if not computing.storages.all %}
......
...@@ -107,9 +107,14 @@ ...@@ -107,9 +107,14 @@
<td>{{ task.name }}</td> <td>{{ task.name }}</td>
</tr> --> </tr> -->
<tr> <!-- <tr>
<td><b>ID</b></td> <td><b>ID</b></td>
<td>{{ task.id }}</td> <td>{{ task.id }}</td>
</tr> -->
<tr>
<td><b>Short ID</b></td>
<td>{{ task.short_uuid }}</td>
</tr> </tr>
<tr> <tr>
...@@ -144,6 +149,13 @@ ...@@ -144,6 +149,13 @@
</tr> </tr>
{% endif %} {% endif %}
{% if task.computing_options %}
<tr>
<td><b>Computing options</b></td>
<td>{{ task.computing_options }}</td>
</tr>
{% endif %}
<!-- <tr><td style="padding-right:0"><b>Direct link</b> <!-- <tr><td style="padding-right:0"><b>Direct link</b>
<td>{% if task.status == "running" %}<a href="{{ task.sharable_link }}">{{ task.sharable_link }}</a>{% else %}N.A. (task not running) {% endif %}</td> --> <td>{% if task.status == "running" %}<a href="{{ task.sharable_link }}">{{ task.sharable_link }}</a>{% else %}N.A. (task not running) {% endif %}</td> -->
......
...@@ -91,7 +91,12 @@ ...@@ -91,7 +91,12 @@
</tr> </tr>
<tr> <tr>
<td valign="top"><b>Task&nbsp;password</b></td> <td valign="top">
{% if request.user.profile.is_power_user %}
<b>Task&nbsp;password</b></td>
{% else %}
<b>Auth&nbsp;token</b></td>
{% endif %}
<td> <td>
<input type="hidden" name="task_auth_token" value="{{data.task_auth_token}}"> <input type="hidden" name="task_auth_token" value="{{data.task_auth_token}}">
...@@ -121,25 +126,20 @@ ...@@ -121,25 +126,20 @@
</select> </select>
</td> </td>
</tr> </tr>
{% else %}
<tr>
<td><b>Access method</b></td><td>
<select name="access_method" >
<option value="auto" selected>Auto</option>
</select>
</td>
</tr>
{% endif %} {% endif %}
{% if data.task_computing.container_runtimes|length > 1 %}
<tr> <tr>
<td><b>Container runtime</b></td><td> <td><b>Container&nbsp;runtime</b></td><td>
<select name="run_using" > <select name="container_runtime" >
<option value="default" selected>Default</option> <option value="" selected>Default</option>
<!-- <option value="docker" selected>default</option> --> {% for container_runtime in data.task_computing.container_runtimes %}
<!-- <option value="singularity">Singularity</option> --> <option value="{{container_runtime}}">{{container_runtime}}</option>
{% endfor %}
</select> </select>
</td> </td>
</tr> </tr>
{% endif %}
{% if data.task_computing.wms == 'slurm' %} {% if data.task_computing.wms == 'slurm' %}
<tr> <tr>
......
...@@ -586,7 +586,7 @@ def new_task(request): ...@@ -586,7 +586,7 @@ def new_task(request):
task.requires_tcp_tunnel = True task.requires_tcp_tunnel = True
# Task access method # Task access method
access_method = request.POST.get('access_method', None) access_method = request.POST.get('access_method', 'auto')
if access_method and access_method != 'auto' and not request.user.profile.is_power_user: if access_method and access_method != 'auto' and not request.user.profile.is_power_user:
raise ErrorMessage('Sorry, only power users can set a task access method other than \'auto\'.') raise ErrorMessage('Sorry, only power users can set a task access method other than \'auto\'.')
if access_method == 'auto': if access_method == 'auto':
...@@ -605,12 +605,21 @@ def new_task(request): ...@@ -605,12 +605,21 @@ def new_task(request):
else: else:
raise ErrorMessage('Unknown access method "{}"'.format(access_method)) raise ErrorMessage('Unknown access method "{}"'.format(access_method))
# Computing options # TODO: This is hardcoded thinking about Slurm and Singularity # Computing options
computing_options = {}
# Container runtime if any set
container_runtime = request.POST.get('container_runtime', None)
if container_runtime:
if not container_runtime in data['task_computing'].container_runtimes:
raise ErrorMessage('Unknown container runtime "{}"'.format(container_runtime))
computing_options['container_runtime'] = container_runtime
# CPUs, memory and partition if set
computing_cpus = request.POST.get('computing_cpus', None) computing_cpus = request.POST.get('computing_cpus', None)
computing_memory = request.POST.get('computing_memory', None) computing_memory = request.POST.get('computing_memory', None)
computing_partition = request.POST.get('computing_partition', None) computing_partition = request.POST.get('computing_partition', None)
computing_options = {}
if computing_cpus: if computing_cpus:
try: try:
int(computing_cpus) int(computing_cpus)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment