Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove logs api #269

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ dev-dist/
env/
.env
__pycache__
weights/
logs/
temp/
*openrc.sh
.terraform*
*.secrets*
version.txt
*.crt
*.pem
2 changes: 2 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions backend/src/weights/model.pth

This file was deleted.

24 changes: 0 additions & 24 deletions backend/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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
Loading