Skip to content

Commit

Permalink
Remove S3_URL_VISUALIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashbrnrd committed Sep 29, 2023
1 parent 7e64d60 commit 971b899
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
8 changes: 3 additions & 5 deletions backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def upload_image(content: bytes, image_key: str):
extras_logging = {
"bg_date": datetime.now().isoformat(),
"bg_upload_time": time.time()-start,
"bg_image_url": os.path.join(S3_URL_VISUALIZE, image_key)
"bg_image_url": image_key
}
logger.info("Upload successful", extra=extras_logging)

Expand Down Expand Up @@ -173,7 +173,6 @@ def upload_image(content: bytes, image_key: str):

# Object storage
S3_URL_ENDPOINT = init_variable("S3_URL_ENDPOINT", "https://s3.gra.io.cloud.ovh.net/")
S3_URL_VISUALIZE = "https://basegun-s3.s3.gra.io.cloud.ovh.net/"
S3_BUCKET_NAME = "basegun-s3"
S3_PREFIX = os.path.join("uploaded-images/", os.environ['WORKSPACE'])
s3 = boto3.resource("s3", endpoint_url=S3_URL_ENDPOINT)
Expand Down Expand Up @@ -244,8 +243,7 @@ async def imageupload(

# upload image to OVH Cloud
background_tasks.add_task(upload_image, img_bytes, img_key)
img_path = os.path.join(S3_URL_VISUALIZE, img_key)
extras_logging["bg_image_url"] = img_path
extras_logging["bg_image_url"] = img_key

# set user id
if not user_id:
Expand All @@ -269,7 +267,7 @@ async def imageupload(
logger.info("Identification request", extra=extras_logging)

return {
"path": img_path,
"path": img_key,
"label": label,
"confidence": confidence,
"confidence_level": extras_logging["bg_confidence_level"]
Expand Down
9 changes: 0 additions & 9 deletions backend/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@ def test_upload(self):
self.assertEqual(res["label"], "revolver")
self.assertAlmostEqual(res["confidence"], 98.43, places=1)
self.assertTrue(res["confidence_level"], "high")
"""
# checks that written file is exactly the same as input file
response = requests.get(res["path"])
with Image.open(path) as image_one:
with Image.open(BytesIO(response.content)) as image_two:
self.assertEqual(image_one.size, image_two.size)
diff = ImageChops.difference(image_one, image_two)
self.assertFalse(diff.getbbox())
"""
# checks that the result is written in logs
r = client.get("/logs")
self.assertEqual(r.status_code, 200)
Expand Down

0 comments on commit 971b899

Please sign in to comment.