Skip to content

Commit

Permalink
Merge pull request #337 from girder/deepssm
Browse files Browse the repository at this point in the history
Deepssm
  • Loading branch information
JakeWags authored Apr 9, 2024
2 parents 4313760 + b71902a commit 7fcf40c
Show file tree
Hide file tree
Showing 17 changed files with 1,516 additions and 66 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install tox
run: |
pip install --upgrade pip
pip install tox

- name: Build images
run: docker-compose -f "docker-compose.yml" build
- name: Install Tox
run: |
docker-compose run --rm django pip install --upgrade pip
docker-compose run --rm django pip install tox
- name: Start services
run: docker-compose -f "docker-compose.yml" up -d

Expand All @@ -32,7 +32,7 @@ jobs:
verbose: true

- name: Run tox
run: tox
run: docker-compose run --rm django tox
env:
DJANGO_DATABASE_URL: postgres://postgres:postgres@localhost:5432/django
DJANGO_MINIO_STORAGE_ENDPOINT: localhost:9000
Expand Down
34 changes: 28 additions & 6 deletions dev/django.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,56 @@ FROM python:3.8-slim
# * psycopg2
RUN apt-get update && \
apt-get install --no-install-recommends --yes \
libpq-dev gcc libc6-dev curl unzip \
git-all libpq-dev gcc libc6-dev curl unzip \
libgl1-mesa-glx libxt6 libglib2.0-0 \
libqt5core5a \
libxrender1 \
&& \
rm -rf /var/lib/apt/lists/*

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install_shapeworks.sh for DeepSSM python api. This must be run from within a conda environment
# install conda
ENV PATH=/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV LDFLAGS=-L/opt/conda/lib
RUN 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

# Only copy the setup.py, it will still force all install_requires to be installed,
# but find_packages() will find nothing (which is fine). When Docker Compose mounts the real source
# over top of this directory, the .egg-link in site-packages resolves to the mounted directory
# and all package modules are importable.
COPY ./setup.py /opt/django-project/setup.py
COPY ./swcc/setup.py /opt/django-project/swcc/setup.py
RUN pip install -U pip && \
pip install --editable /opt/django-project[dev] && \
pip install --editable /opt/django-project/swcc

RUN export url=$(curl -s https://api.github.com/repos/SCIInstitute/ShapeWorks/releases | grep -o "http.*dev-linux.*.gz"); \
curl -L -o /tmp/shapeworks.tgz $url
RUN mkdir /opt/shapeworks && \
tar -zxvf /tmp/shapeworks.tgz -C /opt/shapeworks --strip-components 1 && \
rm /tmp/shapeworks.tgz

COPY ./setup.py /opt/django-project/setup.py
COPY ./swcc/setup.py /opt/django-project/swcc/setup.py

# Run install_shapeworks.sh
SHELL ["conda", "run", "/bin/bash", "-c"]
RUN cd /opt/shapeworks ; ls ; source install_shapeworks.sh ; conda clean -t -y
SHELL ["conda", "run", "-n", "shapeworks", "bin/bash", "-c"]
RUN echo "conda activate shapeworks" >> ~/.bashrc

RUN pip install -U pip && \
pip install --editable /opt/django-project[dev] && \
pip install --editable /opt/django-project/swcc

ENV PATH $PATH:/opt/shapeworks/bin
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/opt/shapeworks/lib

RUN pip install awscli

# Use a directory name which will never be an import name, as isort considers this as first-party.
WORKDIR /opt/django-project
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "shapeworks"]
37 changes: 32 additions & 5 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ services:
build:
context: .
dockerfile: ./dev/django.Dockerfile
command: [ "./manage.py", "runserver", "0.0.0.0:8000" ]
command: [
"./manage.py",
"runserver",
"0.0.0.0:8000"
]
# Log printing via Rich is enhanced by a TTY
tty: true
env_file: ./dev/.env.docker-compose
Expand Down Expand Up @@ -45,22 +49,45 @@ services:
- rabbitmq
- minio

celery-beat:
celery-gpu:
build:
context: .
dockerfile: ./dev/django.Dockerfile
command: [ "celery", "--app", "shapeworks_cloud.celery", "beat" ]
command:
[
"celery",
"--app",
"shapeworks_cloud.celery",
"worker",
"-Q",
"gpu",
"-n=gpu",
"-P",
"threads",
"--loglevel",
"INFO",
"--without-heartbeat"
]
# Docker Compose does not set the TTY width, which causes Celery errors
tty: false
env_file: ./dev/.env.celery.docker-compose
volumes:
- .:/opt/django-project
# Use host mode so that celery can use the localhost:8000 API in dev deployments
network_mode: host
shm_size: 8gb
depends_on:
- celery
- postgres
- rabbitmq
- minio

yarn:
image: node:17
command: [ "/bin/bash", "-c", "yarn install && yarn serve" ]
command: [
"/bin/bash",
"-c",
"yarn install && yarn serve"
]
env_file: ./dev/yarn.env
environment:
- NODE_OPTIONS=--openssl-legacy-provider
Expand Down
Loading

0 comments on commit 7fcf40c

Please sign in to comment.