Skip to content

Commit

Permalink
fix: don't refresh ES indexes during scheduler startup
Browse files Browse the repository at this point in the history
It's only used now for spellcheck, which isn't used anywhere
  • Loading branch information
raphael0202 committed Dec 13, 2022
1 parent 667d19d commit fa72748
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions robotoff/scheduler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from sentry_sdk import capture_exception

from robotoff import settings, slack
from robotoff.elasticsearch.export import ElasticsearchExporter
from robotoff.insights.annotate import (
UPDATED_ANNOTATION_RESULT,
InsightAnnotatorFactory,
Expand All @@ -33,7 +32,6 @@
has_dataset_changed,
)
from robotoff.utils import get_logger
from robotoff.utils.es import get_es_client

from .latent import generate_quality_facets

Expand Down Expand Up @@ -194,28 +192,13 @@ def _download_product_dataset():
fetch_dataset()


def _refresh_elasticsearch():
logger.info("Refreshing Elasticsearch data")

es_client = get_es_client()
exporter = ElasticsearchExporter(es_client)

for index, config_path in settings.ElasticsearchIndex.SUPPORTED_INDICES.items():
exporter.load_index(index, config_path)
exporter.export_index_data(index)


# this job does no use database
def _update_data():
"""Refreshes the PO product dump and updates the Elasticsearch index data."""
try:
_download_product_dataset()
# Elasticsearch is dependent on the availability of the product dump from Product Opener
# (main Open Food Facts backend)
# it it called after the download product dataset call.
_refresh_elasticsearch()
except requests.exceptions.RequestException:
logger.exception("Exception while running ES updates for categories")
logger.exception("Exception during product dataset refresh")


def generate_insights():
Expand Down

0 comments on commit fa72748

Please sign in to comment.