Skip to content

Commit

Permalink
fix: adding documentation about the insights/annotate.py file (#944)
Browse files Browse the repository at this point in the history
* fix: adding documentation about the insights/annotate.py file

* Format code with black and isort

* Update robotoff/insights/annotate.py

Co-authored-by: Raphaël Bournhonesque <raphael0202@users.noreply.github.com>

* Update robotoff/insights/annotate.py

Co-authored-by: Raphaël Bournhonesque <raphael0202@users.noreply.github.com>

* Format code with black and isort

* Update robotoff/insights/annotate.py

Co-authored-by: Pierre Slamich <pierre@openfoodfacts.org>

* Update robotoff/insights/annotate.py

Co-authored-by: Pierre Slamich <pierre@openfoodfacts.org>

* Update robotoff/insights/annotate.py

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Co-authored-by: Raphaël Bournhonesque <raphael0202@users.noreply.github.com>
Co-authored-by: Pierre Slamich <pierre@openfoodfacts.org>
  • Loading branch information
4 people authored Oct 10, 2022
1 parent f189031 commit 18e5c66
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion robotoff/insights/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
from robotoff.products import get_image_id, get_product
from robotoff.utils import get_logger

"""
This file allows to annotate products.
To check whether the annotation already exists or not (and save it and send it to the Open Food Facts database), use the following commands:
from robotoff.insights.annotate import InsightAnnotatorFactor
annotator = InsightAnnotatorFactory.get(insight_type)
annotator.annotate(insight: ProductInsight, annotation: int, update: bool = True, data: Optional[Dict] = None, auth: Optional[OFFAuthentication] = None, automatic: bool = False)
If you don't want to update the Open Food Facts database but only save the insight annotation (if the update is performed on the client side for example), you can call `annotate()` with `update=False`.
"""


logger = get_logger(__name__)


Expand Down Expand Up @@ -121,7 +133,9 @@ def _annotate(
if annotation == 1 and update:
# Save insight before processing the annotation
insight.save()
annotation_result = self.process_annotation(insight, data=data, auth=auth)
annotation_result = self.process_annotation(
insight, data=data, auth=auth
) # calls the process_annotation function of the class corresponding to the current insight type
else:
annotation_result = SAVED_ANNOTATION_RESULT

Expand Down

0 comments on commit 18e5c66

Please sign in to comment.