aiondemand / AIOD-rest-api

Services for the core of AIoD: Authentication and the metadata catalogue with REST API.
https://api.aiod.eu
MIT License
10 stars 7 forks source link

Bugfix/zenodo connector rate limits #272

Closed jsmatias closed 6 months ago

jsmatias commented 6 months ago

Bugfixes:

  1. The connector was unable to fetch all records and process them before the resumption token expiration. (422 error from zenodo). This is related to the issue #267 Solution: I separated fetching all records from processing them, and added a timer to stop fetching before the given expiration.
  2. The previous bug resulted in skipping several records. Solution: I pass the timestamp of the last processed record to the state. This way the next iteration will start from the last record, instead of to_excl_current, which is defined as next cycle (previous from_incl + time_per_loop)
  3. Zenodo connector was exceeding the request rate limits of the Zenodo platform. This is related to the issue #267 Solution: I used decorators on the fetching methods to define the limits and sleep and retry to avoid raising the 429 error.
  4. Many KeyErrors due to missing fields were not properly addressed. This were all passed to the log files making it less readable to debug and quickly overloads the log files. Solution: I used the dictionary .get() method to return a None or default value to be evaluated subsequently.

Changes:

  1. I included a few unit tests to test these bugfixes
  2. Changed the initial date from which the connector starts fetching data 2023 -> 2020