From 77f181f67bd8b599f5c915bb5cec333617a55943 Mon Sep 17 00:00:00 2001 From: Louis Beaumont Date: Thu, 22 Jun 2023 14:47:13 -0700 Subject: [PATCH] hack migration --- hosted/Makefile | 2 +- .../middlewares/auth_api_key/auth_api_key.py | 21 +++++++++++++++++++ hosted/requirements.txt | 2 +- hosted/version.txt | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/hosted/Makefile b/hosted/Makefile index a7680fa..4dfd635 100644 --- a/hosted/Makefile +++ b/hosted/Makefile @@ -2,7 +2,7 @@ LOCAL_PORT="8000" SERVICE="embedbase-hosted" GCLOUD_PROJECT:=$(shell gcloud config list --format 'value(core.project)' 2>/dev/null || echo "none") LATEST_IMAGE_URL=$(shell echo "gcr.io/${GCLOUD_PROJECT}/${SERVICE}:latest") -VERSION=$(shell sed -n 's/.*__version__ = \"\(.*\)\"/\1/p' version.py) +VERSION=$(shell cat version.txt) IMAGE_URL=$(shell echo "gcr.io/${GCLOUD_PROJECT}/${SERVICE}:${VERSION}") REGION="us-central1" diff --git a/hosted/middlewares/auth_api_key/auth_api_key.py b/hosted/middlewares/auth_api_key/auth_api_key.py index f059dcb..2b42df8 100644 --- a/hosted/middlewares/auth_api_key/auth_api_key.py +++ b/hosted/middlewares/auth_api_key/auth_api_key.py @@ -178,6 +178,27 @@ async def dispatch(self, request: Request, call_next) -> Tuple[str, str]: if request.scope["type"] != "http": # pragma: no cover return await call_next(request) + add_pattern = re.compile(r"^/v1/[^/]+$") + + # if the path looks like /v1/{dataset_id} POST we + # send a 400 and tell the user that the add endpoint is currently in maintenance + # the maintainance should be less than 20 minutes + if ( + re.match(add_pattern, request.scope["path"]) + and request.scope["method"] == "POST" + ): + return JSONResponse( + status_code=400, + content={ + "message": "The add endpoint is currently in maintenance. Please try again in 20 minutes." + }, + headers={ + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "*", + "Access-Control-Allow-Headers": "*", + }, + ) + if any(path in request.scope["path"] for path in PRODUCTION_IGNORED_PATHS): return await call_next(request) # in development mode, allow redoc, openapi etc diff --git a/hosted/requirements.txt b/hosted/requirements.txt index 3bbb341..c479388 100644 --- a/hosted/requirements.txt +++ b/hosted/requirements.txt @@ -1,7 +1,7 @@ posthog supabase firebase_admin -embedbase +embedbase==1.2.8 openai sentry_sdk[fastapi] gunicorn diff --git a/hosted/version.txt b/hosted/version.txt index 4e69c2a..09b254e 100644 --- a/hosted/version.txt +++ b/hosted/version.txt @@ -1 +1 @@ -0.5.10 \ No newline at end of file +6.0.0