Exploring Xpublish#

import xarray as xr
import xpublish

ds = xr.open_dataset("../datasets/ww3_72_east_coast_2022041112.nc")
ds
<xarray.Dataset>
Dimensions:                  (longitude: 381, latitude: 351, time: 73,
                              forecast_reference_time: 1)
Coordinates:
  * longitude                (longitude) float32 -93.0 -92.9 ... -55.1 -55.0
  * latitude                 (latitude) float32 20.0 20.1 20.2 ... 54.9 55.0
  * time                     (time) datetime64[ns] 2022-04-11T12:00:00 ... 20...
  * forecast_reference_time  (forecast_reference_time) datetime64[ns] 2022-04...
Data variables: (12/21)
    hs                       (forecast_reference_time, time, latitude, longitude) float32 ...
    t02                      (forecast_reference_time, time, latitude, longitude) float32 ...
    t0m1                     (forecast_reference_time, time, latitude, longitude) float32 ...
    t01                      (forecast_reference_time, time, latitude, longitude) float32 ...
    fp                       (forecast_reference_time, time, latitude, longitude) float32 ...
    dir                      (forecast_reference_time, time, latitude, longitude) float32 ...
    ...                       ...
    pdir2                    (forecast_reference_time, time, latitude, longitude) float32 ...
    pws0                     (forecast_reference_time, time, latitude, longitude) float32 ...
    pws1                     (forecast_reference_time, time, latitude, longitude) float32 ...
    pws2                     (forecast_reference_time, time, latitude, longitude) float32 ...
    tws                      (forecast_reference_time, time, latitude, longitude) float32 ...
    pnr                      (forecast_reference_time, time, latitude, longitude) float32 ...
Attributes: (12/16)
    WAVEWATCH_III_version_number:     5.16
    WAVEWATCH_III_switches:           F90 SHRD NOGRB NOPA LRB4 NC4 TRKNC PR3 ...
    SIN4 namelist parameter BETAMAX:  1.65
    product_name:                     ww3.20220411.nc
    area:                             NW Atlantic  6 arc min grd2
    latitude_resolution:              0.1000000
    ...                               ...
    easternmost_longitude:            -55.00000
    minimum_altitude:                 -12000 m
    maximum_altitude:                 9000 m
    altitude_resolution:              n/a
    start_date:                       2022-04-11 12:00:00
    stop_date:                        2022-04-11 23:00:00
ds.rest.serve()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 ds.rest.serve()

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/xpublish/rest.py:255, in RestAccessor.serve(self, **kwargs)
    242 def serve(self, **kwargs):
    243     """Serve this FastAPI application via :func:`uvicorn.run`.
    244 
    245     Parameters
   (...)
    253 
    254     """
--> 255     self._get_rest_obj().serve(**kwargs)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/xpublish/rest.py:186, in Rest.serve(self, host, port, log_level, **kwargs)
    166 def serve(self, host='0.0.0.0', port=9000, log_level='debug', **kwargs):
    167     """Serve this FastAPI application via :func:`uvicorn.run`.
    168 
    169     Parameters
   (...)
    184 
    185     """
--> 186     uvicorn.run(self.app, host=host, port=port, log_level=log_level, **kwargs)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/uvicorn/main.py:463, in run(app, **kwargs)
    461     Multiprocess(config, target=server.run, sockets=[sock]).run()
    462 else:
--> 463     server.run()
    464 if config.uds:
    465     os.remove(config.uds)  # pragma: py-win32

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/uvicorn/server.py:60, in Server.run(self, sockets)
     58 def run(self, sockets: Optional[List[socket.socket]] = None) -> None:
     59     self.config.setup_event_loop()
---> 60     return asyncio.run(self.serve(sockets=sockets))

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/runners.py:33, in run(main, debug)
      9 """Execute the coroutine and return the result.
     10 
     11 This function runs the passed coroutine, taking care of
   (...)
     30     asyncio.run(main())
     31 """
     32 if events._get_running_loop() is not None:
---> 33     raise RuntimeError(
     34         "asyncio.run() cannot be called from a running event loop")
     36 if not coroutines.iscoroutine(main):
     37     raise ValueError("a coroutine was expected, got {!r}".format(main))

RuntimeError: asyncio.run() cannot be called from a running event loop

Can’t embed it into the notebook. Creating test_xpublish.py to play with.

Found that the default port 9000 conflicted with something else, so chang

import requests
r = requests.get("http://0.0.0.0:9000/")
r
---------------------------------------------------------------------------
ConnectionRefusedError                    Traceback (most recent call last)
File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/urllib3/connection.py:174, in HTTPConnection._new_conn(self)
    173 try:
--> 174     conn = connection.create_connection(
    175         (self._dns_host, self.port), self.timeout, **extra_kw
    176     )
    178 except SocketTimeout:

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/urllib3/util/connection.py:95, in create_connection(address, timeout, source_address, socket_options)
     94 if err is not None:
---> 95     raise err
     97 raise socket.error("getaddrinfo returns an empty list")

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/urllib3/util/connection.py:85, in create_connection(address, timeout, source_address, socket_options)
     84     sock.bind(source_address)
---> 85 sock.connect(sa)
     86 return sock

ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

NewConnectionError                        Traceback (most recent call last)
File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/urllib3/connectionpool.py:703, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    702 # Make the request on the httplib connection object.
--> 703 httplib_response = self._make_request(
    704     conn,
    705     method,
    706     url,
    707     timeout=timeout_obj,
    708     body=body,
    709     headers=headers,
    710     chunked=chunked,
    711 )
    713 # If we're going to release the connection in ``finally:``, then
    714 # the response doesn't need to know about the connection. Otherwise
    715 # it will also try to release it and we'll have a double-release
    716 # mess.

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/urllib3/connectionpool.py:398, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    397     else:
--> 398         conn.request(method, url, **httplib_request_kw)
    400 # We are swallowing BrokenPipeError (errno.EPIPE) since the server is
    401 # legitimately able to close the connection after sending a valid response.
    402 # With this behaviour, the received response is still readable.

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/urllib3/connection.py:239, in HTTPConnection.request(self, method, url, body, headers)
    238     headers["User-Agent"] = _get_default_user_agent()
--> 239 super(HTTPConnection, self).request(method, url, body=body, headers=headers)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/http/client.py:1282, in HTTPConnection.request(self, method, url, body, headers, encode_chunked)
   1281 """Send a complete request to the server."""
-> 1282 self._send_request(method, url, body, headers, encode_chunked)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/http/client.py:1328, in HTTPConnection._send_request(self, method, url, body, headers, encode_chunked)
   1327     body = _encode(body, 'body')
-> 1328 self.endheaders(body, encode_chunked=encode_chunked)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/http/client.py:1277, in HTTPConnection.endheaders(self, message_body, encode_chunked)
   1276     raise CannotSendHeader()
-> 1277 self._send_output(message_body, encode_chunked=encode_chunked)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/http/client.py:1037, in HTTPConnection._send_output(self, message_body, encode_chunked)
   1036 del self._buffer[:]
-> 1037 self.send(msg)
   1039 if message_body is not None:
   1040 
   1041     # create a consistent interface to message_body

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/http/client.py:975, in HTTPConnection.send(self, data)
    974 if self.auto_open:
--> 975     self.connect()
    976 else:

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/urllib3/connection.py:205, in HTTPConnection.connect(self)
    204 def connect(self):
--> 205     conn = self._new_conn()
    206     self._prepare_conn(conn)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/urllib3/connection.py:186, in HTTPConnection._new_conn(self)
    185 except SocketError as e:
--> 186     raise NewConnectionError(
    187         self, "Failed to establish a new connection: %s" % e
    188     )
    190 return conn

NewConnectionError: <urllib3.connection.HTTPConnection object at 0x18aaf8ee0>: Failed to establish a new connection: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/requests/adapters.py:440, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
    439 if not chunked:
--> 440     resp = conn.urlopen(
    441         method=request.method,
    442         url=url,
    443         body=request.body,
    444         headers=request.headers,
    445         redirect=False,
    446         assert_same_host=False,
    447         preload_content=False,
    448         decode_content=False,
    449         retries=self.max_retries,
    450         timeout=timeout
    451     )
    453 # Send the request.
    454 else:

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/urllib3/connectionpool.py:785, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    783     e = ProtocolError("Connection aborted.", e)
--> 785 retries = retries.increment(
    786     method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
    787 )
    788 retries.sleep()

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/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: HTTPConnectionPool(host='0.0.0.0', port=9000): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x18aaf8ee0>: Failed to establish a new connection: [Errno 61] Connection refused'))

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
Input In [9], in <cell line: 1>()
----> 1 r = requests.get("http://0.0.0.0:9000/")
      2 r

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/requests/api.py:75, in get(url, params, **kwargs)
     64 def get(url, params=None, **kwargs):
     65     r"""Sends a GET request.
     66 
     67     :param url: URL for the new :class:`Request` object.
   (...)
     72     :rtype: requests.Response
     73     """
---> 75     return request('get', url, params=params, **kwargs)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/requests/api.py:61, in request(method, url, **kwargs)
     57 # By using the 'with' statement we are sure the session is closed, thus we
     58 # avoid leaving sockets open which can trigger a ResourceWarning in some
     59 # cases, and look like a memory leak in others.
     60 with sessions.Session() as session:
---> 61     return session.request(method=method, url=url, **kwargs)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/requests/sessions.py:529, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    524 send_kwargs = {
    525     'timeout': timeout,
    526     'allow_redirects': allow_redirects,
    527 }
    528 send_kwargs.update(settings)
--> 529 resp = self.send(prep, **send_kwargs)
    531 return resp

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/requests/sessions.py:645, in Session.send(self, request, **kwargs)
    642 start = preferred_clock()
    644 # Send the request
--> 645 r = adapter.send(request, **kwargs)
    647 # Total elapsed time of the request (approximately)
    648 elapsed = preferred_clock() - start

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/requests/adapters.py:519, 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)
    521 except ClosedPoolError as e:
    522     raise ConnectionError(e, request=request)

ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=9000): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x18aaf8ee0>: Failed to establish a new connection: [Errno 61] Connection refused'))
from fsspec.implementations.http import HTTPFileSystem
fs = HTTPFileSystem()
http_map = fs.get_mapper("http://0.0.0.0:9005")
http_map
<fsspec.mapping.FSMap at 0x1850ace20>
for key in [".metadata", "keys"]:
    print(key, http_map[key])
---------------------------------------------------------------------------
ConnectionRefusedError                    Traceback (most recent call last)
File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/connector.py:986, in TCPConnector._wrap_create_connection(self, req, timeout, client_error, *args, **kwargs)
    985     async with ceil_timeout(timeout.sock_connect):
--> 986         return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
    987 except cert_errors as exc:

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/base_events.py:1064, in BaseEventLoop.create_connection(self, protocol_factory, host, port, ssl, family, proto, flags, sock, local_addr, server_hostname, ssl_handshake_timeout, happy_eyeballs_delay, interleave)
   1063 if len(exceptions) == 1:
-> 1064     raise exceptions[0]
   1065 else:
   1066     # If they all have the same str(), raise one.

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/base_events.py:1049, in BaseEventLoop.create_connection(self, protocol_factory, host, port, ssl, family, proto, flags, sock, local_addr, server_hostname, ssl_handshake_timeout, happy_eyeballs_delay, interleave)
   1048 try:
-> 1049     sock = await self._connect_sock(
   1050         exceptions, addrinfo, laddr_infos)
   1051     break

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/base_events.py:960, in BaseEventLoop._connect_sock(self, exceptions, addr_info, local_addr_infos)
    959         raise my_exceptions.pop()
--> 960 await self.sock_connect(sock, address)
    961 return sock

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/selector_events.py:499, in BaseSelectorEventLoop.sock_connect(self, sock, address)
    498 self._sock_connect(fut, sock, address)
--> 499 return await fut

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/selector_events.py:534, in BaseSelectorEventLoop._sock_connect_cb(self, fut, sock, address)
    532     if err != 0:
    533         # Jump to any except clause below.
--> 534         raise OSError(err, f'Connect call failed {address}')
    535 except (BlockingIOError, InterruptedError):
    536     # socket is still registered, the callback will be retried later

ConnectionRefusedError: [Errno 61] Connect call failed ('0.0.0.0', 9005)

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

ClientConnectorError                      Traceback (most recent call last)
Input In [7], in <cell line: 1>()
      1 for key in [".metadata", "keys"]:
----> 2     print(key, http_map[key])

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/fsspec/mapping.py:135, in FSMap.__getitem__(self, key, default)
    133 k = self._key_to_str(key)
    134 try:
--> 135     result = self.fs.cat(k)
    136 except self.missing_exceptions:
    137     if default is not None:

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/fsspec/asyn.py:85, in sync_wrapper.<locals>.wrapper(*args, **kwargs)
     82 @functools.wraps(func)
     83 def wrapper(*args, **kwargs):
     84     self = obj or args[0]
---> 85     return sync(self.loop, func, *args, **kwargs)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/fsspec/asyn.py:65, in sync(loop, func, timeout, *args, **kwargs)
     63     raise FSTimeoutError from return_result
     64 elif isinstance(return_result, BaseException):
---> 65     raise return_result
     66 else:
     67     return return_result

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/fsspec/asyn.py:25, in _runner(event, coro, result, timeout)
     23     coro = asyncio.wait_for(coro, timeout=timeout)
     24 try:
---> 25     result[0] = await coro
     26 except Exception as ex:
     27     result[0] = ex

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/fsspec/asyn.py:397, in AsyncFileSystem._cat(self, path, recursive, on_error, batch_size, **kwargs)
    395     ex = next(filter(is_exception, out), False)
    396     if ex:
--> 397         raise ex
    398 if (
    399     len(paths) > 1
    400     or isinstance(path, list)
    401     or paths[0] != self._strip_protocol(path)
    402 ):
    403     return {
    404         k: v
    405         for k, v in zip(paths, out)
    406         if on_error != "omit" or not is_exception(v)
    407     }

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/tasks.py:408, in wait_for(fut, timeout)
    405 loop = events.get_running_loop()
    407 if timeout is None:
--> 408     return await fut
    410 if timeout <= 0:
    411     fut = ensure_future(fut, loop=loop)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/fsspec/implementations/http.py:224, in HTTPFileSystem._cat_file(self, url, start, end, **kwargs)
    222     kw["headers"] = headers
    223 session = await self.set_session()
--> 224 async with session.get(url, **kw) as r:
    225     out = await r.read()
    226     self._raise_not_found_for_status(r, url)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/client.py:1138, in _BaseRequestContextManager.__aenter__(self)
   1137 async def __aenter__(self) -> _RetType:
-> 1138     self._resp = await self._coro
   1139     return self._resp

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/client.py:535, in ClientSession._request(self, method, str_or_url, params, data, json, cookies, headers, skip_auto_headers, auth, allow_redirects, max_redirects, compress, chunked, expect100, raise_for_status, read_until_eof, proxy, proxy_auth, timeout, verify_ssl, fingerprint, ssl_context, ssl, proxy_headers, trace_request_ctx, read_bufsize)
    533     async with ceil_timeout(real_timeout.connect):
    534         assert self._connector is not None
--> 535         conn = await self._connector.connect(
    536             req, traces=traces, timeout=real_timeout
    537         )
    538 except asyncio.TimeoutError as exc:
    539     raise ServerTimeoutError(
    540         "Connection timeout " "to host {}".format(url)
    541     ) from exc

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/connector.py:542, in BaseConnector.connect(self, req, traces, timeout)
    539         await trace.send_connection_create_start()
    541 try:
--> 542     proto = await self._create_connection(req, traces, timeout)
    543     if self._closed:
    544         proto.close()

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/connector.py:907, in TCPConnector._create_connection(self, req, traces, timeout)
    905     _, proto = await self._create_proxy_connection(req, traces, timeout)
    906 else:
--> 907     _, proto = await self._create_direct_connection(req, traces, timeout)
    909 return proto

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/connector.py:1206, in TCPConnector._create_direct_connection(self, req, traces, timeout, client_error)
   1204 else:
   1205     assert last_exc is not None
-> 1206     raise last_exc

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/connector.py:1175, in TCPConnector._create_direct_connection(self, req, traces, timeout, client_error)
   1172 port = hinfo["port"]
   1174 try:
-> 1175     transp, proto = await self._wrap_create_connection(
   1176         self._factory,
   1177         host,
   1178         port,
   1179         timeout=timeout,
   1180         ssl=sslcontext,
   1181         family=hinfo["family"],
   1182         proto=hinfo["proto"],
   1183         flags=hinfo["flags"],
   1184         server_hostname=hinfo["hostname"] if sslcontext else None,
   1185         local_addr=self._local_addr,
   1186         req=req,
   1187         client_error=client_error,
   1188     )
   1189 except ClientConnectorError as exc:
   1190     last_exc = exc

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/connector.py:992, in TCPConnector._wrap_create_connection(self, req, timeout, client_error, *args, **kwargs)
    990     raise ClientConnectorSSLError(req.connection_key, exc) from exc
    991 except OSError as exc:
--> 992     raise client_error(req.connection_key, exc) from exc

ClientConnectorError: Cannot connect to host 0.0.0.0:9005 ssl:default [Connect call failed ('0.0.0.0', 9005)]
ds_published = xr.open_zarr(http_map, consolidated=True)
ds_published
---------------------------------------------------------------------------
ConnectionRefusedError                    Traceback (most recent call last)
File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/connector.py:986, in TCPConnector._wrap_create_connection(self, req, timeout, client_error, *args, **kwargs)
    985     async with ceil_timeout(timeout.sock_connect):
--> 986         return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
    987 except cert_errors as exc:

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/base_events.py:1064, in BaseEventLoop.create_connection(self, protocol_factory, host, port, ssl, family, proto, flags, sock, local_addr, server_hostname, ssl_handshake_timeout, happy_eyeballs_delay, interleave)
   1063 if len(exceptions) == 1:
-> 1064     raise exceptions[0]
   1065 else:
   1066     # If they all have the same str(), raise one.

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/base_events.py:1049, in BaseEventLoop.create_connection(self, protocol_factory, host, port, ssl, family, proto, flags, sock, local_addr, server_hostname, ssl_handshake_timeout, happy_eyeballs_delay, interleave)
   1048 try:
-> 1049     sock = await self._connect_sock(
   1050         exceptions, addrinfo, laddr_infos)
   1051     break

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/base_events.py:960, in BaseEventLoop._connect_sock(self, exceptions, addr_info, local_addr_infos)
    959         raise my_exceptions.pop()
--> 960 await self.sock_connect(sock, address)
    961 return sock

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/selector_events.py:499, in BaseSelectorEventLoop.sock_connect(self, sock, address)
    498 self._sock_connect(fut, sock, address)
--> 499 return await fut

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/selector_events.py:534, in BaseSelectorEventLoop._sock_connect_cb(self, fut, sock, address)
    532     if err != 0:
    533         # Jump to any except clause below.
--> 534         raise OSError(err, f'Connect call failed {address}')
    535 except (BlockingIOError, InterruptedError):
    536     # socket is still registered, the callback will be retried later

ConnectionRefusedError: [Errno 61] Connect call failed ('0.0.0.0', 9005)

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

ClientConnectorError                      Traceback (most recent call last)
Input In [8], in <cell line: 1>()
----> 1 ds_published = xr.open_zarr(http_map, consolidated=True)
      2 ds_published

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/xarray/backends/zarr.py:752, in open_zarr(store, group, synchronizer, chunks, decode_cf, mask_and_scale, decode_times, concat_characters, decode_coords, drop_variables, consolidated, overwrite_encoded_chunks, chunk_store, storage_options, decode_timedelta, use_cftime, **kwargs)
    739     raise TypeError(
    740         "open_zarr() got unexpected keyword arguments " + ",".join(kwargs.keys())
    741     )
    743 backend_kwargs = {
    744     "synchronizer": synchronizer,
    745     "consolidated": consolidated,
   (...)
    749     "stacklevel": 4,
    750 }
--> 752 ds = open_dataset(
    753     filename_or_obj=store,
    754     group=group,
    755     decode_cf=decode_cf,
    756     mask_and_scale=mask_and_scale,
    757     decode_times=decode_times,
    758     concat_characters=concat_characters,
    759     decode_coords=decode_coords,
    760     engine="zarr",
    761     chunks=chunks,
    762     drop_variables=drop_variables,
    763     backend_kwargs=backend_kwargs,
    764     decode_timedelta=decode_timedelta,
    765     use_cftime=use_cftime,
    766 )
    767 return ds

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/xarray/backends/api.py:495, in open_dataset(filename_or_obj, engine, chunks, cache, decode_cf, mask_and_scale, decode_times, decode_timedelta, use_cftime, concat_characters, decode_coords, drop_variables, backend_kwargs, *args, **kwargs)
    483 decoders = _resolve_decoders_kwargs(
    484     decode_cf,
    485     open_backend_dataset_parameters=backend.open_dataset_parameters,
   (...)
    491     decode_coords=decode_coords,
    492 )
    494 overwrite_encoded_chunks = kwargs.pop("overwrite_encoded_chunks", None)
--> 495 backend_ds = backend.open_dataset(
    496     filename_or_obj,
    497     drop_variables=drop_variables,
    498     **decoders,
    499     **kwargs,
    500 )
    501 ds = _dataset_from_backend_dataset(
    502     backend_ds,
    503     filename_or_obj,
   (...)
    510     **kwargs,
    511 )
    512 return ds

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/xarray/backends/zarr.py:800, in ZarrBackendEntrypoint.open_dataset(self, filename_or_obj, mask_and_scale, decode_times, concat_characters, decode_coords, drop_variables, use_cftime, decode_timedelta, group, mode, synchronizer, consolidated, chunk_store, storage_options, stacklevel)
    780 def open_dataset(
    781     self,
    782     filename_or_obj,
   (...)
    796     stacklevel=3,
    797 ):
    799     filename_or_obj = _normalize_path(filename_or_obj)
--> 800     store = ZarrStore.open_group(
    801         filename_or_obj,
    802         group=group,
    803         mode=mode,
    804         synchronizer=synchronizer,
    805         consolidated=consolidated,
    806         consolidate_on_close=False,
    807         chunk_store=chunk_store,
    808         storage_options=storage_options,
    809         stacklevel=stacklevel + 1,
    810     )
    812     store_entrypoint = StoreBackendEntrypoint()
    813     with close_on_error(store):

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/xarray/backends/zarr.py:368, in ZarrStore.open_group(cls, store, mode, synchronizer, group, consolidated, consolidate_on_close, chunk_store, storage_options, append_dim, write_region, safe_chunks, stacklevel)
    365         zarr_group = zarr.open_group(store, **open_kwargs)
    366 elif consolidated:
    367     # TODO: an option to pass the metadata_key keyword
--> 368     zarr_group = zarr.open_consolidated(store, **open_kwargs)
    369 else:
    370     zarr_group = zarr.open_group(store, **open_kwargs)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/zarr/convenience.py:1187, in open_consolidated(store, metadata_key, mode, **kwargs)
   1183     raise ValueError("invalid mode, expected either 'r' or 'r+'; found {!r}"
   1184                      .format(mode))
   1186 # setup metadata store
-> 1187 meta_store = ConsolidatedMetadataStore(store, metadata_key=metadata_key)
   1189 # pass through
   1190 chunk_store = kwargs.pop('chunk_store', None) or store

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/zarr/storage.py:2644, in ConsolidatedMetadataStore.__init__(self, store, metadata_key)
   2641 self.store = Store._ensure_store(store)
   2643 # retrieve consolidated metadata
-> 2644 meta = json_loads(store[metadata_key])
   2646 # check format of consolidated metadata
   2647 consolidated_format = meta.get('zarr_consolidated_format', None)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/zarr/storage.py:545, in KVStore.__getitem__(self, key)
    544 def __getitem__(self, key):
--> 545     return self._mutable_mapping[key]

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/fsspec/mapping.py:135, in FSMap.__getitem__(self, key, default)
    133 k = self._key_to_str(key)
    134 try:
--> 135     result = self.fs.cat(k)
    136 except self.missing_exceptions:
    137     if default is not None:

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/fsspec/asyn.py:85, in sync_wrapper.<locals>.wrapper(*args, **kwargs)
     82 @functools.wraps(func)
     83 def wrapper(*args, **kwargs):
     84     self = obj or args[0]
---> 85     return sync(self.loop, func, *args, **kwargs)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/fsspec/asyn.py:65, in sync(loop, func, timeout, *args, **kwargs)
     63     raise FSTimeoutError from return_result
     64 elif isinstance(return_result, BaseException):
---> 65     raise return_result
     66 else:
     67     return return_result

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/fsspec/asyn.py:25, in _runner(event, coro, result, timeout)
     23     coro = asyncio.wait_for(coro, timeout=timeout)
     24 try:
---> 25     result[0] = await coro
     26 except Exception as ex:
     27     result[0] = ex

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/fsspec/asyn.py:397, in AsyncFileSystem._cat(self, path, recursive, on_error, batch_size, **kwargs)
    395     ex = next(filter(is_exception, out), False)
    396     if ex:
--> 397         raise ex
    398 if (
    399     len(paths) > 1
    400     or isinstance(path, list)
    401     or paths[0] != self._strip_protocol(path)
    402 ):
    403     return {
    404         k: v
    405         for k, v in zip(paths, out)
    406         if on_error != "omit" or not is_exception(v)
    407     }

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/asyncio/tasks.py:408, in wait_for(fut, timeout)
    405 loop = events.get_running_loop()
    407 if timeout is None:
--> 408     return await fut
    410 if timeout <= 0:
    411     fut = ensure_future(fut, loop=loop)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/fsspec/implementations/http.py:224, in HTTPFileSystem._cat_file(self, url, start, end, **kwargs)
    222     kw["headers"] = headers
    223 session = await self.set_session()
--> 224 async with session.get(url, **kw) as r:
    225     out = await r.read()
    226     self._raise_not_found_for_status(r, url)

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/client.py:1138, in _BaseRequestContextManager.__aenter__(self)
   1137 async def __aenter__(self) -> _RetType:
-> 1138     self._resp = await self._coro
   1139     return self._resp

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/client.py:535, in ClientSession._request(self, method, str_or_url, params, data, json, cookies, headers, skip_auto_headers, auth, allow_redirects, max_redirects, compress, chunked, expect100, raise_for_status, read_until_eof, proxy, proxy_auth, timeout, verify_ssl, fingerprint, ssl_context, ssl, proxy_headers, trace_request_ctx, read_bufsize)
    533     async with ceil_timeout(real_timeout.connect):
    534         assert self._connector is not None
--> 535         conn = await self._connector.connect(
    536             req, traces=traces, timeout=real_timeout
    537         )
    538 except asyncio.TimeoutError as exc:
    539     raise ServerTimeoutError(
    540         "Connection timeout " "to host {}".format(url)
    541     ) from exc

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/connector.py:542, in BaseConnector.connect(self, req, traces, timeout)
    539         await trace.send_connection_create_start()
    541 try:
--> 542     proto = await self._create_connection(req, traces, timeout)
    543     if self._closed:
    544         proto.close()

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/connector.py:907, in TCPConnector._create_connection(self, req, traces, timeout)
    905     _, proto = await self._create_proxy_connection(req, traces, timeout)
    906 else:
--> 907     _, proto = await self._create_direct_connection(req, traces, timeout)
    909 return proto

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/connector.py:1206, in TCPConnector._create_direct_connection(self, req, traces, timeout, client_error)
   1204 else:
   1205     assert last_exc is not None
-> 1206     raise last_exc

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/connector.py:1175, in TCPConnector._create_direct_connection(self, req, traces, timeout, client_error)
   1172 port = hinfo["port"]
   1174 try:
-> 1175     transp, proto = await self._wrap_create_connection(
   1176         self._factory,
   1177         host,
   1178         port,
   1179         timeout=timeout,
   1180         ssl=sslcontext,
   1181         family=hinfo["family"],
   1182         proto=hinfo["proto"],
   1183         flags=hinfo["flags"],
   1184         server_hostname=hinfo["hostname"] if sslcontext else None,
   1185         local_addr=self._local_addr,
   1186         req=req,
   1187         client_error=client_error,
   1188     )
   1189 except ClientConnectorError as exc:
   1190     last_exc = exc

File ~/opt/anaconda3/envs/code-sprint-2022/lib/python3.10/site-packages/aiohttp/connector.py:992, in TCPConnector._wrap_create_connection(self, req, timeout, client_error, *args, **kwargs)
    990     raise ClientConnectorSSLError(req.connection_key, exc) from exc
    991 except OSError as exc:
--> 992     raise client_error(req.connection_key, exc) from exc

ClientConnectorError: Cannot connect to host 0.0.0.0:9005 ssl:default [Connect call failed ('0.0.0.0', 9005)]