Molecule Tutorials - Herong's Tutorial Examples - v1.26, by Herong Yang
chembl_webresource_client - RetryError Exception
This section provides a tutorial example to demonstrate a design issue in chembl_webresource_client, where the HTTP Status Code of '404 (Not Found)' is not handled properly.
chembl_webresource_client has a small design issue in its RetryError Exception. If you try to get a data entity with bad ID code, chembl_webresource_client will perform multiple retry requests, even the first request already returns a HTTP Status Code of "404 (Not Found)".
Below is a sample session that shows this problem:
herong$ python3 >>> from chembl_webresource_client.new_client import new_client >>> molecule = new_client.molecule.get('JUNK') Traceback (most recent call last): ... ".../python3.7/site-packages/urllib3/util/retry.py", line 574, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.ebi.ac.uk', port=443): Max retries exceeded with url: /chembl/api/data/molecule/JUNK (Caused by ResponseError('too many 404 error responses')) During handling of the above exception, another exception occurred: Traceback (most recent call last): ... ".../python3.7/site-packages/requests/adapters.py", line 507, in send raise RetryError(e, request=request) requests.exceptions.RetryError: HTTPSConnectionPool(host='www.ebi.ac.uk', port=443): Max retries exceeded with url: /chembl/api/data/molecule/JUNK (Caused by ResponseError('too many 404 error responses'))
If you run a HTTP request directly with the "curl" command, you will see the "HTTP/1.1 404 Not Found" message in the response header.
herong$ curl -D h.txt https://www.ebi.ac.uk/chembl/api/data/molecule/JUNK herong$ more h.txt HTTP/1.1 404 Not Found Server: gunicorn/20.0.4 Vary: Accept, Origin Content-Type: text/html; charset=utf-8 Strict-Transport-Security: max-age=0 Connection: Keep-Alive Content-Length: 0
A better design should stop the retry loop immediately and raise a new exception like "requests.exceptions.NotFoundError".
Table of Contents
Molecule Names and Identifications
Nucleobase, Nucleoside, Nucleotide, DNA and RNA
►ChEMBL Database - European Molecular Biology Laboratory
Call ChEMBL Data Web Service Directly
ChEMBL Data Resource - molecule
ChEMBL Data Resource - activity
ChEMBL Data Resource - document
ChEMBL Data Resource - chembl_id_lookup
chembl_webresource_client - Python Client
chembl_webresource_client - Usage Examples
►chembl_webresource_client - RetryError Exception
PubChem Database - National Library of Medicine
INSDC (International Nucleotide Sequence Database Collaboration)
HGNC (HUGO Gene Nomenclature Committee)