Skip to content

Commit

Permalink
fix: fix nutrient insight importer
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Oct 24, 2024
1 parent 9ae5ff7 commit 0e4aff3
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions robotoff/insights/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1536,12 +1536,29 @@ def get_required_prediction_types(cls) -> set[PredictionType]:
@classmethod
def generate_candidates(
cls,
product: Optional[Product],
product: Product | None,
predictions: list[Prediction],
product_id: ProductIdentifier,
) -> Iterator[ProductInsight]:
if product is not None and product.nutriments:
# Don't generate candidates if the product already has nutrients
# Don't generate candidates if the product already has nutrients
if (
product is not None
and product.nutriments
# If we delete all nutrient values, these computed values are still
# present. We therefore ignore these keys.
and set(
key
for key in product.nutriments.keys()
if not (
key.startswith("carbon-footprint-from-known-ingredients")
or key.startswith(
"fruits-vegetables-legumes-estimate-from-ingredients"
)
or key.startswith("nova-group")
or key.startswith("nutrition-score-fr")
)
)
):
return

for prediction in predictions:
Expand Down

0 comments on commit 0e4aff3

Please sign in to comment.