Skip to content

Commit

Permalink
fix: don't open DB connection twice
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Dec 26, 2022
1 parent e45bd3a commit 3319c0b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions robotoff/workers/tasks/import_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def run_logo_object_detection(
]

if logos and process_logos:
with db:
with db.connection_context():
save_logo_embeddings(logos, image)
enqueue_job(
process_created_logos,
Expand All @@ -406,7 +406,7 @@ def save_logo_embeddings(logos: list[LogoAnnotation], image: Image.Image):
cropped_images.append(image.crop((left, top, right, bottom)))
embeddings = generate_clip_embedding(cropped_images)

with db:
with db.atomic():
for i in range(len(logos)):
logo_id = logos[i].id
logo_embedding = embeddings[i]
Expand Down

0 comments on commit 3319c0b

Please sign in to comment.