Skip to content

Commit

Permalink
fix: remove server_domain in image, product_insight and prediction ta…
Browse files Browse the repository at this point in the history
…bles

See #894
  • Loading branch information
raphael0202 committed Apr 10, 2023
1 parent 4823f2b commit eeb3a5c
Show file tree
Hide file tree
Showing 27 changed files with 89 additions and 430 deletions.
2 changes: 0 additions & 2 deletions doc/explanations/interactions-product-opener.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Product Opener calls `POST /api/v1/webhook/product` whenever a product is update

- `barcode`: the barcode of product
- `action`: either `updated` or `deleted`
- `server_domain`: the server domain (ex: `api.openfoodfacts.org`)

After receiving a `product_update` webhook call, Robotoff does the following [^product_update]:

Expand All @@ -29,7 +28,6 @@ Product Opener calls `POST /api/v1/images/import` whenever an new image is uploa
- `barcode`: the barcode of product
- `image_url`: the URL of the image
- `ocr_url`: the URL of the OCR result (JSON file)
- `server_domain`: the server domain (ex: `api.openfoodfacts.org`)

After receiving a `import_image` webhook call, Robotoff does the following [^image_import]:

Expand Down
7 changes: 2 additions & 5 deletions doc/how-to-guides/test-and-debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,8 @@ Write test cases every time you write a new feature, to test a feature or to und

There are even cases where automated tests are your only chance to test you code. For example: when you write code to post notifications on Slack channel you can only test them by writing a unit test case.

There are instances when Robotoff tries to connect to MongoDB via Open Food Facts server. For local testing we do not yet provide a standarized approach to add a MongoDB Docker in the same network and configure Robotoff to use it.

In such cases you will have to mock the function which calls MongoDB. Feel free to reuse the existing test cases.

To identify parts of the code where Robotoff connects to MongoDB or to Open Food Facts server (the part you should mock), keep an eye for variables like `server_url`, `server_domain` or `settings.OFF_SERVER_DOMAIN`.
There are instances when Robotoff tries to connect to MongoDB via Open Food Facts server. To disable this
feature (this is disabled by default on local environments), set `DISABLE_PRODUCT_CHECK=1` in your `.env`.

# Debugging guide

Expand Down
33 changes: 1 addition & 32 deletions doc/references/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ info:
Robotoff provides a simple API allowing consumers to fetch predictions and annotate them.
All endpoints must be prefixed with `/api/v1`. The full URL is `https://robotoff.openfoodfacts.org/api/v1/{endpoint}`.
Robotoff can interact with all Openfoodfacts products: Openfoodfacts, Openbeautyfacts, etc. and all environments (production, development, pro). The `server_domain` field should be used to specify the product/environment: `api.openfoodfacts.org` for OFF-prod, `api.openfoodfacts.net` for OFF-dev, `api.openbeautyfacts.org` for OBF-prod,...
contact: {}
version: "1.0"
servers:
Expand All @@ -30,7 +28,6 @@ paths:
default: 1
minimum: 1
- $ref: "#/components/parameters/barcode_path"
- $ref: "#/components/parameters/server_domain"
- $ref: "#/components/parameters/lang"
responses:
"200":
Expand All @@ -57,7 +54,6 @@ paths:
parameters:
- $ref: "#/components/parameters/lang"
- $ref: "#/components/parameters/count"
- $ref: "#/components/parameters/server_domain"
- $ref: "#/components/parameters/insight_types"
- $ref: "#/components/parameters/country"
- $ref: "#/components/parameters/brands"
Expand Down Expand Up @@ -110,7 +106,6 @@ paths:
parameters:
- $ref: "#/components/parameters/lang"
- $ref: "#/components/parameters/count"
- $ref: "#/components/parameters/server_domain"
- $ref: "#/components/parameters/insight_types"
- $ref: "#/components/parameters/country"
- $ref: "#/components/parameters/brands"
Expand Down Expand Up @@ -151,7 +146,6 @@ paths:
parameters:
- $ref: "#/components/parameters/lang"
- $ref: "#/components/parameters/count"
- $ref: "#/components/parameters/server_domain"
- $ref: "#/components/parameters/insight_types"
- $ref: "#/components/parameters/country"
- $ref: "#/components/parameters/brands"
Expand Down Expand Up @@ -180,7 +174,6 @@ paths:
type: number
default: 25
minimum: 1
- $ref: "#/components/parameters/server_domain"
- $ref: "#/components/parameters/insight_type"
- $ref: "#/components/parameters/country"
- $ref: "#/components/parameters/page"
Expand Down Expand Up @@ -226,7 +219,6 @@ paths:
- $ref: "#/components/parameters/insight_type"
- $ref: "#/components/parameters/country"
- $ref: "#/components/parameters/value_tag"
- $ref: "#/components/parameters/server_domain"
- $ref: "#/components/parameters/count"
- $ref: "#/components/parameters/predictor"
responses:
Expand Down Expand Up @@ -449,18 +441,10 @@ paths:
type: string
format: uri
description: URL of the OCR JSON file associated with the image
server_domain:
type: string
description: |
The server domain associated with the image/product.
If the server domain does not match with the server configuration,
the import task will be rejected by Robotoff.
example: "api.openfoodfacts.org"
required:
- "barcode"
- "image_url"
- "ocr_url"
- "server_domain"
responses:
"200":
description: ""
Expand All @@ -472,11 +456,8 @@ paths:
status:
type: string
description: |
status of the import operation, either `scheduled` if it was
successfully scheduled or rejected if the `server_domain` did
not match Robotoff configured server domain.
status of the import operation, always `scheduled`
enum:
- "rejected"
- "scheduled"

/images/logos:
Expand Down Expand Up @@ -561,11 +542,6 @@ paths:
schema:
type: boolean
default: false
- name: server_domain
in: query
description: The server domain
schema:
type: string
- name: annotated
description: The annotation status of the logo.
If not provided, both annotated and non-annotated logos are returned
Expand Down Expand Up @@ -891,13 +867,6 @@ components:
type: integer
default: 25
minimum: 1
server_domain:
name: server_domain
in: query
description: The server domain
schema:
type: string
default: api.openfoodfacts.org
insight_types:
name: insight_types
in: query
Expand Down
Loading

0 comments on commit eeb3a5c

Please sign in to comment.