Skip to content

Commit

Permalink
fix: use Python SDK update listener (#1496)
Browse files Browse the repository at this point in the history
* fix: remove output_image parameter in detect_from_image_tf

* fix: use openfoodfacts UpdateListener class
  • Loading branch information
raphael0202 authored Dec 11, 2024
1 parent 5e43dab commit fb60549
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 173 deletions.
110 changes: 55 additions & 55 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ lark = "~1.1.4"
h5py = "~3.8.0"
opencv-python-headless = "~4.10.0.84"
toml = "~0.10.2"
openfoodfacts = "2.3.4"
openfoodfacts = "2.4.0"
imagehash = "~4.3.1"
peewee-migrate = "~1.12.2"
diskcache = "~5.6.3"
Expand Down
11 changes: 9 additions & 2 deletions robotoff/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,19 @@ def process_updates_since(
)
):
"""Process all updates since a given datetime."""
from robotoff import settings
from robotoff.utils.logger import get_logger
from robotoff.workers.update_listener import process_updates_since
from robotoff.workers.update_listener import UpdateListener, get_redis_client

logger = get_logger()
logger.info("Processing Redis updates since %s", since)
process_updates_since(since)
redis_client = get_redis_client()
update_listener = UpdateListener(
redis_client=redis_client,
redis_stream_name=settings.REDIS_STREAM_NAME,
redis_latest_id_key=settings.REDIS_LATEST_ID_KEY,
)
update_listener.process_updates_since(since)


@app.command()
Expand Down
3 changes: 3 additions & 0 deletions robotoff/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ def event_api() -> str:

# Name of the Redis stream where Product Opener publishes product updates
REDIS_STREAM_NAME = os.environ.get("REDIS_STREAM_NAME", "product_updates_off")
REDIS_LATEST_ID_KEY = os.environ.get(
"REDIS_LATEST_ID_KEY", "robotoff:product_updates:latest_id"
)

# how many seconds should we wait to compute insight on product updated
UPDATED_PRODUCT_WAIT = float(os.environ.get("ROBOTOFF_UPDATED_PRODUCT_WAIT", 10))
Expand Down
Loading

0 comments on commit fb60549

Please sign in to comment.