Skip to content

Commit cb9181b

Browse files
authored
Update dependencies and improve import handling for xarray version compatibility (#696)
1 parent c84e1f3 commit cb9181b

File tree

7 files changed

+128
-133
lines changed

7 files changed

+128
-133
lines changed

ci/environment-docs.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ channels:
44
- nodefaults
55
dependencies:
66
- cftime
7-
- dask[complete]>=2022.02.0
7+
- dask>=2024.12
88
- distributed
99
- ecgtools >=2022.10.7
10-
- fsspec>=2023.05
11-
- gcsfs >=2023.05
10+
- fsspec>=2024.12
11+
- gcsfs >=2024.12
1212
- intake>=2.0
1313
- jupyterlab
1414
- matplotlib
@@ -19,13 +19,13 @@ dependencies:
1919
- pydantic>=2.0
2020
- python-graphviz
2121
- python=3.11
22-
- s3fs >=2023.05
22+
- s3fs >=2024.12
2323
- sphinx<6.0
2424
- sphinx-copybutton
2525
- sphinx-design
2626
- watermark
2727
- xarray-datatree>=0.0.9
28-
- xarray>=2023.05
28+
- xarray>=2024.10
2929
- zarr>=2.12
3030
- furo>=2022.09.15
3131
- pip:

ci/environment-upstream-dev.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ dependencies:
66
- cartopy
77
- cftime
88
- codecov
9-
- dask>=2022.02.0
9+
- dask>=2024.12
1010
- fastprogress>=1.0.0
11-
- gcsfs >=2022.11.0
11+
- gcsfs >=2024.12
1212
- h5netcdf>=0.8.1
1313
- ipython
1414
- matplotlib
@@ -28,7 +28,7 @@ dependencies:
2828
- pytest-sugar
2929
- pytest-xdist
3030
- regionmask
31-
- s3fs >=2022.11.0
31+
- s3fs >=2024.12
3232
- scipy
3333
- xarray-datatree
3434
- xgcm

ci/environment.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ channels:
55
dependencies:
66
- cftime
77
- codecov
8-
- dask[complete]>=2022.02.0
8+
- dask>=2024.12
99
- fastprogress>=1.0.0
10-
- fsspec>=2022.11.0
11-
- gcsfs >=2022.11.0
10+
- fsspec>=2024.12
11+
- gcsfs >=2024.12
1212
- h5netcdf>=0.8.1
1313
- intake>=2.0
1414
- ipython
@@ -25,9 +25,9 @@ dependencies:
2525
- pytest-sugar
2626
- pytest-xdist
2727
- pytest-mock
28-
- s3fs >=2022.11.0
28+
- s3fs >=2024.12
2929
- scipy
30-
- xarray>=2022.06, !=2024.10
30+
- xarray>=2024.10
3131
- xarray-datatree
3232
- zarr>=2.12
3333
# - pytest-icdiff

intake_esm/core.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@
55
from copy import deepcopy
66

77
import dask
8+
import packaging.version
9+
import xarray as xr
810

911
try:
10-
from datatree import DataTree
11-
12+
if packaging.version.Version(xr.__version__) < packaging.version.Version('2024.10'):
13+
from datatree import DataTree
14+
else:
15+
from xarray import DataTree
1216
_DATATREE_AVAILABLE = True
1317
except ImportError:
1418
_DATATREE_AVAILABLE = False
1519
import pandas as pd
1620
import pydantic
17-
import xarray as xr
1821
from fastprogress.fastprogress import progress_bar
1922
from intake.catalog import Catalog
2023

@@ -81,9 +84,9 @@ def __init__(
8184
progressbar: bool = True,
8285
sep: str = '.',
8386
registry: DerivedVariableRegistry | None = None,
84-
read_csv_kwargs: dict[str, typing.Any] = None,
85-
columns_with_iterables: list[str] = None,
86-
storage_options: dict[str, typing.Any] = None,
87+
read_csv_kwargs: dict[str, typing.Any] | None = None,
88+
columns_with_iterables: list[str] | None = None,
89+
storage_options: dict[str, typing.Any] | None = None,
8790
**intake_kwargs: dict[str, typing.Any],
8891
):
8992
"""Intake Catalog representing an ESM Collection."""

pyproject.toml

Lines changed: 97 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,126 @@
11
[build-system]
2-
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
2+
requires = ["setuptools>=45", "setuptools_scm>=6.2", "wheel"]
33

44
[project]
5-
name = "intake-esm"
6-
description = "An intake plugin for parsing an Earth System Model (ESM) catalog and loading netCDF files and/or Zarr stores into Xarray datasets."
7-
readme = "README.md"
8-
license = {text="Apache Software License 2.0"}
9-
requires-python = ">=3.10"
10-
maintainers = [
11-
{ name = "NCAR XDev Team", email = "xdev@ucar.edu" },
12-
]
13-
keywords = [
14-
"catalog",
15-
"intake",
16-
"xarray",
17-
]
18-
classifiers = [
19-
"Development Status :: 4 - Beta",
20-
"Intended Audience :: Science/Research",
21-
"License :: OSI Approved :: Apache Software License",
22-
"Operating System :: OS Independent",
23-
"Programming Language :: Python",
24-
"Programming Language :: Python :: 3",
25-
"Programming Language :: Python :: 3.10",
26-
"Programming Language :: Python :: 3.11",
27-
"Programming Language :: Python :: 3.12",
28-
"Topic :: Scientific/Engineering",
29-
]
30-
31-
dynamic = ["version", "dependencies"]
5+
classifiers = [
6+
"Development Status :: 4 - Beta",
7+
"Intended Audience :: Science/Research",
8+
"License :: OSI Approved :: Apache Software License",
9+
"Operating System :: OS Independent",
10+
"Programming Language :: Python :: 3",
11+
"Programming Language :: Python :: 3.10",
12+
"Programming Language :: Python :: 3.11",
13+
"Programming Language :: Python :: 3.12",
14+
"Programming Language :: Python",
15+
"Topic :: Scientific/Engineering",
16+
]
17+
description = "An intake plugin for parsing an Earth System Model (ESM) catalog and loading netCDF files and/or Zarr stores into Xarray datasets."
18+
keywords = ["catalog", "intake", "xarray"]
19+
license = { text = "Apache Software License 2.0" }
20+
maintainers = [{ name = "NCAR XDev Team", email = "xdev@ucar.edu" }]
21+
name = "intake-esm"
22+
readme = "README.md"
23+
requires-python = ">=3.10"
24+
25+
dynamic = ["dependencies", "version"]
3226

3327
[tool.setuptools.dynamic]
3428

35-
dependencies = { file = ["requirements.txt"] }
36-
optional-dependencies = { dev = { file = ["requirements-dev.txt"] } }
29+
dependencies = { file = ["requirements.txt"] }
30+
optional-dependencies = { dev = { file = ["requirements-dev.txt"] } }
3731

3832
[project.entry-points."intake.drivers"]
39-
esm_datasource = "intake_esm.source:ESMDataSource"
40-
esm_datastore = "intake_esm.core:esm_datastore"
33+
esm_datasource = "intake_esm.source:ESMDataSource"
34+
esm_datastore = "intake_esm.core:esm_datastore"
4135

4236
[project.urls]
43-
Documentation = "https://intake-esm.readthedocs.io"
44-
Homepage = "https://intake-esm.readthedocs.io"
45-
Source = "https://github.com/intake/intake-esm"
46-
Tracker = "https://github.com/intake/intake-esm/issues"
47-
37+
Documentation = "https://intake-esm.readthedocs.io"
38+
Homepage = "https://intake-esm.readthedocs.io"
39+
Source = "https://github.com/intake/intake-esm"
40+
Tracker = "https://github.com/intake/intake-esm/issues"
4841

4942
[tool.setuptools.packages.find]
50-
include = ["intake_esm*"]
43+
include = ["intake_esm*"]
5144

5245
[tool.setuptools.package-data]
53-
intake_esm = ["py.typed"]
54-
55-
46+
intake_esm = ["py.typed"]
5647

5748
[tool.setuptools_scm]
58-
version_scheme = "post-release"
59-
local_scheme = "node-and-date"
60-
fallback_version = "999"
61-
write_to = "intake_esm/_version.py"
62-
write_to_template = '__version__ = "{version}"'
63-
64-
49+
fallback_version = "999"
50+
local_scheme = "node-and-date"
51+
version_scheme = "post-release"
52+
write_to = "intake_esm/_version.py"
53+
write_to_template = '__version__ = "{version}"'
6554

6655
[tool.ruff]
67-
line-length = 100
68-
target-version = "py310"
69-
extend-include = ["*.ipynb"]
70-
71-
72-
builtins = ["ellipsis"]
73-
# Exclude a variety of commonly ignored directories.
74-
exclude = [
75-
".bzr",
76-
".direnv",
77-
".eggs",
78-
".git",
79-
".git-rewrite",
80-
".hg",
81-
".ipynb_checkpoints",
82-
".mypy_cache",
83-
".nox",
84-
".pants.d",
85-
".pyenv",
86-
".pytest_cache",
87-
".pytype",
88-
".ruff_cache",
89-
".svn",
90-
".tox",
91-
".venv",
92-
".vscode",
93-
"__pypackages__",
94-
"_build",
95-
"buck-out",
96-
"build",
97-
"dist",
98-
"node_modules",
99-
"site-packages",
100-
"venv",
101-
]
56+
extend-include = ["*.ipynb"]
57+
line-length = 100
58+
target-version = "py310"
59+
60+
builtins = ["ellipsis"]
61+
# Exclude a variety of commonly ignored directories.
62+
exclude = [
63+
".bzr",
64+
".direnv",
65+
".eggs",
66+
".git",
67+
".git-rewrite",
68+
".hg",
69+
".ipynb_checkpoints",
70+
".mypy_cache",
71+
".nox",
72+
".pants.d",
73+
".pyenv",
74+
".pytest_cache",
75+
".pytype",
76+
".ruff_cache",
77+
".svn",
78+
".tox",
79+
".venv",
80+
".vscode",
81+
"__pypackages__",
82+
"_build",
83+
"buck-out",
84+
"build",
85+
"dist",
86+
"node_modules",
87+
"site-packages",
88+
"venv",
89+
]
10290
[tool.ruff.lint]
103-
per-file-ignores = {}
104-
ignore = [
105-
"E721", # Comparing types instead of isinstance
106-
"E741", # Ambiguous variable names
107-
"E501", # Conflicts with ruff format
108-
]
109-
select = [
110-
# Pyflakes
111-
"F",
112-
# Pycodestyle
113-
"E",
114-
"W",
115-
# isort
116-
"I",
117-
# Pyupgrade
118-
"UP",
119-
]
120-
91+
ignore = [
92+
"E501", # Conflicts with ruff format
93+
"E721", # Comparing types instead of isinstance
94+
"E741", # Ambiguous variable names
95+
]
96+
per-file-ignores = {}
97+
select = [
98+
# Pyflakes
99+
"F",
100+
# Pycodestyle
101+
"E",
102+
"W",
103+
# isort
104+
"I",
105+
# Pyupgrade
106+
"UP",
107+
]
121108

122109
[tool.ruff.lint.mccabe]
123-
max-complexity = 18
110+
max-complexity = 18
124111

125112
[tool.ruff.lint.isort]
126-
known-first-party = ["intake_esm"]
127-
combine-as-imports = true
113+
combine-as-imports = true
114+
known-first-party = ["intake_esm"]
128115

129116
[tool.ruff.format]
130-
quote-style = "single"
131-
docstring-code-format = true
117+
docstring-code-format = true
118+
quote-style = "single"
132119

133120
[tool.ruff.lint.pydocstyle]
134-
convention = "numpy"
121+
convention = "numpy"
135122

136123
[tool.pytest.ini_options]
137-
console_output_style = "count"
138-
addopts = "--cov=./ --cov-report=xml --verbose"
139-
markers = "network: tests requiring a network connection"
124+
addopts = "--cov=./ --cov-report=xml --verbose"
125+
console_output_style = "count"
126+
markers = "network: tests requiring a network connection"

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
dask[complete]>=2022.02.0
1+
dask[complete]>=2024.12
22
fastprogress>=1.0.0
3-
fsspec>=2022.11.0
3+
fsspec>=2024.12
44
intake>=2.0.0
55
netCDF4>=1.5.5
66
pandas>=2.1.0
77
requests>=2.24.0
8-
xarray>=2022.06
8+
xarray>=2024.10
99
zarr>=2.12
1010
pydantic>=2.0

tests/test_core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
import os
33

44
import intake
5+
import packaging.version
56
import pandas as pd
67
import pydantic
78
import pytest
89
import xarray as xr
9-
from datatree import DataTree
10+
11+
if packaging.version.Version(xr.__version__) < packaging.version.Version('2024.10'):
12+
from datatree import DataTree
13+
else:
14+
from xarray import DataTree
1015

1116
import intake_esm
1217

0 commit comments

Comments
 (0)