From 0aca3e62e35b59dc6cfe603dc0051979b1810eeb Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Fri, 10 Nov 2023 19:58:21 +0100 Subject: [PATCH 1/3] Remove logs api --- backend/src/main.py | 12 ------------ backend/tests/test_api.py | 24 ------------------------ 2 files changed, 36 deletions(-) diff --git a/backend/src/main.py b/backend/src/main.py index faee0338..9533f007 100644 --- a/backend/src/main.py +++ b/backend/src/main.py @@ -195,18 +195,6 @@ def version(): return APP_VERSION -@router.get("/logs") -def logs(): - if "WORKSPACE" in os.environ and os.environ["WORKSPACE"] != "prod": - with open(os.path.join(PATH_LOGS, "log.json"), "r") as f: - lines = f.readlines() - res = [json.loads(l) for l in lines] - res.reverse() - return res - else: - return PlainTextResponse("Forbidden") - - @router.post("/upload") async def imageupload( request: Request, diff --git a/backend/tests/test_api.py b/backend/tests/test_api.py index bb582706..fba1addd 100644 --- a/backend/tests/test_api.py +++ b/backend/tests/test_api.py @@ -83,20 +83,6 @@ def test_upload(self): assert res["label"] == "revolver" assert res["confidence"] == pytest.approx(98.43, 0.1) assert res["confidence_level"] == "high" - # checks that the result is written in logs - r = client.get("/api/logs") - assert r.status_code == 200 - # checks the latest log with validates upload to object storage - assert r.json()[0]["_bg_image_url"] == r.json()[1]["_bg_image_url"] - assert r.json()[0]["short_message"] == "Upload successful" - # checks the previous log "Identification request" - log = r.json()[1] - self.check_log_base(log) - assert log["short_message"] == "Identification request" - assert "-" in log["_bg_user_id"] - assert log["_bg_label"] == "revolver" - assert log["_bg_confidence"] == pytest.approx(98.43, 0.1) - assert log["_bg_upload_time"] >= 0 def test_feedback_and_logs(self): """Checks that the feedback works properly""" @@ -116,13 +102,3 @@ def test_feedback_and_logs(self): ) assert r.status_code == 200 - r = client.get("/api/logs") - assert r.status_code == 200 - log = r.json()[0] - self.check_log_base(log) - assert log["short_message"] == "Identification feedback" - assert log["_bg_image_url"] == image_url - assert log["_bg_feedback_bool"] is True - assert log["_bg_confidence"] == confidence - assert log["_bg_label"] == label - assert log["_bg_confidence_level"] == confidence_level From 26c43f18e7f4daf9e4c4899ff1e5583a2cd6a829 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Fri, 10 Nov 2023 20:05:57 +0100 Subject: [PATCH 2/3] Revert "Add model to repo using git lfs" This reverts commit e256b8c661a36bb3da1bbbca8f5e0ad7b97476b6. --- .gitattributes | 1 - .gitignore | 4 ++++ backend/Dockerfile | 2 ++ backend/src/weights/model.pth | 3 --- 4 files changed, 6 insertions(+), 4 deletions(-) delete mode 100644 .gitattributes delete mode 100644 backend/src/weights/model.pth diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 821d7fe3..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -backend/src/weights/model.pth filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index a7fd6a73..79b63117 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,12 @@ dev-dist/ env/ .env __pycache__ +weights/ logs/ +temp/ *openrc.sh +.terraform* *.secrets* +version.txt *.crt *.pem \ No newline at end of file diff --git a/backend/Dockerfile b/backend/Dockerfile index a458e0a3..d9922815 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -23,8 +23,10 @@ RUN pip --default-timeout=300 install --upgrade pip \ ARG VERSION ARG MODEL="EffB7_2023-03-06_08" ENV SSL_CERT_FILE=$CACERT_LOCATION +RUN curl -o model.pth https://storage.gra.cloud.ovh.net/v1/AUTH_df731a99a3264215b973b3dee70a57af/basegun-public/models/${MODEL}/${MODEL}.pth COPY src/ src/ RUN mkdir -p src/weights \ + && mv model.pth src/weights/model.pth \ && echo '{"app": "'${VERSION}'", "model": "'${MODEL}'"}' > versions.json FROM base as dev diff --git a/backend/src/weights/model.pth b/backend/src/weights/model.pth deleted file mode 100644 index 8d147b55..00000000 --- a/backend/src/weights/model.pth +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4232b8d4b4d816fbb9478a9ff660d4fcc6d6098d3a10d964dc1f2f9c8d3d4872 -size 257321442 From 364ea37f7374acf1f36576834510bb07a0d45211 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Fri, 10 Nov 2023 20:06:10 +0100 Subject: [PATCH 3/3] Revert "Add lfs to github checkout action" This reverts commit 8b00c4b75b92c2bfffd07328156135eaf9ccf4ff. --- .github/workflows/pr.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 47539d8a..08d429c5 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -22,8 +22,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: - lfs: true - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3