Error while downloading NIST dataset
s-rathi opened this issue · 0 comments
s-rathi commented
Describe the bug
The NISTWeightsComp
and NISTIonizationEnergies
functions are unstable and fail at some executions due to SSLCertVerificationError
. The functions start working again on repeated attempts. The error occurs when the program tries to fetch the data from https://physics.nist.gov/
.
To Reproduce
- Configure the project and launch the python shell.
- Run these commands:
from carsus.io.nist import NISTIonizationEnergies
ionization_energies = NISTIonizationEnergies('H-Zn')
The NISTIonizationEnergies()
function can fail randomly.
System
-
OS:
- GNU/Linux
- macOS
-
Environment (
conda list
): carsus
Additional context
Error logs:
>>> ionization_energies = NISTIonizationEnergies('H-Zn')
[ carsus.io.nist.ionization][ INFO] - Downloading ionization energies from the NIST Atomic Spectra Database. (ionization.py:64)
Traceback (most recent call last):
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/urllib3/connectionpool.py", line 710, in urlopen
chunked=chunked,
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/urllib3/connection.py", line 424, in connect
tls_in_tls=tls_in_tls,
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 450, in ssl_wrap_socket
sock, context, tls_in_tls, server_hostname=server_hostname
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/ssl.py", line 423, in wrap_socket
session=session
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/ssl.py", line 870, in _create
self.do_handshake()
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/requests/adapters.py", line 499, in send
timeout=timeout,
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/urllib3/connectionpool.py", line 788, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='physics.nist.gov', port=443): Max retries exceeded with url: /PhysRefData/ASD/Html/verhist.shtml (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/shikha/Dev/Proj/carsus/carsus/io/nist/ionization.py", line 319, in __init__
self._get_version()
File "/Users/shikha/Dev/Proj/carsus/carsus/io/nist/ionization.py", line 355, in _get_version
html = requests.get(IONIZATION_ENERGIES_VERSION_URL)
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/requests/api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/Users/shikha/miniconda3/envs/carsus/lib/python3.7/site-packages/requests/adapters.py", line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='physics.nist.gov', port=443): Max retries exceeded with url: /PhysRefData/ASD/Html/verhist.shtml (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)')))