Teichlab / celltypist

A tool for semi-automatic cell type classification
https://www.celltypist.org/
MIT License
260 stars 40 forks source link

Error with model download #36

Closed akk01 closed 1 year ago

akk01 commented 1 year ago

📜 Retrieving model list from server https://celltypist.cog.sanger.ac.uk/models/models.json


timeout Traceback (most recent call last) ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 381 try: --> 382 self._validate_conn(conn) 383 except (SocketTimeout, BaseSSLError) as e:

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connectionpool.py in _validate_conn(self, conn) 1009 if not getattr(conn, "sock", None): # AppEngine might not have .sock -> 1010 conn.connect() 1011

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connection.py in connect(self) 420 ssl_context=context, --> 421 tls_in_tls=tls_in_tls, 422 )

~/.conda/envs/single_cellv0.1/lib/python3.7/site-packages/urllib3/util/ssl.py in ssl_wrap_socket(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir, key_password, ca_cert_data, tls_in_tls) 449 ssl_sock = _ssl_wrap_socket_impl( --> 450 sock, context, tls_in_tls, server_hostname=server_hostname 451 )

~/.conda/envs/single_cellv0.1/lib/python3.7/site-packages/urllib3/util/ssl.py in _ssl_wrap_socket_impl(sock, ssl_context, tls_in_tls, server_hostname) 492 if server_hostname: --> 493 return ssl_context.wrap_socket(sock, server_hostname=server_hostname) 494 else:

~/.conda/envs/single_cell_v0.1/lib/python3.7/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session) 422 context=self, --> 423 session=session 424 )

~/.conda/envs/single_cell_v0.1/lib/python3.7/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session) 869 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") --> 870 self.do_handshake() 871 except (OSError, ValueError):

~/.conda/envs/single_cell_v0.1/lib/python3.7/ssl.py in do_handshake(self, block) 1138 self.settimeout(None) -> 1139 self._sslobj.do_handshake() 1140 finally:

timeout: _ssl.c:1074: The handshake operation timed out

During handling of the above exception, another exception occurred:

ReadTimeoutError Traceback (most recent call last) ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies) 448 retries=self.max_retries, --> 449 timeout=timeout 450 )

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw) 755 retries = retries.increment( --> 756 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] 757 )

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace) 531 if read is False or not self._is_method_retryable(method): --> 532 raise six.reraise(type(error), error, _stacktrace) 533 elif read is not None:

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/packages/six.py in reraise(tp, value, tb) 769 raise value.with_traceback(tb) --> 770 raise value 771 finally:

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw) 705 headers=headers, --> 706 chunked=chunked, 707 )

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 384 # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout. --> 385 self._raise_timeout(err=e, url=url, timeout_value=conn.timeout) 386 raise

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connectionpool.py in _raise_timeout(self, err, url, timeout_value) 336 raise ReadTimeoutError( --> 337 self, url, "Read timed out. (read timeout=%s)" % timeout_value 338 )

ReadTimeoutError: HTTPSConnectionPool(host='celltypist.cog.sanger.ac.uk', port=443): Read timed out. (read timeout=30)

During handling of the above exception, another exception occurred:

ReadTimeout Traceback (most recent call last) ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/celltypist/models.py in _requests_get(url, timeout) 36 try: ---> 37 r = requests.get(url, timeout = timeout) 38 r.raise_for_status()

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/requests/api.py in get(url, params, kwargs) 74 ---> 75 return request('get', url, params=params, kwargs) 76

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/requests/api.py in request(method, url, kwargs) 60 with sessions.Session() as session: ---> 61 return session.request(method=method, url=url, kwargs) 62

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json) 541 send_kwargs.update(settings) --> 542 resp = self.send(prep, **send_kwargs) 543

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/requests/sessions.py in send(self, request, kwargs) 654 # Send the request --> 655 r = adapter.send(request, kwargs) 656

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies) 528 elif isinstance(e, ReadTimeoutError): --> 529 raise ReadTimeout(e, request=request) 530 else:

ReadTimeout: HTTPSConnectionPool(host='celltypist.cog.sanger.ac.uk', port=443): Read timed out. (read timeout=30)

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last)

in 1 # Enabling `force_update = True` will overwrite existing (old) models. ----> 2 models.download_models(force_update = True) ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/celltypist/models.py in download_models(force_update, model) 424 To check all available models, use :func:`~celltypist.models.models_description`. 425 """ --> 426 models_json = get_models_index(force_update) 427 logger.info(f"📂 Storing models in {models_path}") 428 if model is not None: ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/celltypist/models.py in get_models_index(force_update) 384 models_json_path = get_model_path("models.json") 385 if not os.path.exists(models_json_path) or force_update: --> 386 download_model_index() 387 with open(models_json_path) as f: 388 return json.load(f) ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/celltypist/models.py in download_model_index(only_model) 402 logger.info(f"📜 Retrieving model list from server {url}") 403 with open(get_model_path("models.json"), "wb") as f: --> 404 f.write(_requests_get(url).content) 405 model_count = len(_requests_get(url).json()["models"]) 406 logger.info(f"📚 Total models in list: {model_count}") ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/celltypist/models.py in _requests_get(url, timeout) 39 except requests.exceptions.RequestException as e: 40 raise Exception( ---> 41 f"🛑 Cannot fetch '{url}', the error is: {e}") 42 return r 43 Exception: 🛑 Cannot fetch 'https://celltypist.cog.sanger.ac.uk/models/models.json', the error is: HTTPSConnectionPool(host='celltypist.cog.sanger.ac.uk', port=443): Read timed out. (read timeout=30)
prete commented 1 year ago

Hi @akk01 thank you for using CellTypist!

Are you still seeing that error? It may have been a transient network error and if you try again it may work.

Can you confirm if you can reach https://celltypist.cog.sanger.ac.uk/models/models.json ? If not, then that means there's something preventing you from reaching that URL. Possibly a firewall configuration or a proxy setup on your machine? If you're working from an HPC you mat need to set HTTPS_PROXY values to pull data from the internet but you'll have to ask that to your IT team.

Let us know otherwise and we'll have a second look at this.

akk01 commented 1 year ago

Hi, I am still getting the same error. Yes, I am able to access json page https://celltypist.cog.sanger.ac.uk/models/models.json. Thanks for suggesting HTTPS_PROXY, which I will reach out to HPC admin.

prete commented 1 year ago

Hi @akk01, just wanted to check if you got a response from your admin team regarding this?

akk01 commented 1 year ago

I tried it today and first few download were progressing but it failed afterward with this message: els.download_models(force_update = True)

📜 Retrieving model list from server https://celltypist.cog.sanger.ac.uk/models/models.json


timeout Traceback (most recent call last) ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 381 try: --> 382 self._validate_conn(conn) 383 except (SocketTimeout, BaseSSLError) as e:

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connectionpool.py in _validate_conn(self, conn) 1009 if not getattr(conn, "sock", None): # AppEngine might not have .sock -> 1010 conn.connect() 1011

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connection.py in connect(self) 420 ssl_context=context, --> 421 tls_in_tls=tls_in_tls, 422 )

~/.conda/envs/single_cellv0.1/lib/python3.7/site-packages/urllib3/util/ssl.py in ssl_wrap_socket(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir, key_password, ca_cert_data, tls_in_tls) 449 ssl_sock = _ssl_wrap_socket_impl( --> 450 sock, context, tls_in_tls, server_hostname=server_hostname 451 )

~/.conda/envs/single_cellv0.1/lib/python3.7/site-packages/urllib3/util/ssl.py in _ssl_wrap_socket_impl(sock, ssl_context, tls_in_tls, server_hostname) 492 if server_hostname: --> 493 return ssl_context.wrap_socket(sock, server_hostname=server_hostname) 494 else:

~/.conda/envs/single_cell_v0.1/lib/python3.7/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session) 422 context=self, --> 423 session=session 424 )

~/.conda/envs/single_cell_v0.1/lib/python3.7/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session) 869 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") --> 870 self.do_handshake() 871 except (OSError, ValueError):

~/.conda/envs/single_cell_v0.1/lib/python3.7/ssl.py in do_handshake(self, block) 1138 self.settimeout(None) -> 1139 self._sslobj.do_handshake() 1140 finally:

timeout: _ssl.c:1074: The handshake operation timed out

During handling of the above exception, another exception occurred:

ReadTimeoutError Traceback (most recent call last) ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies) 448 retries=self.max_retries, --> 449 timeout=timeout 450 )

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw) 755 retries = retries.increment( --> 756 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] 757 )

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace) 531 if read is False or not self._is_method_retryable(method): --> 532 raise six.reraise(type(error), error, _stacktrace) 533 elif read is not None:

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/packages/six.py in reraise(tp, value, tb) 769 raise value.with_traceback(tb) --> 770 raise value 771 finally:

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw) 705 headers=headers, --> 706 chunked=chunked, 707 )

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 384 # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout. --> 385 self._raise_timeout(err=e, url=url, timeout_value=conn.timeout) 386 raise

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/urllib3/connectionpool.py in _raise_timeout(self, err, url, timeout_value) 336 raise ReadTimeoutError( --> 337 self, url, "Read timed out. (read timeout=%s)" % timeout_value 338 )

ReadTimeoutError: HTTPSConnectionPool(host='celltypist.cog.sanger.ac.uk', port=443): Read timed out. (read timeout=30)

During handling of the above exception, another exception occurred:

ReadTimeout Traceback (most recent call last) ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/celltypist/models.py in _requests_get(url, timeout) 36 try: ---> 37 r = requests.get(url, timeout = timeout) 38 r.raise_for_status()

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/requests/api.py in get(url, params, kwargs) 74 ---> 75 return request('get', url, params=params, kwargs) 76

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/requests/api.py in request(method, url, kwargs) 60 with sessions.Session() as session: ---> 61 return session.request(method=method, url=url, kwargs) 62

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json) 541 send_kwargs.update(settings) --> 542 resp = self.send(prep, **send_kwargs) 543

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/requests/sessions.py in send(self, request, kwargs) 654 # Send the request --> 655 r = adapter.send(request, kwargs) 656

~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies) 528 elif isinstance(e, ReadTimeoutError): --> 529 raise ReadTimeout(e, request=request) 530 else:

ReadTimeout: HTTPSConnectionPool(host='celltypist.cog.sanger.ac.uk', port=443): Read timed out. (read timeout=30)

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last)

in 1 # Enabling `force_update = True` will overwrite existing (old) models. ----> 2 models.download_models(force_update = True) ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/celltypist/models.py in download_models(force_update, model) 424 To check all available models, use :func:`~celltypist.models.models_description`. 425 """ --> 426 models_json = get_models_index(force_update) 427 logger.info(f"📂 Storing models in {models_path}") 428 if model is not None: ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/celltypist/models.py in get_models_index(force_update) 384 models_json_path = get_model_path("models.json") 385 if not os.path.exists(models_json_path) or force_update: --> 386 download_model_index() 387 with open(models_json_path) as f: 388 return json.load(f) ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/celltypist/models.py in download_model_index(only_model) 402 logger.info(f"📜 Retrieving model list from server {url}") 403 with open(get_model_path("models.json"), "wb") as f: --> 404 f.write(_requests_get(url).content) 405 model_count = len(_requests_get(url).json()["models"]) 406 logger.info(f"📚 Total models in list: {model_count}") ~/.conda/envs/single_cell_v0.1/lib/python3.7/site-packages/celltypist/models.py in _requests_get(url, timeout) 39 except requests.exceptions.RequestException as e: 40 raise Exception( ---> 41 f"🛑 Cannot fetch '{url}', the error is: {e}") 42 return r 43 Exception: 🛑 Cannot fetch 'https://celltypist.cog.sanger.ac.uk/models/models.json', the error is: HTTPSConnectionPool(host='celltypist.cog.sanger.ac.uk', port=443): Read timed out. (read timeout=30)
ChuanXu1 commented 1 year ago

@akk01, this error means you cannot fetch https://celltypist.cog.sanger.ac.uk/models/models.json within 30 seconds of response. Have you solved it now?

ChuanXu1 commented 1 year ago

I will close this issue, Please reopen it if you still have problem connecting to the models.