OpenFermion
OpenFermion copied to clipboard
Fix #481: add retry logic to pubchem fetching function
The nightly test runs would often fail at least one test that fetched data from a Pubchem network service. The failures happened because sometimes the remote server would respond with an error (probably because it's getting hit with too many requests). The problem was reported years ago in issue #481.
This PR should address this problem. I added a simple retry mechanism to the function geometry_from_pubchem() in the file src/openfermion/chem/pubchem.py. It now catches exceptions and retries the network call up to three times with a delay between each attempt. I also updated the corresponding tests in src/openfermion/chem/pubchem_test.py to mock the network calls and verify the new retry logic.