From 1795fa227d57e3d0ed8f6b3630b4cd5e0f8548e6 Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Fri, 12 Apr 2024 22:06:18 +0000 Subject: [PATCH] fix: create and activate shapeworks conda env on worker --- ansible/playbook.yml | 17 +++++++++++++++++ dev/prod.celery.start.sh | 1 + 2 files changed, 18 insertions(+) diff --git a/ansible/playbook.yml b/ansible/playbook.yml index 23651c09..ccf60b6b 100644 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -56,6 +56,23 @@ cp -nr /opt/shapeworks/lib/* /usr/local/lib/. become: true become_user: root + - name: Create ShapeWorks Conda Env + ansible.builtin.shell: | + apt-get update + apt-get install --no-install-recommends --yes libpq-dev gcc libc6-dev curl libgl1-mesa-glx libxt6 libglib2.0-0 libqt5core5a libxrender1 + curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o /tmp/Miniconda3-latest-Linux-x86_64.sh + bash /tmp/Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda + ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh + conda update -n base -c defaults conda + conda install pip + echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc + conda run /bin/bash -c + cd /opt/shapeworks + source install_shapeworks.sh + conda clean -t -y + conda run -n shapeworks bin/bash -c + become: true + become_user: root # This is required because composed_configurations attempts to create the staticfiles directory in the python installation directory while being imported. # The python installation on the EC2 worker belongs to root, but the Celery worker runs as celery, so it does not have permission to create the directory. # The (dumb) solution is to create the directory with the correct permissions in advance. diff --git a/dev/prod.celery.start.sh b/dev/prod.celery.start.sh index 3fac37f2..61382db7 100644 --- a/dev/prod.celery.start.sh +++ b/dev/prod.celery.start.sh @@ -4,4 +4,5 @@ cd ~/celery_project for keyval in $(cat .env | sed -e 's/: /=/g' -e "s/'\|,\|{\|}//g" -e 's/", "/ /g' -e 's/"}//g' ); do export $keyval; done +conda activate shapeworks celery -A shapeworks_cloud.celery worker -n "w1@${HOSTNAME}" -Q gpu --logfile=celery-logs