From 35a06a98ab0d3fea632ffe34bd9207d71af47f7e Mon Sep 17 00:00:00 2001 From: Stefano Alberto Russo <stefano.russo@gmail.com> Date: Sun, 21 Feb 2021 20:06:04 +0100 Subject: [PATCH] Added support for user data folder with local Docker containers. Cleaned up some conf vars. --- .../code/rosetta/core_app/computing_managers.py | 11 ++++++----- services/webapp/code/rosetta/settings.py | 7 +++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/services/webapp/code/rosetta/core_app/computing_managers.py b/services/webapp/code/rosetta/core_app/computing_managers.py index af46a9c..b3cb204 100644 --- a/services/webapp/code/rosetta/core_app/computing_managers.py +++ b/services/webapp/code/rosetta/core_app/computing_managers.py @@ -1,14 +1,12 @@ from .models import TaskStatuses, KeyPair, Task from .utils import os_shell from .exceptions import ErrorMessage, ConsistencyException +from django.conf import settings # Setup logging import logging logger = logging.getLogger(__name__) -# Conf -TASK_DATA_DIR = "/data" - class ComputingManager(object): @@ -77,6 +75,9 @@ class LocalComputingManager(ComputingManager): def _start_task(self, task): + if task.container.type != 'docker': + raise ErrorMessage('Sorry, only Docker container are supported on this computing resource.') + # Init run command #--cap-add=NET_ADMIN --cap-add=NET_RAW run_command = 'sudo docker run --network=rosetta_default --name rosetta-task-{}'.format( task.id) @@ -84,8 +85,8 @@ class LocalComputingManager(ComputingManager): if task.auth_pass: run_command += ' -eAUTH_PASS={} '.format(task.auth_pass) - # Data volume - run_command += ' -v {}/task-{}:/data'.format(TASK_DATA_DIR, task.id) + # User data volume + run_command += ' -v {}/user-{}:/data'.format(settings.LOCAL_USER_DATA_DIR, task.user.id) # Set registry string if task.container.registry == 'local': diff --git a/services/webapp/code/rosetta/settings.py b/services/webapp/code/rosetta/settings.py index 5d0fe93..39b06b3 100644 --- a/services/webapp/code/rosetta/settings.py +++ b/services/webapp/code/rosetta/settings.py @@ -151,10 +151,6 @@ SWAGGER_SETTINGS = { 'USE_SESSION_AUTH': False } -# Data path for resources etc. -DATA_PATH = '/data/' -TMP_PATH = '/tmp/' - #=============================== # Email settings @@ -227,6 +223,9 @@ LOGGING = { } +# Local user data dir +LOCAL_USER_DATA_DIR = os.environ.get('LOCAL_USER_DATA_DIR', '/data') + #=============================== # Auth -- GitLab