CI skip for tests when Cartopy data not accessible

Abierto
#163 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
66/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Start with tests/integration/test_advanced_plot_examples.py, especially test_canari_1, and inspect the plotting tests that request Cartopy Natural Earth data. Check how those tests behave when the data fetch fails, then add skips only to the susceptible tests. Done means CI no longer fails solely because Cartopy resources are unreachable, while the affected tests still run when the data is available.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

CI infrastructure testing

Some tests have been observed to fail on Actions not due to a cf-plot issue but due to inability to fetch Cartopy resources such as the Natural Earth shapefile data to draw the land and ocean shapes notably coastlines etc.
(locally this is cached when obtained at any point so rarely needs to be pulled down but on the CI jobs it needs to be fetched each time).

We should add appropriate skips onto tests which can fail in this way. This will mainly involve investigating which tests are susceptible to this.

Example

As seen on Mac 3.13 job for #161 at commit 9540c18. Only this one test failed somehow which possibly implies the data is being fetched for each plotting call which is a separate (bad for performance) issue in itself (TBC).

=================================== FAILURES ===================================
________________________________ test_canari_1 _________________________________

self = <urllib.request.HTTPSHandler object at 0x14c2fcad0>
http_class = <class 'http.client.HTTPSConnection'>
req = <urllib.request.Request object at 0x14f43fd90>
http_conn_args = {'context': <ssl.SSLContext object at 0x14c2f82d0>}

    def do_open(self, http_class, req, **http_conn_args):
        """Return an HTTPResponse object for the request, using http_class.
    
        http_class must implement the HTTPConnection API from http.client.
        """
        host = req.host
        if not host:
            raise URLError('no host given')
    
        # will parse host:port
        h = http_class(host, timeout=req.timeout, **http_conn_args)
        h.set_debuglevel(self._debuglevel)
    
        headers = dict(req.unredirected_hdrs)
        headers.update(req.headers)
    
        # TODO(jhylton): Should this be redesigned to handle
        # persistent connections?
    
        # We want to make an HTTP/1.1 request, but the addinfourl
        # class isn't prepared to deal with a persistent connection.
        # It will try to read all remaining data from the socket,
        # which will block while the server waits for the next request.
        # So make sure the connection gets closed after the (only)
        # request.
        headers["Connection"] = "close"
        headers = {name.title(): val for name, val in headers.items()}
    
        if req._tunnel_host:
            tunnel_headers = {}
            proxy_auth_hdr = "Proxy-Authorization"
            if proxy_auth_hdr in headers:
                tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
                # Proxy-Authorization should not be sent to origin
                # server.
                del headers[proxy_auth_hdr]
            h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
    
        try:
            try:
>               h.request(req.get_method(), req.selector, req.data, headers,
                          encode_chunked=req.has_header('Transfer-encoding'))

../../../../miniconda3/envs/cf-latest/lib/python3.13/urllib/request.py:1331: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../../miniconda3/envs/cf-latest/lib/python3.13/http/client.py:1386: in request
    self._send_request(method, url, body, headers, encode_chunked)
../../../../miniconda3/envs/cf-latest/lib/python3.13/http/client.py:1432: in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
../../../../miniconda3/envs/cf-latest/lib/python3.13/http/client.py:1381: in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
../../../../miniconda3/envs/cf-latest/lib/python3.13/http/client.py:1141: in _send_output
    self.send(msg)
../../../../miniconda3/envs/cf-latest/lib/python3.13/http/client.py:1085: in send
    self.connect()
../../../../miniconda3/envs/cf-latest/lib/python3.13/http/client.py:1520: in connect
    super().connect()
../../../../miniconda3/envs/cf-latest/lib/python3.13/http/client.py:1051: in connect
    self.sock = self._create_connection(
../../../../miniconda3/envs/cf-latest/lib/python3.13/socket.py:844: in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

host = 'naturalearth.s3.amazonaws.com', port = 443, family = 0
type = <SocketKind.SOCK_STREAM: 1>, proto = 0, flags = 0

    def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):
        """Resolve host and port into list of address info entries.
    
        Translate the host/port argument into a sequence of 5-tuples that contain
        all the necessary arguments for creating a socket connected to that service.
        host is a domain name, a string representation of an IPv4/v6 address or
        None. port is a string service name such as 'http', a numeric port number or
        None. By passing None as the value of host and port, you can pass NULL to
        the underlying C API.
    
        The family, type and proto arguments can be optionally specified in order to
        narrow the list of addresses returned. Passing zero as a value for each of
        these arguments selects the full range of results.
        """
        # We override this function since we want to translate the numeric family
        # and socket type values to enum constants.
        addrlist = []
>       for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       socket.gaierror: [Errno 8] nodename nor servname provided, or not known

../../../../miniconda3/envs/cf-latest/lib/python3.13/socket.py:983: gaierror

During handling of the above exception, another exception occurred:

    @pytest.mark.integration
    def test_canari_1():
        """Regression test for CANARI rotated-grid plotting case."""
        if not CANARI_DATA_FILE.exists():
            pytest.skip(f"Missing integration dataset: {CANARI_DATA_FILE}")
    
        _configure_example_output("canari_1")
        flds = cf.read(str(CANARI_DATA_FILE))
        f = flds[0]
        field = f[0, 3, :, :]
        cfp.mapset(proj="rotated")
>       cfp.con(field, lines=False)

tests/integration/test_advanced_plot_examples.py:321: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
cfplot/contour.py:2680: in con
    if _render_with_new_xy(f=f, x=x, y=y, kwargs=kwargs):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cfplot/contour.py:1953: in _render_with_new_xy
    rendered = _render_ptype6_rotated_pole(
cfplot/rotated_runtime.py:485: in _render_ptype6_rotated_pole
    _render_rotated_grid_axes(
cfplot/rotated_runtime.py:139: in _render_rotated_grid_axes
    shpfilename = shpreader.natural_earth(
../../../../miniconda3/envs/cf-latest/lib/python3.13/site-packages/cartopy/io/shapereader.py:319: in natural_earth
    return ne_downloader.path(format_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../miniconda3/envs/cf-latest/lib/python3.13/site-packages/cartopy/io/__init__.py:226: in path
    result_path = self.acquire_resource(target_path, format_dict)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../miniconda3/envs/cf-latest/lib/python3.13/site-packages/cartopy/io/shapereader.py:372: in acquire_resource
    shapefile_online = self._urlopen(url)
                       ^^^^^^^^^^^^^^^^^^
../../../../miniconda3/envs/cf-latest/lib/python3.13/site-packages/cartopy/io/__init__.py:264: in _urlopen
    return urlopen(url)
           ^^^^^^^^^^^^
../../../../miniconda3/envs/cf-latest/lib/python3.13/urllib/request.py:189: in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../miniconda3/envs/cf-latest/lib/python3.13/urllib/request.py:489: in open
    response = self._open(req, data)
               ^^^^^^^^^^^^^^^^^^^^^
../../../../miniconda3/envs/cf-latest/lib/python3.13/urllib/request.py:506: in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
../../../../miniconda3/envs/cf-latest/lib/python3.13/urllib/request.py:466: in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
../../../../miniconda3/envs/cf-latest/lib/python3.13/urllib/request.py:1379: in https_open
    return self.do_open(http.client.HTTPSConnection, req,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <urllib.request.HTTPSHandler object at 0x14c2fcad0>
http_class = <class 'http.client.HTTPSConnection'>
req = <urllib.request.Request object at 0x14f43fd90>
http_conn_args = {'context': <ssl.SSLContext object at 0x14c2f82d0>}

    def do_open(self, http_class, req, **http_conn_args):
        """Return an HTTPResponse object for the request, using http_class.
    
        http_class must implement the HTTPConnection API from http.client.
        """
        host = req.host
        if not host:
            raise URLError('no host given')
    
        # will parse host:port
        h = http_class(host, timeout=req.timeout, **http_conn_args)
        h.set_debuglevel(self._debuglevel)
    
        headers = dict(req.unredirected_hdrs)
        headers.update(req.headers)
    
        # TODO(jhylton): Should this be redesigned to handle
        # persistent connections?
    
        # We want to make an HTTP/1.1 request, but the addinfourl
        # class isn't prepared to deal with a persistent connection.
        # It will try to read all remaining data from the socket,
        # which will block while the server waits for the next request.
        # So make sure the connection gets closed after the (only)
        # request.
        headers["Connection"] = "close"
        headers = {name.title(): val for name, val in headers.items()}
    
        if req._tunnel_host:
            tunnel_headers = {}
            proxy_auth_hdr = "Proxy-Authorization"
            if proxy_auth_hdr in headers:
                tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
                # Proxy-Authorization should not be sent to origin
                # server.
                del headers[proxy_auth_hdr]
            h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
    
        try:
            try:
                h.request(req.get_method(), req.selector, req.data, headers,
                          encode_chunked=req.has_header('Transfer-encoding'))
            except OSError as err: # timeout error
>               raise URLError(err)
E               urllib.error.URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>

../../../../miniconda3/envs/cf-latest/lib/python3.13/urllib/request.py:1334: URLError
Lenguaje dominante
Python
Estrellas
21
Forks
11
Merge medio
2 h 59 min
PR fusionados (30 d)
11

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NCAS-CMS/cf-plot

Todos los issues de NCAS-CMS/cf-plot

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.