From 092d0f2f21f48d2084ca7b4f390e21ac92854377 Mon Sep 17 00:00:00 2001 From: Saba Date: Mon, 4 Jul 2022 12:33:55 -0400 Subject: [PATCH 1/5] Move Dockerfile to project root to avoid permissions issues. Allocate more memory to docker-compose to avoid OOM --- config/Dockerfile => Dockerfile | 2 +- README.org | 2 +- docker-compose.yml | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) rename config/Dockerfile => Dockerfile (98%) diff --git a/config/Dockerfile b/Dockerfile similarity index 98% rename from config/Dockerfile rename to Dockerfile index 02ba84aa..abed586d 100644 --- a/config/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update -y && \ # Add the local code to the /app directory and set it to be the working directory. # Since we mount the /app directory as a volume in docker-compose.yml, this # allows us to automatically update the code in the Docker image when it's changed. -ADD .. /app +ADD . /app WORKDIR /app # Get the arguments from the docker-compose environment. diff --git a/README.org b/README.org index e8394a0c..19ee69de 100644 --- a/README.org +++ b/README.org @@ -39,7 +39,7 @@ ** Upgrade #+begin_src shell - docker-compose build + docker-compose build --pull #+end_src ** Troubleshooting diff --git a/docker-compose.yml b/docker-compose.yml index a75e77d0..07daded2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: server: build: context: . - dockerfile: config/Dockerfile + dockerfile: Dockerfile args: - PORT=8000 ports: @@ -28,6 +28,9 @@ services: # You can set these volumes to point to empty directories on host - ./tests/data/embeddings/:/data/embeddings/ - ./tests/data/models/:/data/models/ - + deploy: + resources: + limits: + memory: 2GB # Use 0.0.0.0 to explicitly set the host ip for the service on the container. https://pythonspeed.com/articles/docker-connection-refused/ command: --host="0.0.0.0" --port=8000 -c=config/sample_config.yml -vv From 0f88abd219d21353deb063fcbb6e8cb12ea40c27 Mon Sep 17 00:00:00 2001 From: Saba Date: Mon, 4 Jul 2022 14:01:59 -0400 Subject: [PATCH 2/5] Allocate 8GB of memory to docker container. Adjust path to Dockerfile in Github action --- .github/workflows/build.yml | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5ea7996d..f402734d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: config/Dockerfile + file: Dockerfile push: true tags: ghcr.io/${{ github.repository }}:latest build-args: | diff --git a/docker-compose.yml b/docker-compose.yml index 07daded2..54d070c5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,6 +31,6 @@ services: deploy: resources: limits: - memory: 2GB + memory: 8GB # Use 0.0.0.0 to explicitly set the host ip for the service on the container. https://pythonspeed.com/articles/docker-connection-refused/ command: --host="0.0.0.0" --port=8000 -c=config/sample_config.yml -vv From 07a56c4ab665f6b7d688bb4faf79eaf13ab5ba5e Mon Sep 17 00:00:00 2001 From: Saba Date: Mon, 4 Jul 2022 18:01:55 -0400 Subject: [PATCH 3/5] Add specific version for Python packages and downgrade miniconda Docker image to potentially fix build issues --- Dockerfile | 2 +- README.org | 4 ++++ config/environment.yml | 30 +++++++++++++++--------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index abed586d..8437d38e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1 -FROM continuumio/miniconda3:latest +FROM continuumio/miniconda3:4.12.0 # Install system dependencies. RUN apt-get update -y && \ diff --git a/README.org b/README.org index 19ee69de..e03bc37d 100644 --- a/README.org +++ b/README.org @@ -37,6 +37,10 @@ - [[https://github.com/debanjum/semantic-search/tree/master/src/interface/emacs#installation][Install]] [[./src/interface/emacs/semantic-search.el][semantic-search.el]] - Run ~M-x semantic-search ~ +** Run Unit tests + + `pytest` + ** Upgrade #+begin_src shell docker-compose build --pull diff --git a/config/environment.yml b/config/environment.yml index bb1dc845..289d20d7 100644 --- a/config/environment.yml +++ b/config/environment.yml @@ -2,19 +2,19 @@ name: semantic-search channels: - conda-forge dependencies: - - python=3.* - - numpy=1.* - - pytorch=1.* - - transformers=4.* + - python=3.8.* + - numpy=1.22.4 + - pytorch=1.11.0 + - transformers=4.19.4 - sentence-transformers=2.1.0 - - fastapi=0.* - - uvicorn=0.* - - pyyaml=5.* - - pytest=6.* - - pillow=8.* - - torchvision=0.* - - openai=0.* - - pydantic=1.* - - jinja2=3.0.* - - aiofiles=0.* - - huggingface_hub=0.* \ No newline at end of file + - fastapi=0.77.1 + - uvicorn=0.17.6 + - pyyaml=6.0 + - pytest=7.1.2 + - pillow=8.4.0 + - torchvision=0.12.0 + - openai=0.20.0 + - pydantic=1.9.1 + - jinja2=3.1.2 + - aiofiles=0.8.0 + - huggingface_hub=0.8.1 From 7bb35ccc7e8ac6a908f5f91a73678f2392fba903 Mon Sep 17 00:00:00 2001 From: Saba Date: Mon, 4 Jul 2022 18:09:47 -0400 Subject: [PATCH 4/5] Run build on PR --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f402734d..b09cfd10 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,9 @@ name: build on: + pull_request: + branches: + - master push: branches: - master From 2eb44c7a64069a55900390060a84f8da51773c22 Mon Sep 17 00:00:00 2001 From: Saba Date: Wed, 6 Jul 2022 20:07:11 -0400 Subject: [PATCH 5/5] Correct syntax of memory limit in docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 54d070c5..fbf2a6b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,6 +31,6 @@ services: deploy: resources: limits: - memory: 8GB + memory: 8g # Use 0.0.0.0 to explicitly set the host ip for the service on the container. https://pythonspeed.com/articles/docker-connection-refused/ command: --host="0.0.0.0" --port=8000 -c=config/sample_config.yml -vv