Skip to content

Commit d2e84d2

Browse files
committed
Merge branch 'main' into fix_s3_start_byte
2 parents 93711b7 + 1083c9d commit d2e84d2

30 files changed

+854
-222
lines changed

.github/workflows/ci-additional.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,64 @@ jobs:
134134
name: codecov-umbrella
135135
fail_ci_if_error: false
136136

137+
mypy38:
138+
name: Mypy 3.8
139+
runs-on: "ubuntu-latest"
140+
needs: detect-ci-trigger
141+
# temporarily skipping due to https://github.com/pydata/xarray/issues/6551
142+
if: needs.detect-ci-trigger.outputs.triggered == 'false'
143+
defaults:
144+
run:
145+
shell: bash -l {0}
146+
env:
147+
CONDA_ENV_FILE: ci/requirements/environment.yml
148+
PYTHON_VERSION: "3.8"
149+
150+
steps:
151+
- uses: actions/checkout@v3
152+
with:
153+
fetch-depth: 0 # Fetch all history for all branches and tags.
154+
155+
- name: set environment variables
156+
run: |
157+
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
158+
- name: Setup micromamba
159+
uses: mamba-org/provision-with-micromamba@v14
160+
with:
161+
environment-file: ${{env.CONDA_ENV_FILE}}
162+
environment-name: xarray-tests
163+
extra-specs: |
164+
python=${{env.PYTHON_VERSION}}
165+
conda
166+
cache-env: true
167+
cache-env-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
168+
- name: Install xarray
169+
run: |
170+
python -m pip install --no-deps -e .
171+
- name: Version info
172+
run: |
173+
conda info -a
174+
conda list
175+
python xarray/util/print_versions.py
176+
- name: Install mypy
177+
run: |
178+
python -m pip install 'mypy<0.990'
179+
180+
- name: Run mypy
181+
run: |
182+
python -m mypy --install-types --non-interactive --cobertura-xml-report mypy_report
183+
184+
- name: Upload mypy coverage to Codecov
185+
uses: codecov/codecov-action@v3.1.1
186+
with:
187+
file: mypy_report/cobertura.xml
188+
flags: mypy38
189+
env_vars: PYTHON_VERSION
190+
name: codecov-umbrella
191+
fail_ci_if_error: false
192+
193+
194+
137195
min-version-policy:
138196
name: Minimum Version Policy
139197
runs-on: "ubuntu-latest"

.github/workflows/upstream-dev-ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ jobs:
8080
if: success()
8181
id: status
8282
run: |
83+
export ZARR_V3_EXPERIMENTAL_API=1
8384
python -m pytest --timeout=60 -rf \
8485
--report-log output-${{ matrix.python-version }}-log.jsonl
8586
- name: Generate and publish the report

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ repos:
4747
# - id: velin
4848
# args: ["--write", "--compact"]
4949
- repo: https://github.com/pre-commit/mirrors-mypy
50-
rev: v0.990
50+
rev: v0.991
5151
hooks:
5252
- id: mypy
5353
# Copied from setup.cfg

ci/requirements/all-but-dask.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ dependencies:
3030
- pip
3131
- pseudonetcdf
3232
- pydap
33-
# - pynio # not compatible with netCDF4>1.5.3, see #4491
3433
- pytest
3534
- pytest-cov
3635
- pytest-env

ci/requirements/environment-windows.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ dependencies:
3030
- pre-commit
3131
- pseudonetcdf
3232
- pydap
33-
# - pynio # Not available on Windows
3433
- pytest
3534
- pytest-cov
3635
- pytest-env

ci/requirements/environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ dependencies:
3434
- pre-commit
3535
- pseudonetcdf
3636
- pydap
37-
# - pynio # not compatible with netCDF4>1.5.3, see #4491
3837
- pytest
3938
- pytest-cov
4039
- pytest-env

ci/requirements/min-all-deps.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ dependencies:
4040
- pip
4141
- pseudonetcdf=3.2
4242
- pydap=3.2
43-
# - pynio=1.5.5 # see: https://github.com/pydata/xarray/issues/4491
4443
- pytest
4544
- pytest-cov
4645
- pytest-env

doc/user-guide/io.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,10 @@ We recommend installing cfgrib via conda::
12091209
Formats supported by PyNIO
12101210
--------------------------
12111211

1212+
.. warning::
1213+
1214+
The PyNIO backend is deprecated_. PyNIO is no longer maintained_. See
1215+
12121216
Xarray can also read GRIB, HDF4 and other file formats supported by PyNIO_,
12131217
if PyNIO is installed. To use PyNIO to read such files, supply
12141218
``engine='pynio'`` to :py:func:`open_dataset`.
@@ -1217,12 +1221,9 @@ We recommend installing PyNIO via conda::
12171221

12181222
conda install -c conda-forge pynio
12191223

1220-
.. warning::
1221-
1222-
PyNIO is no longer actively maintained and conflicts with netcdf4 > 1.5.3.
1223-
The PyNIO backend may be moved outside of xarray in the future.
1224-
12251224
.. _PyNIO: https://www.pyngl.ucar.edu/Nio.shtml
1225+
.. _deprecated: https://github.com/pydata/xarray/issues/4491
1226+
.. _maintained: https://github.com/NCAR/pynio/issues/53
12261227

12271228
.. _io.PseudoNetCDF:
12281229

doc/whats-new.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@ What's New
1414
1515
np.random.seed(123456)
1616
17-
1817
.. _whats-new.2022.11.1:
1918

2019
v2022.11.1 (unreleased)
2120
-----------------------
2221

2322
New Features
2423
~~~~~~~~~~~~
25-
24+
- Enable using `offset` and `origin` arguments in :py:meth:`DataArray.resample`
25+
and :py:meth:`Dataset.resample` (:issue:`7266`, :pull:`6538`). By `Spencer
26+
Clark <https://github.com/spencerkclark>`_.
27+
- Add experimental support for Zarr's in-progress V3 specification. (:pull:`6475`).
28+
By `Gregory Lee <https://github.com/grlee77>`_ and `Joe Hamman <https://github.com/jhamman>`_.
2629

2730
Breaking changes
2831
~~~~~~~~~~~~~~~~
@@ -49,13 +52,16 @@ Breaking changes
4952

5053
Deprecations
5154
~~~~~~~~~~~~
52-
55+
- The PyNIO backend has been deprecated (:issue:`4491`, :pull:`7301`).
56+
By `Joe Hamman <https://github.com/jhamman>`_.
5357

5458
Bug fixes
5559
~~~~~~~~~
5660

5761
- Import ``nc_time_axis`` when needed (:issue:`7275`, :pull:`7276`).
5862
By `Michael Niklas <https://github.com/headtr1ck>`_.
63+
- Fix static typing of :py:meth:`xr.polyval` (:issue:`7312`, :pull:`7315`).
64+
By `Michael Niklas <https://github.com/headtr1ck>`_.
5965
- Fix multiple reads on fsspec S3 files by resetting file pointer to 0 when reading file streams (:issue:`6813`, :pull:`7304`).
6066
By `David Hoese <https://github.com/djhoese>`_ and `Wei Ji Leong <https://github.com/weiji14>`_.
6167

pyproject.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ module = [
4040
"cfgrib.*",
4141
"cftime.*",
4242
"cupy.*",
43-
"dask.*",
44-
"distributed.*",
4543
"fsspec.*",
4644
"h5netcdf.*",
4745
"h5py.*",
@@ -52,11 +50,9 @@ module = [
5250
"Nio.*",
5351
"nc_time_axis.*",
5452
"numbagg.*",
55-
"numpy.*",
5653
"netCDF4.*",
5754
"netcdftime.*",
5855
"pandas.*",
59-
"pint.*",
6056
"pooch.*",
6157
"PseudoNetCDF.*",
6258
"pydap.*",
@@ -70,8 +66,6 @@ module = [
7066
"zarr.*",
7167
]
7268

73-
# version spanning code is hard to type annotate (and most of this module will
74-
# be going away soon anyways)
7569
[[tool.mypy.overrides]]
7670
ignore_errors = true
77-
module = "xarray.core.pycompat"
71+
module = []

setup.cfg

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,12 @@ markers =
147147

148148
[flake8]
149149
ignore =
150-
E203 # whitespace before ':' - doesn't work well with black
151-
E402 # module level import not at top of file
152-
E501 # line too long - let black worry about that
153-
E731 # do not assign a lambda expression, use a def
154-
W503 # line break before binary operator
150+
# E203: whitespace before ':' - doesn't work well with black
151+
# E402: module level import not at top of file
152+
# E501: line too long - let black worry about that
153+
# E731: do not assign a lambda expression, use a def
154+
# W503: line break before binary operator
155+
E203, E402, E501, E731, W503
155156
exclude =
156157
.eggs
157158
doc

xarray/backends/api.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
TYPE_CHECKING,
1010
Any,
1111
Callable,
12+
Dict,
1213
Final,
1314
Hashable,
1415
Iterable,
@@ -62,7 +63,7 @@
6263
str, # no nice typing support for custom backends
6364
None,
6465
]
65-
T_Chunks = Union[int, dict[Any, Any], Literal["auto"], None]
66+
T_Chunks = Union[int, Dict[Any, Any], Literal["auto"], None]
6667
T_NetcdfTypes = Literal[
6768
"NETCDF4", "NETCDF4_CLASSIC", "NETCDF3_64BIT", "NETCDF3_CLASSIC"
6869
]
@@ -1503,6 +1504,7 @@ def to_zarr(
15031504
region: Mapping[str, slice] | None = None,
15041505
safe_chunks: bool = True,
15051506
storage_options: dict[str, str] | None = None,
1507+
zarr_version: int | None = None,
15061508
) -> backends.ZarrStore:
15071509
...
15081510

@@ -1524,6 +1526,7 @@ def to_zarr(
15241526
region: Mapping[str, slice] | None = None,
15251527
safe_chunks: bool = True,
15261528
storage_options: dict[str, str] | None = None,
1529+
zarr_version: int | None = None,
15271530
) -> Delayed:
15281531
...
15291532

@@ -1542,6 +1545,7 @@ def to_zarr(
15421545
region: Mapping[str, slice] | None = None,
15431546
safe_chunks: bool = True,
15441547
storage_options: dict[str, str] | None = None,
1548+
zarr_version: int | None = None,
15451549
) -> backends.ZarrStore | Delayed:
15461550
"""This function creates an appropriate datastore for writing a dataset to
15471551
a zarr ztore
@@ -1608,6 +1612,13 @@ def to_zarr(
16081612
f"``region`` with to_zarr(), got {append_dim} in both"
16091613
)
16101614

1615+
if zarr_version is None:
1616+
# default to 2 if store doesn't specify it's version (e.g. a path)
1617+
zarr_version = int(getattr(store, "_store_version", 2))
1618+
1619+
if consolidated is None and zarr_version > 2:
1620+
consolidated = False
1621+
16111622
if mode == "r+":
16121623
already_consolidated = consolidated
16131624
consolidate_on_close = False
@@ -1626,6 +1637,7 @@ def to_zarr(
16261637
write_region=region,
16271638
safe_chunks=safe_chunks,
16281639
stacklevel=4, # for Dataset.to_zarr()
1640+
zarr_version=zarr_version,
16291641
)
16301642

16311643
if mode in ["a", "r+"]:

xarray/backends/pynio_.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import warnings
4+
35
import numpy as np
46

57
from ..core import indexing
@@ -55,6 +57,12 @@ class NioDataStore(AbstractDataStore):
5557
def __init__(self, filename, mode="r", lock=None, **kwargs):
5658
import Nio
5759

60+
warnings.warn(
61+
"The PyNIO backend is Deprecated and will be removed from Xarray in a future release. "
62+
"See https://github.com/pydata/xarray/issues/4491 for more information",
63+
DeprecationWarning,
64+
)
65+
5866
if lock is None:
5967
lock = PYNIO_LOCK
6068
self.lock = ensure_lock(lock)
@@ -94,6 +102,15 @@ def close(self):
94102

95103

96104
class PynioBackendEntrypoint(BackendEntrypoint):
105+
"""
106+
PyNIO backend
107+
108+
.. deprecated:: 0.20.0
109+
110+
Deprecated as PyNIO is no longer supported. See
111+
https://github.com/pydata/xarray/issues/4491 for more information
112+
"""
113+
97114
available = module_available("Nio")
98115

99116
def open_dataset(

0 commit comments

Comments
 (0)