rxn4chemistry / biocatalysis-model

RXN for biochemical reactions
MIT License
61 stars 14 forks source link

ReadMe test code is returning a "Too Many Requests" error #1

Closed tjmoutinhocgn closed 2 years ago

tjmoutinhocgn commented 2 years ago

Hello, I am running into an error when trying to run the example code that you provide in the ReadMe (I am using a brand new api-key from IBM RXN, not included in the code below): from rxn4chemistry import RXN4ChemistryWrapper rxn4chemistry_wrapper = RXN4ChemistryWrapper(api_key=api_key) rxn4chemistry_wrapper.create_project('test_wrapper') print(rxn4chemistry_wrapper.project_id) response = rxn4chemistry_wrapper.predict_automatic_retrosynthesis('OC1C(O)C=C(Br)C=C1', ai_model='enzymatic-2021-04-16') print(response)

I get the error: Unexpected error. {"timestamp":1651515402560,"status":429,"error":"Too Many Requests","message":"Too many requests","path":"/rxn/api/api/v1/retrosynthesis/rs"}

Do you have any recommendations for reducing the number of requests that are sent to the API? It doesn't look like there is a parameter for this function to adjust the request rate. Thanks for any help you can provide.

Best Regard, Tom

drugilsberg commented 2 years ago

Hey @tjmoutinhocgn, thanks for trying our work.

The error you are getting is due to the prediction call just after the project creation one. Put a time.sleep of 1 second between the two calls and it should work fine.

tjmoutinhocgn commented 2 years ago

Thanks!