Skip to content

Commit

Permalink
fix: wait for Product Opener to generate the dump before downloading it
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Sep 12, 2024
1 parent 857fea1 commit 6eae9d5
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions robotoff/scheduler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,13 @@ def update_insight_attributes(product: Product, insight: ProductInsight) -> bool
return bool(updated_fields)


def _download_product_dataset():
logger.info("Downloading new version of product dataset")

if has_dataset_changed():
fetch_dataset()


# this job does no use database
def _update_data():
"""Refreshes the PO product dump data."""
logger.info("Downloading new version of product dataset")
try:
_download_product_dataset()
if has_dataset_changed():
fetch_dataset()
except requests.exceptions.RequestException:
logger.exception("Exception during product dataset refresh")

Expand Down Expand Up @@ -341,7 +336,7 @@ def run():
scheduler.add_job(save_insight_metrics, "cron", day="*", hour=1, max_instances=1)

# This job refreshes data needed to generate insights.
scheduler.add_job(_update_data, "cron", day="*", hour="8", max_instances=1)
scheduler.add_job(_update_data, "cron", day="*", hour="15", max_instances=1)

# This job updates the product insights state with respect to the latest PO
# dump by:
Expand All @@ -352,7 +347,7 @@ def run():
refresh_insights,
"cron",
day="*",
hour="15",
hour="16",
max_instances=1,
)

Expand Down

0 comments on commit 6eae9d5

Please sign in to comment.