Loading docker-compose.yml +7 −3 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ services: - SAFEMODE=False privileged: true volumes: - ./data/shared:/shared - ./data_rosetta/shared:/shared # - ./data/singularity_cache:/rosetta/.singularity/cache # Not working, check permissions... ports: - "8590:8590" Loading @@ -23,7 +23,7 @@ services: - SAFEMODE=False privileged: true volumes: - ./data/shared:/shared - ./data_rosetta/shared:/shared ports: - "8591:8590" - "5901:5900" Loading @@ -33,7 +33,7 @@ services: hostname: dregistry image: "rosetta/dregistry" volumes: - ./data/dregistry:/var/lib/registry - ./data_rosetta/dregistry:/var/lib/registry ports: - "5000:5000" Loading @@ -45,6 +45,10 @@ services: - SAFEMODE=False - DJANGO_LOG_LEVEL=CRITICAL - ROSETTA_LOG_LEVEL=DEBUG #- ROSETTA_WEBAPP_HOST= #- ROSETTA_WEBAPP_PORT=8080 #- LOCAL_DOCKER_REGISTRY_HOST= #- LOCAL_DOCKER_REGISTRY_PORT=5000 ports: - "8080:8080" - "8000:8590" Loading services/webapp/code/rosetta/base_app/api.py +3 −5 Original line number Diff line number Diff line Loading @@ -221,11 +221,9 @@ class agent_api(PublicGETAPI): except (Task.DoesNotExist, ValidationError): return HttpResponse('Unknown task uuid "{}"'.format(task_uuid)) import socket hostname = socket.gethostname() webapp_ip = socket.gethostbyname(hostname) host_conn_string = 'http://{}:8080'.format(webapp_ip) from.utils import get_webapp_conn_string webapp_conn_string = get_webapp_conn_string() action = request.GET.get('action', None) Loading Loading @@ -275,7 +273,7 @@ while True: break logger.info(' - ports: "{},{},{}"'.format(port, port+1, port+2)) response = urlopen("'''+host_conn_string+'''/api/v1/base/agent/?task_uuid={}&action=set_ip_port&ip={}&port={}".format(task_uuid, ip, port)) response = urlopen("'''+webapp_conn_string+'''/api/v1/base/agent/?task_uuid={}&action=set_ip_port&ip={}&port={}".format(task_uuid, ip, port)) response_content = response.read() if response_content != 'OK': logger.error(response_content) Loading services/webapp/code/rosetta/base_app/computing_managers.py +16 −10 Original line number Diff line number Diff line Loading @@ -169,6 +169,11 @@ class RemoteComputingManager(ComputingManager): else: raise NotImplementedError('Remote tasks not requiring keys are not yet supported') # Get webapp conn string from.utils import get_webapp_conn_string webapp_conn_string = get_webapp_conn_string() # 1) Run the container on the host (non blocking) if task.container.type == 'singularity': Loading @@ -182,12 +187,8 @@ class RemoteComputingManager(ComputingManager): else: authstring = '' import socket hostname = socket.gethostname() webapp_ip = socket.gethostbyname(hostname) run_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {}@{} '.format(user_keys.private_key_file, user, host) run_command += '/bin/bash -c \'"wget {}:8080/api/v1/base/agent/?task_uuid={} -O /tmp/agent_{}.py &> /dev/null && export BASE_PORT=\$(python /tmp/agent_{}.py 2> /tmp/{}.log) && '.format(webapp_ip, task.uuid, task.uuid, task.uuid, task.uuid) run_command += '/bin/bash -c \'"wget {}/api/v1/base/agent/?task_uuid={} -O /tmp/agent_{}.py &> /dev/null && export BASE_PORT=\$(python /tmp/agent_{}.py 2> /tmp/{}.log) && '.format(webapp_conn_string, 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 ' Loading Loading @@ -295,6 +296,10 @@ class SlurmComputingManager(ComputingManager): else: raise NotImplementedError('Remote tasks not requiring keys are not yet supported') # Get webapp conn string from.utils import get_webapp_conn_string webapp_conn_string = get_webapp_conn_string() # Get task computing parameters and set sbatch args sbatch_args = '' if task.computing_options: Loading @@ -314,6 +319,7 @@ class SlurmComputingManager(ComputingManager): # Set output and error files sbatch_args += ' --output=\$HOME/{}.log --error=\$HOME/{}.log '.format(task.uuid, task.uuid) # 1) Run the container on the host (non blocking) if task.container.type == 'singularity': Loading @@ -326,13 +332,10 @@ class SlurmComputingManager(ComputingManager): else: authstring = '' import socket hostname = socket.gethostname() webapp_ip = socket.gethostbyname(hostname) run_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {}@{} '.format(user_keys.private_key_file, user, host) run_command += '\'bash -c "echo \\"#!/bin/bash\nwget {}:8080/api/v1/base/agent/?task_uuid={} -O \$HOME/agent_{}.py &> /dev/null && export BASE_PORT=\\\\\\$(python \$HOME/agent_{}.py 2> \$HOME/{}.log) && '.format(webapp_ip, task.uuid, task.uuid, task.uuid, task.uuid) 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 ' Loading @@ -340,7 +343,10 @@ class SlurmComputingManager(ComputingManager): # Set registry if task.container.registry == 'docker_local': registry = 'docker://dregistry:5000/' # Get local Docker registry conn string from.utils import get_local_docker_registry_conn_string local_docker_registry_conn_string = get_local_docker_registry_conn_string() registry = 'docker://{}/'.format(local_docker_registry_conn_string) elif task.container.registry == 'docker_hub': registry = 'docker://' else: Loading services/webapp/code/rosetta/base_app/utils.py +37 −0 Original line number Diff line number Diff line import os import traceback import hashlib import random Loading Loading @@ -425,7 +426,43 @@ class dt_range(object): return self.__next__() #================================ # Others #================================ def debug_param(**kwargs): for item in kwargs: logger.critical('Param "{}": "{}"'.format(item, kwargs[item])) def get_my_ip(): import socket hostname = socket.gethostname() my_ip = socket.gethostbyname(hostname) return my_ip def get_webapp_conn_string(): webapp_host = os.environ.get('ROSETTA_WEBAPP_HOST', get_my_ip()) webapp_port = os.environ.get('ROSETTA_WEBAPP_PORT', '8080') webapp_conn_string = 'http://{}:{}'.format(webapp_host, webapp_port) return webapp_conn_string def get_local_docker_registry_conn_string(): local_docker_registry_host = os.environ.get('LOCAL_DOCKER_REGISTRY_HOST', 'dregistry') local_docker_registry_port = os.environ.get('LOCAL_DOCKER_REGISTRY_PORT', '5000') local_docker_registry_conn_string = '{}:{}'.format(local_docker_registry_host, local_docker_registry_port) return local_docker_registry_conn_string Loading
docker-compose.yml +7 −3 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ services: - SAFEMODE=False privileged: true volumes: - ./data/shared:/shared - ./data_rosetta/shared:/shared # - ./data/singularity_cache:/rosetta/.singularity/cache # Not working, check permissions... ports: - "8590:8590" Loading @@ -23,7 +23,7 @@ services: - SAFEMODE=False privileged: true volumes: - ./data/shared:/shared - ./data_rosetta/shared:/shared ports: - "8591:8590" - "5901:5900" Loading @@ -33,7 +33,7 @@ services: hostname: dregistry image: "rosetta/dregistry" volumes: - ./data/dregistry:/var/lib/registry - ./data_rosetta/dregistry:/var/lib/registry ports: - "5000:5000" Loading @@ -45,6 +45,10 @@ services: - SAFEMODE=False - DJANGO_LOG_LEVEL=CRITICAL - ROSETTA_LOG_LEVEL=DEBUG #- ROSETTA_WEBAPP_HOST= #- ROSETTA_WEBAPP_PORT=8080 #- LOCAL_DOCKER_REGISTRY_HOST= #- LOCAL_DOCKER_REGISTRY_PORT=5000 ports: - "8080:8080" - "8000:8590" Loading
services/webapp/code/rosetta/base_app/api.py +3 −5 Original line number Diff line number Diff line Loading @@ -221,11 +221,9 @@ class agent_api(PublicGETAPI): except (Task.DoesNotExist, ValidationError): return HttpResponse('Unknown task uuid "{}"'.format(task_uuid)) import socket hostname = socket.gethostname() webapp_ip = socket.gethostbyname(hostname) host_conn_string = 'http://{}:8080'.format(webapp_ip) from.utils import get_webapp_conn_string webapp_conn_string = get_webapp_conn_string() action = request.GET.get('action', None) Loading Loading @@ -275,7 +273,7 @@ while True: break logger.info(' - ports: "{},{},{}"'.format(port, port+1, port+2)) response = urlopen("'''+host_conn_string+'''/api/v1/base/agent/?task_uuid={}&action=set_ip_port&ip={}&port={}".format(task_uuid, ip, port)) response = urlopen("'''+webapp_conn_string+'''/api/v1/base/agent/?task_uuid={}&action=set_ip_port&ip={}&port={}".format(task_uuid, ip, port)) response_content = response.read() if response_content != 'OK': logger.error(response_content) Loading
services/webapp/code/rosetta/base_app/computing_managers.py +16 −10 Original line number Diff line number Diff line Loading @@ -169,6 +169,11 @@ class RemoteComputingManager(ComputingManager): else: raise NotImplementedError('Remote tasks not requiring keys are not yet supported') # Get webapp conn string from.utils import get_webapp_conn_string webapp_conn_string = get_webapp_conn_string() # 1) Run the container on the host (non blocking) if task.container.type == 'singularity': Loading @@ -182,12 +187,8 @@ class RemoteComputingManager(ComputingManager): else: authstring = '' import socket hostname = socket.gethostname() webapp_ip = socket.gethostbyname(hostname) run_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {}@{} '.format(user_keys.private_key_file, user, host) run_command += '/bin/bash -c \'"wget {}:8080/api/v1/base/agent/?task_uuid={} -O /tmp/agent_{}.py &> /dev/null && export BASE_PORT=\$(python /tmp/agent_{}.py 2> /tmp/{}.log) && '.format(webapp_ip, task.uuid, task.uuid, task.uuid, task.uuid) run_command += '/bin/bash -c \'"wget {}/api/v1/base/agent/?task_uuid={} -O /tmp/agent_{}.py &> /dev/null && export BASE_PORT=\$(python /tmp/agent_{}.py 2> /tmp/{}.log) && '.format(webapp_conn_string, 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 ' Loading Loading @@ -295,6 +296,10 @@ class SlurmComputingManager(ComputingManager): else: raise NotImplementedError('Remote tasks not requiring keys are not yet supported') # Get webapp conn string from.utils import get_webapp_conn_string webapp_conn_string = get_webapp_conn_string() # Get task computing parameters and set sbatch args sbatch_args = '' if task.computing_options: Loading @@ -314,6 +319,7 @@ class SlurmComputingManager(ComputingManager): # Set output and error files sbatch_args += ' --output=\$HOME/{}.log --error=\$HOME/{}.log '.format(task.uuid, task.uuid) # 1) Run the container on the host (non blocking) if task.container.type == 'singularity': Loading @@ -326,13 +332,10 @@ class SlurmComputingManager(ComputingManager): else: authstring = '' import socket hostname = socket.gethostname() webapp_ip = socket.gethostbyname(hostname) run_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {}@{} '.format(user_keys.private_key_file, user, host) run_command += '\'bash -c "echo \\"#!/bin/bash\nwget {}:8080/api/v1/base/agent/?task_uuid={} -O \$HOME/agent_{}.py &> /dev/null && export BASE_PORT=\\\\\\$(python \$HOME/agent_{}.py 2> \$HOME/{}.log) && '.format(webapp_ip, task.uuid, task.uuid, task.uuid, task.uuid) 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 ' Loading @@ -340,7 +343,10 @@ class SlurmComputingManager(ComputingManager): # Set registry if task.container.registry == 'docker_local': registry = 'docker://dregistry:5000/' # Get local Docker registry conn string from.utils import get_local_docker_registry_conn_string local_docker_registry_conn_string = get_local_docker_registry_conn_string() registry = 'docker://{}/'.format(local_docker_registry_conn_string) elif task.container.registry == 'docker_hub': registry = 'docker://' else: Loading
services/webapp/code/rosetta/base_app/utils.py +37 −0 Original line number Diff line number Diff line import os import traceback import hashlib import random Loading Loading @@ -425,7 +426,43 @@ class dt_range(object): return self.__next__() #================================ # Others #================================ def debug_param(**kwargs): for item in kwargs: logger.critical('Param "{}": "{}"'.format(item, kwargs[item])) def get_my_ip(): import socket hostname = socket.gethostname() my_ip = socket.gethostbyname(hostname) return my_ip def get_webapp_conn_string(): webapp_host = os.environ.get('ROSETTA_WEBAPP_HOST', get_my_ip()) webapp_port = os.environ.get('ROSETTA_WEBAPP_PORT', '8080') webapp_conn_string = 'http://{}:{}'.format(webapp_host, webapp_port) return webapp_conn_string def get_local_docker_registry_conn_string(): local_docker_registry_host = os.environ.get('LOCAL_DOCKER_REGISTRY_HOST', 'dregistry') local_docker_registry_port = os.environ.get('LOCAL_DOCKER_REGISTRY_PORT', '5000') local_docker_registry_conn_string = '{}:{}'.format(local_docker_registry_host, local_docker_registry_port) return local_docker_registry_conn_string