pygeoapi icon indicating copy to clipboard operation
pygeoapi copied to clipboard

zarr file format

Open dschneider-wxs opened this issue 8 months ago • 1 comments

Description I am using the workshop resources to test pygeoapi. I would like to serve zarr "files" either as coverage or edr but I get the error below always. I have tried with zarr v3, and zarr v2 with/out consolidated_metadata. I am creating the zarr by reading a netcdf as a dataset with xarray and using ds.to_zarr() to write to local disk.

i couldn't find an example of a zarr being served. do I need to do something specific, like specify the engine? i don't see any options to do so in the documentation. Thanks in advance.

this is the collection i defined in my config:

    gems2:
        type: collection
        title: GEMS2
        description: My zarr dataset
        providers:
            - type: coverage
              name: xarray
              data: /data/acq00004-v2.zar
              format:
                  name: zarr
                  mimetype: application/zip
(3) ~/Downloads/diving-into-pygeoapi-main/workshop/exercises
% docker compose up
[+] Running 1/1
 ✔ Container pygeoapi  Created                                                                                      0.0s 
Attaching to pygeoapi
pygeoapi  | START /entrypoint.sh
pygeoapi  | Trying to generate openapi.yml
pygeoapi  | /usr/lib/python3/dist-packages/xarray/backends/plugins.py:117: RuntimeWarning: 'netcdf4' fails while guessing
pygeoapi  |   warnings.warn(f"{engine!r} fails while guessing", RuntimeWarning)
pygeoapi  | /usr/lib/python3/dist-packages/xarray/backends/plugins.py:117: RuntimeWarning: 'scipy' fails while guessing
pygeoapi  |   warnings.warn(f"{engine!r} fails while guessing", RuntimeWarning)
pygeoapi  | /usr/lib/python3/dist-packages/xarray/backends/plugins.py:126: RuntimeWarning: 'netcdf4' fails while guessing
pygeoapi  |   warnings.warn(f"{engine!r} fails while guessing", RuntimeWarning)
pygeoapi  | /usr/lib/python3/dist-packages/xarray/backends/plugins.py:126: RuntimeWarning: 'h5netcdf' fails while guessing
pygeoapi  |   warnings.warn(f"{engine!r} fails while guessing", RuntimeWarning)
pygeoapi  | /usr/lib/python3/dist-packages/xarray/backends/plugins.py:126: RuntimeWarning: 'scipy' fails while guessing
pygeoapi  |   warnings.warn(f"{engine!r} fails while guessing", RuntimeWarning)
pygeoapi  | did not find a match in any of xarray's currently installed IO backends ['netcdf4', 'scipy', 'zarr']. Consider explicitly selecting one of the installed engines via the ``engine`` parameter, or installing additional IO dependencies, see:
pygeoapi  | http://xarray.pydata.org/en/stable/getting-started-guide/installing.html
pygeoapi  | http://xarray.pydata.org/en/stable/user-guide/io.html
pygeoapi  | Traceback (most recent call last):
pygeoapi  |   File "/pygeoapi/pygeoapi/provider/xarray_.py", line 95, in __init__
pygeoapi  |     raise err
pygeoapi  |   File "/pygeoapi/pygeoapi/provider/xarray_.py", line 89, in __init__
pygeoapi  |     self._data = open_func(data_to_open)
pygeoapi  |   File "/usr/lib/python3/dist-packages/xarray/backends/api.py", line 479, in open_dataset
pygeoapi  |     engine = plugins.guess_engine(filename_or_obj)
pygeoapi  |   File "/usr/lib/python3/dist-packages/xarray/backends/plugins.py", line 155, in guess_engine
pygeoapi  |     raise ValueError(error_msg)
pygeoapi  | ValueError: did not find a match in any of xarray's currently installed IO backends ['netcdf4', 'scipy', 'zarr']. Consider explicitly selecting one of the installed engines via the ``engine`` parameter, or installing additional IO dependencies, see:
pygeoapi  | http://xarray.pydata.org/en/stable/getting-started-guide/installing.html
pygeoapi  | http://xarray.pydata.org/en/stable/user-guide/io.html
pygeoapi  | 
pygeoapi  | During handling of the above exception, another exception occurred:
pygeoapi  | 
pygeoapi  | Traceback (most recent call last):
pygeoapi  |   File "/usr/local/bin/pygeoapi", line 33, in <module>
pygeoapi  |     sys.exit(load_entry_point('pygeoapi', 'console_scripts', 'pygeoapi')())
pygeoapi  |   File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1161, in __call__
pygeoapi  |     return self.main(*args, **kwargs)
pygeoapi  |   File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1082, in main
pygeoapi  |     rv = self.invoke(ctx)
pygeoapi  |   File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1697, in invoke
pygeoapi  |     return _process_result(sub_ctx.command.invoke(sub_ctx))
pygeoapi  |   File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1697, in invoke
pygeoapi  |     return _process_result(sub_ctx.command.invoke(sub_ctx))
pygeoapi  |   File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1443, in invoke
pygeoapi  |     return ctx.invoke(self.callback, **ctx.params)
pygeoapi  |   File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 788, in invoke
pygeoapi  |     return __callback(*args, **kwargs)
pygeoapi  |   File "/usr/local/lib/python3.10/dist-packages/click/decorators.py", line 33, in new_func
pygeoapi  |     return f(get_current_context(), *args, **kwargs)
pygeoapi  |   File "/pygeoapi/pygeoapi/openapi.py", line 1057, in generate
pygeoapi  |     content = generate_openapi_document(
pygeoapi  |   File "/pygeoapi/pygeoapi/openapi.py", line 997, in generate_openapi_document
pygeoapi  |     oas = get_oas(s, fail_on_invalid_collection=fail_on_invalid_collection)
pygeoapi  |   File "/pygeoapi/pygeoapi/openapi.py", line 947, in get_oas
pygeoapi  |     return get_oas_30(
pygeoapi  |   File "/pygeoapi/pygeoapi/openapi.py", line 542, in get_oas_30
pygeoapi  |     sub_tags, sub_paths = api_module.get_oas_30(cfg, locale_)
pygeoapi  |   File "/pygeoapi/pygeoapi/api/coverages.py", line 218, in get_oas_30
pygeoapi  |     load_plugin('provider', get_provider_by_type(
pygeoapi  |   File "/pygeoapi/pygeoapi/plugin.py", line 126, in load_plugin
pygeoapi  |     plugin = class_(plugin_def)
pygeoapi  |   File "/pygeoapi/pygeoapi/provider/xarray_.py", line 105, in __init__
pygeoapi  |     raise ProviderConnectionError(err)
pygeoapi  | pygeoapi.provider.base.ProviderConnectionError: did not find a match in any of xarray's currently installed IO backends ['netcdf4', 'scipy', 'zarr']. Consider explicitly selecting one of the installed engines via the ``engine`` parameter, or installing additional IO dependencies, see:
pygeoapi  | http://xarray.pydata.org/en/stable/getting-started-guide/installing.html
pygeoapi  | http://xarray.pydata.org/en/stable/user-guide/io.html
pygeoapi  | ERROR: openapi.yml could not be generated ERROR
pygeoapi exited with code 255

(3) ~/Downloads/diving-into-pygeoapi-main/workshop/exercises
% 

dschneider-wxs avatar Apr 15 '25 22:04 dschneider-wxs

i took a peek at the source and realized the code is looking for .zarr explicitly and i had .zar https://github.com/geopython/pygeoapi/blob/9a71a01b3b0d2383a5128065361b668f6f4c0b0f/pygeoapi/provider/xarray_.py#L67C15-L67C51

however, is there anyway to provide options to xarray reader? I need to provide decode_times=False but the try/except block in the source is not catching my error for some reason. so maybe thats the real bug i'm catching here

dschneider-wxs avatar Apr 15 '25 23:04 dschneider-wxs

This Issue has been inactive for 90 days. As per RFC4, in order to manage maintenance burden, it will be automatically closed in 7 days.

github-actions[bot] avatar Jul 20 '25 04:07 github-actions[bot]

As per RFC4, this Issue has been closed due to there being no activity for more than 90 days.

github-actions[bot] avatar Jul 27 '25 04:07 github-actions[bot]