pmaxted / pycheops

Python module for the analysis of light curves from the ESA Cheops mission
http://cheops.unibe.ch/
GNU General Public License v3.0
21 stars 15 forks source link

dace query problem #305

Closed pmaxted closed 1 year ago

pmaxted commented 1 year ago

From Vikash ...

---------------------------------------------------------------------------
SSLCertVerificationError                  Traceback (most recent call last)
File ~/anaconda3/lib/python3.11/site-packages/urllib3/connectionpool.py:714, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    713 # Make the request on the httplib connection object.
--> 714 httplib_response = self._make_request(
    715     conn,
    716     method,
    717     url,
    718     timeout=timeout_obj,
    719     body=body,
    720     headers=headers,
    721     chunked=chunked,
    722 )
    724 # If we're going to release the connection in ``finally:``, then
    725 # the response doesn't need to know about the connection. Otherwise
    726 # it will also try to release it and we'll have a double-release
    727 # mess.

File ~/anaconda3/lib/python3.11/site-packages/urllib3/connectionpool.py:403, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    402 try:
--> 403     self._validate_conn(conn)
    404 except (SocketTimeout, BaseSSLError) as e:
    405     # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.

File ~/anaconda3/lib/python3.11/site-packages/urllib3/connectionpool.py:1053, in HTTPSConnectionPool._validate_conn(self, conn)
   1052 if not getattr(conn, "sock", None):  # AppEngine might not have  `.sock`
-> 1053     conn.connect()
   1055 if not conn.is_verified:

File ~/anaconda3/lib/python3.11/site-packages/urllib3/connection.py:419, in HTTPSConnection.connect(self)
    417     context.load_default_certs()
--> 419 self.sock = ssl_wrap_socket(
    420     sock=conn,
    421     keyfile=self.key_file,
    422     certfile=self.cert_file,
    423     key_password=self.key_password,
    424     ca_certs=self.ca_certs,
    425     ca_cert_dir=self.ca_cert_dir,
    426     ca_cert_data=self.ca_cert_data,
    427     server_hostname=server_hostname,
    428     ssl_context=context,
    429     tls_in_tls=tls_in_tls,
    430 )
    432 # If we're using all defaults and the connection
    433 # is TLSv1 or TLSv1.1 we throw a DeprecationWarning
    434 # for the host.

File ~/anaconda3/lib/python3.11/site-packages/urllib3/util/ssl_.py:449, 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)
    448 if send_sni:
--> 449     ssl_sock = _ssl_wrap_socket_impl(
    450         sock, context, tls_in_tls, server_hostname=server_hostname
    451     )
    452 else:

File ~/anaconda3/lib/python3.11/site-packages/urllib3/util/ssl_.py:493, 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:

File ~/anaconda3/lib/python3.11/ssl.py:517, in SSLContext.wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    511 def wrap_socket(self, sock, server_side=False,
    512                 do_handshake_on_connect=True,
    513                 suppress_ragged_eofs=True,
    514                 server_hostname=None, session=None):
    515     # SSLSocket class handles server_hostname encoding before it calls
    516     # ctx._wrap_socket()
--> 517     return self.sslsocket_class._create(
    518         sock=sock,
    519         server_side=server_side,
    520         do_handshake_on_connect=do_handshake_on_connect,
    521         suppress_ragged_eofs=suppress_ragged_eofs,
    522         server_hostname=server_hostname,
    523         context=self,
    524         session=session
    525     )

File ~/anaconda3/lib/python3.11/ssl.py:1075, in SSLSocket._create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
   1074             raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1075         self.do_handshake()
   1076 except (OSError, ValueError):

File ~/anaconda3/lib/python3.11/ssl.py:1346, in SSLSocket.do_handshake(self, block)
   1345         self.settimeout(None)
-> 1346     self._sslobj.do_handshake()
   1347 finally:

SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1002)

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
File ~/anaconda3/lib/python3.11/site-packages/requests/adapters.py:486, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
    485 try:
--> 486     resp = conn.urlopen(
    487         method=request.method,
    488         url=url,
    489         body=request.body,
    490         headers=request.headers,
    491         redirect=False,
    492         assert_same_host=False,
    493         preload_content=False,
    494         decode_content=False,
    495         retries=self.max_retries,
    496         timeout=timeout,
    497         chunked=chunked,
    498     )
    500 except (ProtocolError, OSError) as err:

File ~/anaconda3/lib/python3.11/site-packages/urllib3/connectionpool.py:798, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    796     e = ProtocolError("Connection aborted.", e)
--> 798 retries = retries.increment(
    799     method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
    800 )
    801 retries.sleep()

File ~/anaconda3/lib/python3.11/site-packages/urllib3/util/retry.py:592, in Retry.increment(self, method, url, response, error, _pool, _stacktrace)
    591 if new_retry.is_exhausted():
--> 592     raise MaxRetryError(_pool, url, error or ResponseError(cause))
    594 log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)

MaxRetryError: HTTPSConnectionPool(host='[dace-api.unige.ch](http://dace-api.unige.ch/)', port=443): Max retries exceeded with url: /ObsAPI/cheops/search?limit=10000&filters=%7B%22obj_id_catname%22%3A+%7B%22contains%22%3A+%22KELT-20%22%7D%7D&sort=%7B%7D (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1002)')))

During handling of the above exception, another exception occurred:

SSLError                                  Traceback (most recent call last)
File ~/anaconda3/lib/python3.11/site-packages/dace/dace.py:181, in DaceClass.get(self, endpoint, raw_response)
    180 try:
--> 181     response = requests.get(host, headers=headers)
    182     response.raise_for_status()

File ~/anaconda3/lib/python3.11/site-packages/requests/api.py:73, in get(url, params, **kwargs)
     63 r"""Sends a GET request.
     64 
     65 :param url: URL for the new :class:`Request` object.
   (...)
     70 :rtype: requests.Response
     71 """
---> 73 return request("get", url, params=params, **kwargs)

File ~/anaconda3/lib/python3.11/site-packages/requests/api.py:59, in request(method, url, **kwargs)
     58 with sessions.Session() as session:
---> 59     return session.request(method=method, url=url, **kwargs)

File ~/anaconda3/lib/python3.11/site-packages/requests/sessions.py:589, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    588 send_kwargs.update(settings)
--> 589 resp = self.send(prep, **send_kwargs)
    591 return resp

File ~/anaconda3/lib/python3.11/site-packages/requests/sessions.py:703, in Session.send(self, request, **kwargs)
    702 # Send the request
--> 703 r = adapter.send(request, **kwargs)
    705 # Total elapsed time of the request (approximately)

File ~/anaconda3/lib/python3.11/site-packages/requests/adapters.py:517, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
    515 if isinstance(e.reason, _SSLError):
    516     # This branch is for urllib3 v1.22 and later.
--> 517     raise SSLError(e, request=request)
    519 raise ConnectionError(e, request=request)

SSLError: HTTPSConnectionPool(host='[dace-api.unige.ch](http://dace-api.unige.ch/)', port=443): Max retries exceeded with url: /ObsAPI/cheops/search?limit=10000&filters=%7B%22obj_id_catname%22%3A+%7B%22contains%22%3A+%22KELT-20%22%7D%7D&sort=%7B%7D (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1002)')))

The above exception was the direct cause of the following exception:

RequestException                          Traceback (most recent call last)
Cell In[3], line 2
      1 myfilter = {"obj_id_catname" : {"contains" : "KELT-20"}}
----> 2 data = Cheops.query_database(filters = myfilter)

File ~/anaconda3/lib/python3.11/site-packages/dace/cheops/cheops.py:90, in CheopsClass.query_database(self, limit, filters, sort, output_format)
     86 if sort is None:
     87     sort = {}
     89 return self.dace.transform_to_format(
---> 90     self.dace.get(self.dace._OBS_API + 'cheops' + '/search' + '?limit=' + str(
     91         limit) + '&filters=' + self.dace.transform_dict_to_encoded_json(
     92         filters) + '&sort=' + self.dace.transform_dict_to_encoded_json(sort)), output_format=output_format)

File ~/anaconda3/lib/python3.11/site-packages/dace/dace.py:194, in DaceClass.get(self, endpoint, raw_response)
    192     return self.__manage_http_errors(errh)
    193 except RequestException as e:
--> 194     raise RequestException('Problem when calling {}'.format(host)) from e

RequestException: Problem when calling https://dace-api.unige.ch/ObsAPI/cheops/search?limit=10000&filters=%7B%22obj_id_catname%22%3A+%7B%22contains%22%3A+%22KELT-20%22%7D%7D&sort=%7B%7D
pmaxted commented 1 year ago

From dace-support@unige.ch ...

Hello Pierre,

The python-dace-client is a deprecated library which queries our old infrastructure.

We released a new library called "dace-query" which contains the same classes and functions and which connect to our new system:

https://dace-query.readthedocs.io/en/latest/

We sent an e-mail to all DACE users months ago about this, but probably we should send the information again.

IMPORTANT: since the classes and functions are the same, we encourage you to uninstall the python-dace-client to avoid having conflicts between the 2 libs.