From a28be4f28a3bfa5cd1d503f88c1612c68998dc3a Mon Sep 17 00:00:00 2001 From: Arnold Kochari Date: Fri, 29 Nov 2024 17:23:11 +0100 Subject: [PATCH 1/9] Rename start-single.sh to start-script.sh --- ptp/{start-single.sh => start-script.sh} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename ptp/{start-single.sh => start-script.sh} (70%) diff --git a/ptp/start-single.sh b/ptp/start-script.sh similarity index 70% rename from ptp/start-single.sh rename to ptp/start-script.sh index 39771ee..37b7eb5 100644 --- a/ptp/start-single.sh +++ b/ptp/start-script.sh @@ -5,4 +5,4 @@ echo "done!" echo "starting serving..." sh -c /app/start-django.sh -supervisord -c /etc/supervisor/conf.d/supervisord.conf \ No newline at end of file +supervisord -c /etc/supervisor/conf.d/supervisord.conf From 3909316fcfa36cecd338fddf82f4fb367ff10bb1 Mon Sep 17 00:00:00 2001 From: Arnold Kochari Date: Fri, 29 Nov 2024 17:23:58 +0100 Subject: [PATCH 2/9] Rename start-single.sh to start-script.sh --- ptp/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ptp/Dockerfile b/ptp/Dockerfile index e1b3f54..6d95e46 100644 --- a/ptp/Dockerfile +++ b/ptp/Dockerfile @@ -41,7 +41,7 @@ RUN useradd -u 1000 $USER RUN chown -R $USER:$USER /etc/supervisor/conf.d/supervisord.conf RUN chown -R $USER:$USER /app/ RUN chown -R $USER:$USER /var/log/supervisor/ -RUN chmod +x /app/start-single.sh +RUN chmod +x /app/start-script.sh RUN chmod +x /app/start-django.sh RUN chmod +x /app/download.sh @@ -53,4 +53,4 @@ ENV REDIS_URL="redis://localhost:6379/0" ENV DOWNLOAD=false # Start supervisord -CMD ["sh", "-c", "/app/start-single.sh"] \ No newline at end of file +CMD ["sh", "-c", "/app/start-script.sh"] From e31a74b4f7f7921fcb5b7ff83a2aad4c34e31290 Mon Sep 17 00:00:00 2001 From: Arnold Kochari Date: Fri, 29 Nov 2024 17:30:39 +0100 Subject: [PATCH 3/9] allow to work with my repository --- .github/workflows/build-ptp.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-ptp.yaml b/.github/workflows/build-ptp.yaml index 36340d3..27a8f2b 100644 --- a/.github/workflows/build-ptp.yaml +++ b/.github/workflows/build-ptp.yaml @@ -69,7 +69,7 @@ jobs: with: # list of Docker images to use as base name for tags images: | - ghcr.io/pharmbio/ptp + ghcr.io/akochari/ptp # generate Docker tags based on the following events/attributes tags: | type=schedule From 6e4cb712113846d05176316cc0aaa5e656b9495c Mon Sep 17 00:00:00 2001 From: akochari Date: Tue, 3 Dec 2024 15:07:18 +0100 Subject: [PATCH 4/9] rearrange a bit for Serve --- ptp/Dockerfile | 6 ++---- ptp/download.sh | 9 --------- ptp/start-script.sh | 4 ---- 3 files changed, 2 insertions(+), 17 deletions(-) delete mode 100644 ptp/download.sh diff --git a/ptp/Dockerfile b/ptp/Dockerfile index 6d95e46..a442949 100644 --- a/ptp/Dockerfile +++ b/ptp/Dockerfile @@ -31,8 +31,6 @@ COPY . /app/ WORKDIR /app - - # Expose the port the Django app runs on EXPOSE 8000 @@ -43,14 +41,14 @@ RUN chown -R $USER:$USER /app/ RUN chown -R $USER:$USER /var/log/supervisor/ RUN chmod +x /app/start-script.sh RUN chmod +x /app/start-django.sh -RUN chmod +x /app/download.sh # Make sure the container is running as non-root USER $USER ENV CELERY_BROKER_URL="redis://localhost:6379/0" ENV REDIS_URL="redis://localhost:6379/0" -ENV DOWNLOAD=false +ENV MODEL_DIR = "/app/inference/models/models" +# Models will be downloaded and placed in /app/inference/models/models through SciLifeLab Serve interface # Start supervisord CMD ["sh", "-c", "/app/start-script.sh"] diff --git a/ptp/download.sh b/ptp/download.sh deleted file mode 100644 index adec30f..0000000 --- a/ptp/download.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -if [ "$DOWNLOAD" = "true" ]; then - git clone https://huggingface.co/pharmbio/ptp /app/inference/models && \ - cd /app/inference/models && \ - git lfs pull -else - echo "noop" -fi -exit 0 \ No newline at end of file diff --git a/ptp/start-script.sh b/ptp/start-script.sh index 37b7eb5..94c994d 100644 --- a/ptp/start-script.sh +++ b/ptp/start-script.sh @@ -1,8 +1,4 @@ #!/bin/bash -echo "downloading models.." -sh -c /app/download.sh -echo "done!" -echo "starting serving..." sh -c /app/start-django.sh supervisord -c /etc/supervisor/conf.d/supervisord.conf From 461b9ec6f1b1b2a24f2fbf65fa722027260c0b47 Mon Sep 17 00:00:00 2001 From: akochari Date: Tue, 3 Dec 2024 15:37:39 +0100 Subject: [PATCH 5/9] pre-create models directory --- ptp/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/ptp/Dockerfile b/ptp/Dockerfile index a442949..56a2ff2 100644 --- a/ptp/Dockerfile +++ b/ptp/Dockerfile @@ -30,6 +30,7 @@ FROM djangobase AS djangoapp COPY . /app/ WORKDIR /app +RUN mkdir /app/inference/models/ # Expose the port the Django app runs on EXPOSE 8000 From c34c5bdae1a9d4b4618fa6dd951f5d3593fda20e Mon Sep 17 00:00:00 2001 From: Arnold Kochari Date: Tue, 3 Dec 2024 16:13:38 +0100 Subject: [PATCH 6/9] allow to run in any repo --- .github/workflows/build-ptp.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-ptp.yaml b/.github/workflows/build-ptp.yaml index 27a8f2b..27c9370 100644 --- a/.github/workflows/build-ptp.yaml +++ b/.github/workflows/build-ptp.yaml @@ -31,7 +31,7 @@ jobs: env: REGISTRY: ghcr.io - IMAGE_NAME: 'ptp' + IMAGE_NAME: ${{ github.repository }} #DOCKER_USER: ${{ secrets.DOCKER_USER }} #DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} working-directory: ./ptp @@ -69,7 +69,7 @@ jobs: with: # list of Docker images to use as base name for tags images: | - ghcr.io/akochari/ptp + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} # generate Docker tags based on the following events/attributes tags: | type=schedule From f53a3354edd4e39ccd7bb1a1e896c3c935a0720e Mon Sep 17 00:00:00 2001 From: akochari Date: Tue, 3 Dec 2024 16:21:26 +0100 Subject: [PATCH 7/9] add explicit host --- ptp/ptp/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ptp/ptp/settings.py b/ptp/ptp/settings.py index c808a68..075c87e 100644 --- a/ptp/ptp/settings.py +++ b/ptp/ptp/settings.py @@ -8,9 +8,9 @@ SECRET_KEY = 'ptp_for_president_CC44aAFG' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False -ALLOWED_HOSTS = ['*', 'localhost'] +ALLOWED_HOSTS = ['localhost', 'ptp-inference.serve.scilifelab.se'] # Application definition INSTALLED_APPS = [ From 5ccea4b5c130fd8ca5f4dd6ca7a0dd8c451fe329 Mon Sep 17 00:00:00 2001 From: akochari Date: Tue, 3 Dec 2024 16:28:56 +0100 Subject: [PATCH 8/9] add back --- ptp/ptp/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ptp/ptp/settings.py b/ptp/ptp/settings.py index 075c87e..2cb18b1 100644 --- a/ptp/ptp/settings.py +++ b/ptp/ptp/settings.py @@ -10,7 +10,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False -ALLOWED_HOSTS = ['localhost', 'ptp-inference.serve.scilifelab.se'] +ALLOWED_HOSTS = ['*', 'localhost', 'ptp-inference.serve.scilifelab.se'] # Application definition INSTALLED_APPS = [ From c411741098eed056139bffe64f80a2e3ef6709fa Mon Sep 17 00:00:00 2001 From: akochari Date: Tue, 3 Dec 2024 16:33:05 +0100 Subject: [PATCH 9/9] revert settings back --- ptp/ptp/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ptp/ptp/settings.py b/ptp/ptp/settings.py index 2cb18b1..c808a68 100644 --- a/ptp/ptp/settings.py +++ b/ptp/ptp/settings.py @@ -8,9 +8,9 @@ SECRET_KEY = 'ptp_for_president_CC44aAFG' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +DEBUG = True -ALLOWED_HOSTS = ['*', 'localhost', 'ptp-inference.serve.scilifelab.se'] +ALLOWED_HOSTS = ['*', 'localhost'] # Application definition INSTALLED_APPS = [