Skip to content

Commit

Permalink
0.2.0: improve large note handling, large vault, optimise speed
Browse files Browse the repository at this point in the history
  • Loading branch information
louis030195 committed Jan 5, 2023
1 parent da21179 commit a54c020
Show file tree
Hide file tree
Showing 16 changed files with 17,935 additions and 303 deletions.
25 changes: 10 additions & 15 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
Dockerfile
README.md
*.pyc
*.pyo
*.pyd
__pycache__
.pytest_cache
test*.py
*.ipynb*
public
.firebase*
.gitignore
firebase.json
.pylintrc
*.yaml
# ignore everything
**
.*

# Allow files and directories
!search/**
!setup.py
!*requirements.txt
!README.md
!MANIFEST.in
2 changes: 1 addition & 1 deletion .github/workflows/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
file: ./search/Dockerfile
platforms: linux/amd64
push: true
tags: |
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"python.envFile": "${workspaceFolder}/.env",
"python.formatting.provider": "black",
"python.testing.pytestArgs": [
"."
"./search"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
Expand Down
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@ install: ## [DEVELOPMENT] Install the API dependencies
@echo "Done, run '\033[0;31msource env/bin/activate\033[0m' to activate the virtual environment"

run: ## [DEVELOPMENT] Run the API
python3 -m uvicorn api:app --port 3333 --reload --log-level debug
python3 -m uvicorn search.api:app --port 3333 --reload --log-level debug
# GUNICORN_CMD_ARGS="--keep-alive 0" gunicorn -w 1 -k uvicorn.workers.UvicornH11Worker api:app -b 0.0.0.0:3333 --log-level debug --timeout 120

test: ## [Local development] Run tests with pytest.
python3 -m pytest -s -vv test_main.py::test_refresh_small_notes
python3 -m pytest -s -vv test_main.py::test_embed
cd search; \
python3 -m pytest -s -vv test_main.py::test_refresh_small_notes; \
python3 -m pytest -s -vv test_main.py::test_embed; \
python3 -m pytest -s -vv test_main.py::test_upload
@echo "Done testing"

docker/build: ## [Local development] Build the docker image.
@echo "Building docker image for urls ${LATEST_IMAGE_URL} and ${IMAGE_URL}"
docker buildx build . --platform linux/amd64 -t ${LATEST_IMAGE_URL} -f ./Dockerfile
docker buildx build . --platform linux/amd64 -t ${IMAGE_URL} -f ./Dockerfile
docker buildx build . --platform linux/amd64 -t ${LATEST_IMAGE_URL} -f ./search/Dockerfile
docker buildx build . --platform linux/amd64 -t ${IMAGE_URL} -f ./search/Dockerfile

docker/run: ## [Local development] Run the docker image.
docker build -t ${IMAGE_URL} -f ./Dockerfile .
docker run -p 8080:8080 --rm --name ${SERVICE} -v $(shell pwd)/.env:/app/.env ${IMAGE_URL}
docker build -t ${IMAGE_URL} -f ./search/Dockerfile .
docker run -p 8080:8080 --rm --name ${SERVICE} -v "$(shell pwd)/.env":/app/.env ${IMAGE_URL}

docker/push: docker/build ## [Local development] Push the docker image to GCP.
docker push ${IMAGE_URL}
Expand All @@ -43,7 +45,7 @@ docker/deploy: docker/push ## [Local development] Deploy the Cloud run service.
gcloud beta run services replace ./service.prod.yaml --region ${REGION}

docker/deploy/dev: ## [Local development] Deploy the Cloud run service.
docker buildx build . --platform linux/amd64 -t ${LATEST_IMAGE_URL}-dev -f ./Dockerfile
docker buildx build . --platform linux/amd64 -t ${LATEST_IMAGE_URL}-dev -f ./search/Dockerfile
docker push ${LATEST_IMAGE_URL}-dev
gcloud beta run services replace ./service.dev.yaml --region ${REGION}

Expand Down
189 changes: 0 additions & 189 deletions fine_tuning.py

This file was deleted.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
sentence-transformers
fastapi
uvicorn[standard]
pinecone-client
Expand All @@ -7,3 +6,4 @@ openai
sentry-sdk[fastapi]
posthog
tenacity
gunicorn
5 changes: 2 additions & 3 deletions Dockerfile → search/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ COPY . ./
ENV PORT 8080

RUN pip install --no-cache-dir -r requirements.txt
# multi-qa-MiniLM-L6-cos-v1
RUN python -c "import os; from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/multi-qa-MiniLM-L6-cos-v1')"
# As an example here we're running the web service with one worker on uvicorn.
CMD exec uvicorn api:app --host 0.0.0.0 --port ${PORT} --workers 1
# CMD exec gunicorn -w 1 -k uvicorn.workers.UvicornH11Worker api:app -b 0.0.0.0:${PORT} --threads 4
CMD exec uvicorn search.api:app --host 0.0.0.0 --port ${PORT} --workers 1
File renamed without changes.
Loading

0 comments on commit a54c020

Please sign in to comment.