From 64326058c07b56836e6d3675acd2d94bf7397fd4 Mon Sep 17 00:00:00 2001 From: Metamess Date: Wed, 16 Aug 2023 14:32:41 +0200 Subject: [PATCH 1/8] Renamed 'grib_errors' parameter to 'errors' to match open_file() signature --- cfgrib/dataset.py | 7 +++---- cfgrib/xarray_store.py | 2 +- tests/test_40_xarray_store.py | 9 ++++++--- tests/test_50_sample_data.py | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cfgrib/dataset.py b/cfgrib/dataset.py index 91db7996..bf5eea9a 100644 --- a/cfgrib/dataset.py +++ b/cfgrib/dataset.py @@ -782,7 +782,7 @@ def open_fileindex( def open_file( path: T.Union[str, "os.PathLike[str]"], - grib_errors: str = "warn", + errors: str = "warn", indexpath: str = messages.DEFAULT_INDEXPATH, filter_by_keys: T.Dict[str, T.Any] = {}, read_keys: T.Sequence[str] = (), @@ -792,9 +792,8 @@ def open_file( ) -> Dataset: """Open a GRIB file as a ``cfgrib.Dataset``.""" path = os.fspath(path) - stream = messages.FileStream(path, errors=grib_errors) - + stream = messages.FileStream(path, errors=errors) index_keys = compute_index_keys(time_dims, extra_coords) index = open_fileindex(stream, indexpath, index_keys, filter_by_keys=filter_by_keys) - return open_from_index(index, read_keys, time_dims, extra_coords, **kwargs) + return open_from_index(index, read_keys, time_dims, extra_coords, errors=errors, **kwargs) diff --git a/cfgrib/xarray_store.py b/cfgrib/xarray_store.py index f0427fc0..d0a32cd9 100644 --- a/cfgrib/xarray_store.py +++ b/cfgrib/xarray_store.py @@ -82,7 +82,7 @@ def open_variable_datasets(path, backend_kwargs={}, **kwargs): for key in ["filter_by_keys", "indexpath"] if key in backend_kwargs } - errors = backend_kwargs.get("grib_errors", "warn") + errors = backend_kwargs.get("errors", "warn") stream = messages.FileStream(path, errors=errors) index = open_fileindex(stream, computed_keys=cfmessage.COMPUTED_KEYS, **fileindex_kwargs) datasets = [] # type: T.List[xr.Dataset] diff --git a/tests/test_40_xarray_store.py b/tests/test_40_xarray_store.py index 46b07683..d1ac9a27 100644 --- a/tests/test_40_xarray_store.py +++ b/tests/test_40_xarray_store.py @@ -1,5 +1,6 @@ import os.path +import gribapi import numpy as np import pytest @@ -39,9 +40,11 @@ def test_open_dataset() -> None: res = xarray_store.open_dataset(TEST_IGNORE, backend_kwargs={"errors": "ignore"}) assert "isobaricInhPa" in res.dims - with pytest.raises(ValueError): + with pytest.raises(dataset.DatasetBuildError): xarray_store.open_dataset(TEST_IGNORE, backend_kwargs={"errors": "raise"}) + xarray_store.open_dataset(TEST_DATA, backend_kwargs={"errors": "raise"}) + def test_open_dataset_corrupted() -> None: res = xarray_store.open_dataset(TEST_CORRUPTED) @@ -49,8 +52,8 @@ def test_open_dataset_corrupted() -> None: assert res.attrs["GRIB_edition"] == 1 assert len(res.data_vars) == 1 - with pytest.raises(Exception): - xarray_store.open_dataset(TEST_CORRUPTED, backend_kwargs={"grib_errors": "raise"}) + with pytest.raises(gribapi.GribInternalError): + xarray_store.open_dataset(TEST_CORRUPTED, backend_kwargs={"errors": "raise"}) def test_open_dataset_encode_cf_time() -> None: diff --git a/tests/test_50_sample_data.py b/tests/test_50_sample_data.py index 89b5bfd2..df9d8900 100644 --- a/tests/test_50_sample_data.py +++ b/tests/test_50_sample_data.py @@ -7,7 +7,7 @@ xr = pytest.importorskip("xarray") # noqa -from cfgrib import xarray_store, xarray_to_grib +from cfgrib import xarray_store, xarray_to_grib, dataset SAMPLE_DATA_FOLDER = os.path.join(os.path.dirname(__file__), "sample-data") @@ -49,7 +49,7 @@ def test_open_dataset(grib_name: str) -> None: def test_open_dataset_fail(grib_name: str) -> None: grib_path = os.path.join(SAMPLE_DATA_FOLDER, grib_name + ".grib") - with pytest.raises(ValueError): + with pytest.raises(dataset.DatasetBuildError): xarray_store.open_dataset(grib_path, cache=False, backend_kwargs={"errors": "raise"}) From 84b414f6095c60ba66d6c184e8dd55d7418592f5 Mon Sep 17 00:00:00 2001 From: Iain Russell Date: Thu, 17 Aug 2023 17:01:52 +0100 Subject: [PATCH 2/8] isort --- tests/test_50_sample_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_50_sample_data.py b/tests/test_50_sample_data.py index df9d8900..c4384dd7 100644 --- a/tests/test_50_sample_data.py +++ b/tests/test_50_sample_data.py @@ -7,7 +7,7 @@ xr = pytest.importorskip("xarray") # noqa -from cfgrib import xarray_store, xarray_to_grib, dataset +from cfgrib import dataset, xarray_store, xarray_to_grib SAMPLE_DATA_FOLDER = os.path.join(os.path.dirname(__file__), "sample-data") From 3c06b8369b5fa2d102d6cd51807fa41bdf6a65bc Mon Sep 17 00:00:00 2001 From: Iain Russell Date: Thu, 17 Aug 2023 17:17:49 +0100 Subject: [PATCH 3/8] mpypy fix on test_40_xarray_store.py --- tests/test_40_xarray_store.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_40_xarray_store.py b/tests/test_40_xarray_store.py index d1ac9a27..0f51613b 100644 --- a/tests/test_40_xarray_store.py +++ b/tests/test_40_xarray_store.py @@ -1,6 +1,6 @@ import os.path -import gribapi +import gribapi # type: ignore import numpy as np import pytest From abcdbedf49c448225469558b0c2fc50982b0f0e0 Mon Sep 17 00:00:00 2001 From: Iain Russell Date: Thu, 17 Aug 2023 18:24:32 +0100 Subject: [PATCH 4/8] Update ci dependencies to eccodes==2.31.0 and python-eccodes==1.6.0 --- tests/environment-macos-3.8.yml | 4 ++-- tests/environment-ubuntu-3.10.yml | 2 +- tests/environment-ubuntu-3.7.yml | 4 ++-- tests/environment-ubuntu-3.8.yml | 4 ++-- tests/environment-ubuntu-3.9-minimal.yml | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/environment-macos-3.8.yml b/tests/environment-macos-3.8.yml index 8b5f86ee..f991d564 100644 --- a/tests/environment-macos-3.8.yml +++ b/tests/environment-macos-3.8.yml @@ -15,7 +15,7 @@ dependencies: - click=8.0.3 - coverage=6.2 - curl=7.80.0 - - eccodes=2.24.2 + - eccodes=2.31.0 - findlibs=0.0.2 - hdf4=4.2.15 - hdf5=1.12.1 @@ -65,7 +65,7 @@ dependencies: - pytest-cov=3.0.0 - python=3.8.12 - python-dateutil=2.8.2 - - python-eccodes=1.4.0 + - python-eccodes=1.5.0 - python_abi=3.8 - pytz=2021.3 - readline=8.1.2 diff --git a/tests/environment-ubuntu-3.10.yml b/tests/environment-ubuntu-3.10.yml index c13502a9..224a8e85 100644 --- a/tests/environment-ubuntu-3.10.yml +++ b/tests/environment-ubuntu-3.10.yml @@ -62,7 +62,7 @@ dependencies: - pytest=7.3.1 - python=3.10.11 - python-dateutil=2.8.2 - - python-eccodes=1.5.1 + - python-eccodes=1.6.0 - python-tzdata=2023.3 - python_abi=3.10 - pytz=2023.3 diff --git a/tests/environment-ubuntu-3.7.yml b/tests/environment-ubuntu-3.7.yml index d3fe9cb2..e6c07009 100644 --- a/tests/environment-ubuntu-3.7.yml +++ b/tests/environment-ubuntu-3.7.yml @@ -16,7 +16,7 @@ dependencies: - click=8.0.3 - coverage=6.2 - curl=7.80.0 - - eccodes=2.24.2 + - eccodes=2.31.0 - findlibs=0.0.2 - freeglut=3.2.1 - hdf4=4.2.15 @@ -70,7 +70,7 @@ dependencies: - pytest-cov=3.0.0 - python=3.7.11 - python-dateutil=2.8.2 - - python-eccodes=1.4.0 + - python-eccodes=1.6.0 - python_abi=3.7 - pytz=2021.3 - readline=8.1.2 diff --git a/tests/environment-ubuntu-3.8.yml b/tests/environment-ubuntu-3.8.yml index f525de74..24d08c8b 100644 --- a/tests/environment-ubuntu-3.8.yml +++ b/tests/environment-ubuntu-3.8.yml @@ -16,7 +16,7 @@ dependencies: - click=8.0.3 - coverage=6.2 - curl=7.80.0 - - eccodes=2.24.2 + - eccodes=2.31.0 - findlibs=0.0.2 - freeglut=3.2.1 - hdf4=4.2.15 @@ -70,7 +70,7 @@ dependencies: - pytest-cov=3.0.0 - python=3.8.12 - python-dateutil=2.8.2 - - python-eccodes=1.4.0 + - python-eccodes=1.6.0 - python_abi=3.8 - pytz=2021.3 - readline=8.1.2 diff --git a/tests/environment-ubuntu-3.9-minimal.yml b/tests/environment-ubuntu-3.9-minimal.yml index 3ba22061..8fd0ca03 100644 --- a/tests/environment-ubuntu-3.9-minimal.yml +++ b/tests/environment-ubuntu-3.9-minimal.yml @@ -15,7 +15,7 @@ dependencies: - click=8.0.3 - coverage=6.2 - curl=7.80.0 - - eccodes=2.23.0 + - eccodes=2.31.0 - findlibs=0.0.2 - freeglut=3.0.0 - hdf4=4.2.13 @@ -60,7 +60,7 @@ dependencies: - pytest=6.2.5 - pytest-cov=3.0.0 - python=3.9.7 - - python-eccodes=1.4.0 + - python-eccodes=1.6.0 - python_abi=3.9 - readline=8.1.2 - setuptools=58.0.4 From 69908ac4de990a454967d62405f358d2bdf0fc53 Mon Sep 17 00:00:00 2001 From: Iain Russell Date: Thu, 17 Aug 2023 18:30:57 +0100 Subject: [PATCH 5/8] Update ci dependencies to eccodes==2.31.0 and python-eccodes==1.6.0 --- tests/environment-macos-3.8.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/environment-macos-3.8.yml b/tests/environment-macos-3.8.yml index f991d564..fcb24e95 100644 --- a/tests/environment-macos-3.8.yml +++ b/tests/environment-macos-3.8.yml @@ -65,7 +65,7 @@ dependencies: - pytest-cov=3.0.0 - python=3.8.12 - python-dateutil=2.8.2 - - python-eccodes=1.5.0 + - python-eccodes=1.6.0 - python_abi=3.8 - pytz=2021.3 - readline=8.1.2 From 9f10fa92f09ef450bd5f7a43ec46da88eb41143a Mon Sep 17 00:00:00 2001 From: Iain Russell Date: Fri, 18 Aug 2023 09:25:17 +0100 Subject: [PATCH 6/8] Update ci dependencies to be modern/drop Python 3.7 ci because latest python-eccodes not available for it --- .github/workflows/on-push.yml | 2 +- tests/environment-macos-3.8.yml | 145 +++++++++++-------- tests/environment-ubuntu-3.8.yml | 172 ++++++++++++++--------- tests/environment-ubuntu-3.9-minimal.yml | 145 ++++++++++++------- 4 files changed, 285 insertions(+), 179 deletions(-) diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml index 94a8170a..7d554b75 100644 --- a/.github/workflows/on-push.yml +++ b/.github/workflows/on-push.yml @@ -9,7 +9,7 @@ jobs: max-parallel: 5 matrix: os: [ubuntu] - python: [3.7, 3.8] + python: [3.8] extras: [''] include: - os: macos diff --git a/tests/environment-macos-3.8.yml b/tests/environment-macos-3.8.yml index fcb24e95..373d4774 100644 --- a/tests/environment-macos-3.8.yml +++ b/tests/environment-macos-3.8.yml @@ -3,84 +3,109 @@ channels: - defaults - conda-forge dependencies: - - attrs=21.4.0 - - blas=2.113 + - attrs=23.1.0 + - aws-c-auth=0.7.3 + - aws-c-cal=0.6.1 + - aws-c-common=0.9.0 + - aws-c-compression=0.2.17 + - aws-c-event-stream=0.3.1 + - aws-c-http=0.7.11 + - aws-c-io=0.13.32 + - aws-c-mqtt=0.9.3 + - aws-c-s3=0.3.14 + - aws-c-sdkutils=0.1.12 + - aws-checksums=0.1.17 + - aws-crt-cpp=0.21.0 + - aws-sdk-cpp=1.10.57 + - blas=2.117 - blas-devel=3.9.0 - - bottleneck=1.3.2 + - blosc=1.21.4 + - brotli-python=1.0.9 - bzip2=1.0.8 - - c-ares=1.18.1 - - ca-certificates=2021.10.26 - - certifi=2021.10.8 - - cffi=1.15.0 - - click=8.0.3 - - coverage=6.2 - - curl=7.80.0 + - c-ares=1.19.1 + - ca-certificates=2023.7.22 + - certifi=2023.7.22 + - cffi=1.15.1 + - charset-normalizer=3.2.0 + - click=8.1.6 + - colorama=0.4.6 + - coverage=7.3.0 - eccodes=2.31.0 - - findlibs=0.0.2 + - exceptiongroup=1.1.3 + - findlibs=0.0.5 - hdf4=4.2.15 - - hdf5=1.12.1 - - importlib-metadata=4.8.2 - - importlib_metadata=4.8.2 - - iniconfig=1.1.1 - - jasper=2.0.33 - - jpeg=9d - - krb5=1.19.2 + - hdf5=1.14.1 + - icu=72.1 + - idna=3.4 + - iniconfig=2.0.0 + - jasper=4.0.0 + - krb5=1.21.2 - libaec=1.0.6 - libblas=3.9.0 - libcblas=3.9.0 - - libcurl=7.80.0 - - libcxx=12.0.0 - - libedit=3.1.20210910 + - libcurl=8.2.1 + - libcxx=16.0.6 + - libedit=3.1.20191231 - libev=4.33 - - libffi=3.3 + - libffi=3.4.4 - libgfortran=5.0.0 - - libgfortran5=9.3.0 + - libgfortran5=12.3.0 + - libiconv=1.17 + - libjpeg-turbo=2.1.5.1 - liblapack=3.9.0 - liblapacke=3.9.0 - - libnetcdf=4.8.1 - - libnghttp2=1.46.0 - - libopenblas=0.3.18 - - libpng=1.6.37 - - libssh2=1.9.0 - - libzip=1.8.0 - - llvm-openmp=12.0.0 + - libnetcdf=4.9.2 + - libnghttp2=1.52.0 + - libopenblas=0.3.23 + - libpng=1.6.39 + - libsqlite=3.42.0 + - libssh2=1.11.0 + - libxml2=2.11.5 + - libzip=1.9.2 + - libzlib=1.2.13 + - llvm-openmp=16.0.6 + - lz4-c=1.9.4 - mypy=0.812 - mypy_extensions=0.4.3 - - ncurses=6.3 - - nomkl=3.0 - - numexpr=2.8.1 - - numpy=1.21.2 - - numpy-base=1.21.2 - - openblas=0.3.18 - - openssl=1.1.1m - - packaging=21.3 - - pandas=1.3.5 - - pip=21.2.4 - - pluggy=1.0.0 - - psutil=5.8.0 - - py=1.10.0 + - ncurses=6.4 + - nomkl=1.0 + - numpy=1.24.3 + - numpy-base=1.24.3 + - openblas=0.3.23 + - openssl=3.1.2 + - packaging=23.1 + - pandas=1.5.3 + - pip=23.2.1 + - platformdirs=3.10.0 + - pluggy=1.2.0 + - pooch=1.7.0 + - psutil=5.9.0 - pycparser=2.21 - - pyparsing=3.0.4 - - pytest=6.2.5 - - pytest-cov=3.0.0 - - python=3.8.12 + - pysocks=1.7.1 + - pytest=7.4.0 + - pytest-cov=4.1.0 + - python=3.8.17 - python-dateutil=2.8.2 - python-eccodes=1.6.0 - python_abi=3.8 - - pytz=2021.3 - - readline=8.1.2 - - scipy=1.7.3 - - setuptools=58.0.4 + - pytz=2023.3 + - readline=8.2 + - requests=2.31.0 + - scipy=1.10.1 + - setuptools=68.0.0 - six=1.16.0 - - sqlite=3.37.0 - - tk=8.6.11 + - snappy=1.1.10 + - sqlite=3.41.2 + - tk=8.6.12 - toml=0.10.2 - - tomli=1.2.2 + - tomli=2.0.1 - typed-ast=1.4.3 - - typing_extensions=3.10.0.2 - - wheel=0.37.1 - - xarray=0.20.2 - - xz=5.2.5 - - zipp=3.7.0 - - zlib=1.2.11 + - typing-extensions=4.7.1 + - typing_extensions=4.7.1 + - urllib3=2.0.4 + - wheel=0.38.4 + - xarray=2023.1.0 + - xz=5.4.2 + - zlib=1.2.13 + - zstd=1.5.2 prefix: /usr/local/miniconda/envs/macos-3.8 diff --git a/tests/environment-ubuntu-3.8.yml b/tests/environment-ubuntu-3.8.yml index 24d08c8b..f69a6be7 100644 --- a/tests/environment-ubuntu-3.8.yml +++ b/tests/environment-ubuntu-3.8.yml @@ -5,97 +5,137 @@ channels: dependencies: - _libgcc_mutex=0.1 - _openmp_mutex=4.5 - - attrs=21.4.0 - - blas=2.106 - - bottleneck=1.3.2 + - attrs=23.1.0 + - aws-c-auth=0.7.3 + - aws-c-cal=0.6.1 + - aws-c-common=0.9.0 + - aws-c-compression=0.2.17 + - aws-c-event-stream=0.3.1 + - aws-c-http=0.7.11 + - aws-c-io=0.13.32 + - aws-c-mqtt=0.9.3 + - aws-c-s3=0.3.14 + - aws-c-sdkutils=0.1.12 + - aws-checksums=0.1.17 + - aws-crt-cpp=0.21.0 + - aws-sdk-cpp=1.10.57 + - blas=2.117 + - blas-devel=3.9.0 + - blosc=1.21.4 + - bottleneck=1.3.7 + - brotli-python=1.0.9 - bzip2=1.0.8 - - c-ares=1.18.1 - - ca-certificates=2021.10.26 - - certifi=2021.10.8 - - cffi=1.15.0 - - click=8.0.3 - - coverage=6.2 - - curl=7.80.0 + - c-ares=1.19.1 + - ca-certificates=2023.7.22 + - certifi=2023.7.22 + - cffi=1.15.1 + - charset-normalizer=3.2.0 + - click=8.1.6 + - colorama=0.4.6 + - coverage=7.3.0 + - curl=8.2.1 - eccodes=2.31.0 - - findlibs=0.0.2 - - freeglut=3.2.1 + - exceptiongroup=1.1.3 + - findlibs=0.0.5 + - freeglut=3.2.2 - hdf4=4.2.15 - - hdf5=1.12.1 - - importlib-metadata=4.8.2 - - importlib_metadata=4.8.2 - - iniconfig=1.1.1 - - jasper=2.0.33 - - jpeg=9d - - krb5=1.19.2 - - ld_impl_linux-64=2.35.1 + - hdf5=1.14.1 + - icu=72.1 + - idna=3.4 + - importlib-metadata=6.8.0 + - importlib_metadata=6.8.0 + - iniconfig=2.0.0 + - jasper=4.0.0 + - jpeg=9e + - keyutils=1.6.1 + - krb5=1.21.2 + - ld_impl_linux-64=2.40 - libaec=1.0.6 - libblas=3.9.0 - libcblas=3.9.0 - - libcurl=7.80.0 - - libedit=3.1.20210910 + - libcurl=8.2.1 + - libedit=3.1.20191231 - libev=4.33 - - libffi=3.3 - - libgcc-ng=11.2.0 - - libgfortran-ng=11.2.0 - - libgfortran5=11.2.0 + - libffi=3.4.2 + - libgcc-ng=13.1.0 + - libgfortran-ng=13.1.0 + - libgfortran5=13.1.0 - libglu=9.0.0 + - libiconv=1.17 - liblapack=3.9.0 - liblapacke=3.9.0 - - libnetcdf=4.8.1 - - libnghttp2=1.46.0 - - libopenblas=0.3.12 - - libpng=1.6.37 - - libssh2=1.9.0 - - libstdcxx-ng=11.2.0 - - libxcb=1.14 - - libzip=1.8.0 - - llvm-openmp=12.0.1 - - mypy=0.812 - - mypy_extensions=0.4.3 - - ncurses=6.3 - - nomkl=3.0 + - libnetcdf=4.9.2 + - libnghttp2=1.52.0 + - libnsl=2.0.0 + - libopenblas=0.3.23 + - libpng=1.6.39 + - libsqlite=3.42.0 + - libssh2=1.11.0 + - libstdcxx-ng=13.1.0 + - libxcb=1.15 + - libxml2=2.11.5 + - libzip=1.9.2 + - libzlib=1.2.13 + - llvm-openmp=16.0.6 + - lz4-c=1.9.4 + - mypy=1.5.1 + - mypy_extensions=1.0.0 + - ncurses=6.4 + - nomkl=1.0 - numexpr=2.8.1 - numpy=1.21.2 - numpy-base=1.21.2 - - openssl=1.1.1m - - packaging=21.3 - - pandas=1.3.5 - - pip=21.2.4 - - pluggy=1.0.0 - - psutil=5.8.0 - - py=1.10.0 + - openblas=0.3.23 + - openssl=3.1.2 + - packaging=23.1 + - pandas=1.5.3 + - pip=23.2.1 + - platformdirs=3.10.0 + - pluggy=1.2.0 + - pooch=1.7.0 + - psutil=5.9.5 + - pthread-stubs=0.4 + - py=1.11.0 - pycparser=2.21 - - pyparsing=3.0.4 - - pytest=6.2.5 - - pytest-cov=3.0.0 + - pyparsing=3.1.1 + - pysocks=1.7.1 + - pytest=7.4.0 + - pytest-cov=4.1.0 - python=3.8.12 - python-dateutil=2.8.2 - - python-eccodes=1.6.0 + - python-eccodes=1.5.1 - python_abi=3.8 - - pytz=2021.3 - - readline=8.1.2 - - scipy=1.7.3 - - setuptools=58.0.4 + - pytz=2023.3 + - readline=8.2 + - requests=2.31.0 + - s2n=1.3.48 + - scipy=1.10.1 + - setuptools=68.0.0 - six=1.16.0 - - sqlite=3.37.0 - - tk=8.6.11 + - snappy=1.1.10 + - sqlite=3.42.0 + - tk=8.6.12 - toml=0.10.2 - - tomli=1.2.2 - - typed-ast=1.4.3 - - typing_extensions=3.10.0.2 - - wheel=0.37.1 - - xarray=0.20.2 + - tomli=2.0.1 + - typed-ast=1.5.5 + - typing-extensions=4.7.1 + - typing_extensions=4.7.1 + - urllib3=2.0.4 + - wheel=0.41.1 + - xarray=2023.1.0 - xorg-fixesproto=5.0 - xorg-inputproto=2.3.2 - xorg-kbproto=1.0.7 - - xorg-libx11=1.7.2 - - xorg-libxau=1.0.9 + - xorg-libx11=1.8.6 + - xorg-libxau=1.0.11 + - xorg-libxdmcp=1.1.3 - xorg-libxext=1.3.4 - xorg-libxfixes=5.0.3 - xorg-libxi=1.7.10 - xorg-xextproto=7.3.0 - xorg-xproto=7.0.31 - - xz=5.2.5 - - zipp=3.7.0 - - zlib=1.2.11 + - xz=5.2.6 + - zipp=3.16.2 + - zlib=1.2.13 + - zstd=1.5.2 prefix: /usr/share/miniconda/envs/ubuntu-3.8 diff --git a/tests/environment-ubuntu-3.9-minimal.yml b/tests/environment-ubuntu-3.9-minimal.yml index 8fd0ca03..35c41f1a 100644 --- a/tests/environment-ubuntu-3.9-minimal.yml +++ b/tests/environment-ubuntu-3.9-minimal.yml @@ -5,71 +5,112 @@ channels: dependencies: - _libgcc_mutex=0.1 - _openmp_mutex=4.5 - - attrs=21.4.0 - - blas=2.106 + - attrs=23.1.0 + - aws-c-auth=0.7.3 + - aws-c-cal=0.6.1 + - aws-c-common=0.9.0 + - aws-c-compression=0.2.17 + - aws-c-event-stream=0.3.1 + - aws-c-http=0.7.11 + - aws-c-io=0.13.32 + - aws-c-mqtt=0.9.3 + - aws-c-s3=0.3.14 + - aws-c-sdkutils=0.1.12 + - aws-checksums=0.1.17 + - aws-crt-cpp=0.21.0 + - aws-sdk-cpp=1.10.57 + - blas=2.117 + - blas-devel=3.9.0 + - blosc=1.21.4 - bzip2=1.0.8 - - c-ares=1.18.1 - - ca-certificates=2021.10.26 - - certifi=2021.10.8 - - cffi=1.15.0 - - click=8.0.3 - - coverage=6.2 - - curl=7.80.0 + - c-ares=1.19.1 + - ca-certificates=2023.7.22 + - certifi=2023.7.22 + - cffi=1.15.1 + - click=8.1.7 + - colorama=0.4.6 + - coverage=7.3.0 + - curl=8.2.1 - eccodes=2.31.0 - - findlibs=0.0.2 - - freeglut=3.0.0 - - hdf4=4.2.13 - - hdf5=1.10.6 - - iniconfig=1.1.1 - - jasper=2.0.14 - - jpeg=9d - - krb5=1.19.2 - - ld_impl_linux-64=2.35.1 + - exceptiongroup=1.1.3 + - findlibs=0.0.5 + - freeglut=3.2.2 + - hdf4=4.2.15 + - hdf5=1.14.1 + - icu=72.1 + - iniconfig=2.0.0 + - jasper=4.0.0 + - jpeg=9e + - keyutils=1.6.1 + - krb5=1.21.2 + - ld_impl_linux-64=2.40 - libaec=1.0.6 - libblas=3.9.0 - libcblas=3.9.0 - - libcurl=7.80.0 - - libedit=3.1.20210910 + - libcurl=8.2.1 + - libedit=3.1.20191231 - libev=4.33 - - libffi=3.3 - - libgcc-ng=11.2.0 - - libgfortran-ng=11.2.0 - - libgfortran5=11.2.0 + - libffi=3.4.2 + - libgcc-ng=13.1.0 + - libgfortran-ng=13.1.0 + - libgfortran5=13.1.0 - libglu=9.0.0 + - libiconv=1.17 - liblapack=3.9.0 - liblapacke=3.9.0 - - libnetcdf=4.8.1 - - libnghttp2=1.46.0 - - libopenblas=0.3.12 - - libpng=1.6.37 - - libssh2=1.9.0 - - libstdcxx-ng=11.2.0 - - libzip=1.5.1 - - llvm-openmp=12.0.1 - - ncurses=6.3 - - nomkl=3.0 + - libnetcdf=4.9.2 + - libnghttp2=1.52.0 + - libopenblas=0.3.23 + - libpng=1.6.39 + - libsqlite=3.42.0 + - libssh2=1.11.0 + - libstdcxx-ng=13.1.0 + - libxcb=1.15 + - libxml2=2.11.5 + - libzip=1.9.2 + - libzlib=1.2.13 + - llvm-openmp=16.0.6 + - lz4-c=1.9.4 + - ncurses=6.4 + - nomkl=1.0 - numpy=1.21.2 - numpy-base=1.21.2 - - openssl=1.1.1m - - packaging=21.3 - - pip=21.2.4 - - pluggy=1.0.0 - - py=1.10.0 + - openblas=0.3.23 + - openssl=3.1.2 + - packaging=23.1 + - pip=23.2.1 + - pluggy=1.2.0 + - pthread-stubs=0.4 + - py=1.11.0 - pycparser=2.21 - - pyparsing=3.0.4 - - pytest=6.2.5 - - pytest-cov=3.0.0 + - pyparsing=3.1.1 + - pytest=7.4.0 + - pytest-cov=4.1.0 - python=3.9.7 - - python-eccodes=1.6.0 + - python-eccodes=1.5.1 - python_abi=3.9 - - readline=8.1.2 - - setuptools=58.0.4 - - sqlite=3.37.0 - - tk=8.6.11 + - readline=8.2 + - s2n=1.3.48 + - setuptools=68.0.0 + - snappy=1.1.10 + - sqlite=3.42.0 + - tk=8.6.12 - toml=0.10.2 - - tomli=1.2.2 - - tzdata=2021e - - wheel=0.37.1 - - xz=5.2.5 - - zlib=1.2.11 + - tomli=2.0.1 + - tzdata=2023c + - wheel=0.41.1 + - xorg-fixesproto=5.0 + - xorg-inputproto=2.3.2 + - xorg-kbproto=1.0.7 + - xorg-libx11=1.8.6 + - xorg-libxau=1.0.11 + - xorg-libxdmcp=1.1.3 + - xorg-libxext=1.3.4 + - xorg-libxfixes=5.0.3 + - xorg-libxi=1.7.10 + - xorg-xextproto=7.3.0 + - xorg-xproto=7.0.31 + - xz=5.2.6 + - zlib=1.2.13 + - zstd=1.5.2 prefix: /usr/share/miniconda/envs/ubuntu-3.9-minimal From c2a56a209da118e396671b58aa22b76a262b4e25 Mon Sep 17 00:00:00 2001 From: Iain Russell Date: Fri, 18 Aug 2023 14:37:32 +0100 Subject: [PATCH 7/8] Update README so that code snippets pass pytest --- README.rst | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/README.rst b/README.rst index 48519c44..0482d25b 100644 --- a/README.rst +++ b/README.rst @@ -96,7 +96,8 @@ In a Python interpreter try: >>> ds = xr.open_dataset('era5-levels-members.grib', engine='cfgrib') >>> ds -Dimensions: (number: 10, time: 4, isobaricInhPa: 2, latitude: 61, longitude: 120) +Dimensions: (number: 10, time: 4, isobaricInhPa: 2, latitude: 61, + longitude: 120) Coordinates: * number (number) int64 0 1 2 3 4 5 6 7 8 9 * time (time) datetime64[ns] 2017-01-01 ... 2017-01-02T12:00:00 @@ -188,7 +189,8 @@ To translate to the Common Data Model of the Climate Data Store use: >>> import cf2cdm >>> cf2cdm.translate_coords(ds, cf2cdm.CDS) -Dimensions: (realization: 10, forecast_reference_time: 4, plev: 2, lat: 61, lon: 120) +Dimensions: (realization: 10, forecast_reference_time: 4, + plev: 2, lat: 61, lon: 120) Coordinates: * realization (realization) int64 0 1 2 3 4 5 6 7 8 9 * forecast_reference_time (forecast_reference_time) datetime64[ns] 2017-01... @@ -261,7 +263,7 @@ Data variables: crain (y, x) float32 ... cape (y, x) float32 ... cin (y, x) float32 ... - hpbl (y, x) float32 ... + unknown (y, x) float32 ... Attributes: GRIB_edition: 2 GRIB_centre: kwbc @@ -323,7 +325,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -342,7 +344,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -362,7 +364,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -381,7 +383,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -400,7 +402,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (heightAboveGroundLayer: 2, y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -418,7 +420,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (isobaricInhPa: 19, y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -441,7 +443,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (isobaricInhPa: 5, y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -459,7 +461,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -478,7 +480,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -499,7 +501,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -518,7 +520,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (pressureFromGroundLayer: 2, y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -537,7 +539,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (pressureFromGroundLayer: 5, y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -558,7 +560,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -576,7 +578,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -594,7 +596,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -605,6 +607,7 @@ Coordinates: valid_time datetime64[ns] 2018-09-17 Dimensions without coordinates: y, x Data variables: + unknown (y, x) float32 ... cape (y, x) float32 ... sp (y, x) float32 ... acpcp (y, x) float32 ... @@ -616,14 +619,13 @@ Data variables: cicep (y, x) float32 ... csnow (y, x) float32 ... gust (y, x) float32 ... - hpbl (y, x) float32 ... Attributes: GRIB_edition: 2 GRIB_centre: kwbc GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP , + institution: US National Weather Service - NCEP, Dimensions: (y: 65, x: 93) Coordinates: time datetime64[ns] 2018-09-17 @@ -644,7 +646,7 @@ Attributes: GRIB_centreDescription: US National Weather Service - NCEP... GRIB_subCentre: 0 Conventions: CF-1.7 - institution: US National Weather Service - NCEP ] + institution: US National Weather Service - NCEP] Advanced usage From d4e003c237a1f007be990c2cb4fcdf8c28b4eb4c Mon Sep 17 00:00:00 2001 From: Iain Russell Date: Fri, 18 Aug 2023 15:06:57 +0100 Subject: [PATCH 8/8] Add mypy ignore lines to __main__.py --- cfgrib/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cfgrib/__main__.py b/cfgrib/__main__.py index 6f34bfe5..0404c4e6 100644 --- a/cfgrib/__main__.py +++ b/cfgrib/__main__.py @@ -169,9 +169,9 @@ def dump(inpaths, variable, cdm, engine): ds = cf2cdm.translate_coords(ds, coord_model=coord_model) if variable: - ds_or_da = ds[variable] + ds_or_da = ds[variable] # type: ignore else: - ds_or_da = ds + ds_or_da = ds # type: ignore print(ds_or_da)