Skip to content

Commit

Permalink
Pin intake to <v2 (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 committed Feb 6, 2024
1 parent b2c0fa1 commit 14d069c
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 43 deletions.
6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.9"
rev: "v0.2.1"
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
hooks:
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-prettier
Expand Down
2 changes: 1 addition & 1 deletion ci/environment-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- ecgtools >=2022.10.7
- fsspec>=2023.05
- gcsfs >=2023.05
- intake>=0.7
- intake<2.0
- jupyterlab
- matplotlib
- myst-nb
Expand Down
2 changes: 1 addition & 1 deletion ci/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- fsspec>=2022.11.0
- gcsfs >=2022.11.0
- h5netcdf>=0.8.1
- intake>=0.6.6
- intake<2.0
- ipython
- matplotlib
- netcdf4>=1.5.5
Expand Down
64 changes: 32 additions & 32 deletions intake_esm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class esm_datastore(Catalog):
can be accessed with `intake.open_esm_datastore()`:
>>> import intake
>>> url = "https://storage.googleapis.com/cmip6/pangeo-cmip6.json"
>>> url = 'https://storage.googleapis.com/cmip6/pangeo-cmip6.json'
>>> cat = intake.open_esm_datastore(url)
>>> cat.df.head()
activity_id institution_id source_id experiment_id ... variable_id grid_label zstore dcpp_init_year
Expand Down Expand Up @@ -155,7 +155,7 @@ def keys_info(self) -> pd.DataFrame:
--------
>>> import intake
>>> cat = intake.open_esm_datastore("./tests/sample-catalogs/cesm1-lens-netcdf.json")
>>> cat = intake.open_esm_datastore('./tests/sample-catalogs/cesm1-lens-netcdf.json')
>>> cat.keys_info()
component experiment stream
key
Expand Down Expand Up @@ -233,8 +233,8 @@ def __getitem__(self, key: str) -> ESMDataSource:
Examples
--------
>>> cat = intake.open_esm_datastore("mycatalog.json")
>>> data_source = cat["AerChemMIP.BCC.BCC-ESM1.piClim-control.AERmon.gn"]
>>> cat = intake.open_esm_datastore('mycatalog.json')
>>> data_source = cat['AerChemMIP.BCC.BCC-ESM1.piClim-control.AERmon.gn']
"""
# The canonical unique key is the key of a compatible group of assets
try:
Expand Down Expand Up @@ -354,19 +354,19 @@ def search(
Examples
--------
>>> import intake
>>> cat = intake.open_esm_datastore("pangeo-cmip6.json")
>>> cat = intake.open_esm_datastore('pangeo-cmip6.json')
>>> cat.df.head(3)
activity_id institution_id source_id ... grid_label zstore dcpp_init_year
0 AerChemMIP BCC BCC-ESM1 ... gn gs://cmip6/AerChemMIP/BCC/BCC-ESM1/ssp370/r1i1... NaN
1 AerChemMIP BCC BCC-ESM1 ... gn gs://cmip6/AerChemMIP/BCC/BCC-ESM1/ssp370/r1i1... NaN
2 AerChemMIP BCC BCC-ESM1 ... gn gs://cmip6/AerChemMIP/BCC/BCC-ESM1/ssp370/r1i1... NaN
>>> sub_cat = cat.search(
... source_id=["BCC-CSM2-MR", "CNRM-CM6-1", "CNRM-ESM2-1"],
... experiment_id=["historical", "ssp585"],
... variable_id="pr",
... table_id="Amon",
... grid_label="gn",
... source_id=['BCC-CSM2-MR', 'CNRM-CM6-1', 'CNRM-ESM2-1'],
... experiment_id=['historical', 'ssp585'],
... variable_id='pr',
... table_id='Amon',
... grid_label='gn',
... )
>>> sub_cat.df.head(3)
activity_id institution_id source_id ... grid_label zstore dcpp_init_year
Expand All @@ -379,7 +379,7 @@ def search(
>>> import re
>>> # Let's search for variables containing "Frac" in their name
>>> pat = re.compile(r"Frac") # Define a regular expression
>>> pat = re.compile(r'Frac') # Define a regular expression
>>> cat.search(variable_id=pat)
>>> cat.df.head().variable_id
0 residualFrac
Expand Down Expand Up @@ -479,14 +479,14 @@ def serialize(
Examples
--------
>>> import intake
>>> cat = intake.open_esm_datastore("pangeo-cmip6.json")
>>> cat = intake.open_esm_datastore('pangeo-cmip6.json')
>>> cat_subset = cat.search(
... source_id="BCC-ESM1",
... grid_label="gn",
... table_id="Amon",
... experiment_id="historical",
... source_id='BCC-ESM1',
... grid_label='gn',
... table_id='Amon',
... experiment_id='historical',
... )
>>> cat_subset.serialize(name="cmip6_bcc_esm1", catalog_type="file")
>>> cat_subset.serialize(name='cmip6_bcc_esm1', catalog_type='file')
"""

self.esmcat.save(
Expand All @@ -505,7 +505,7 @@ def nunique(self) -> pd.Series:
Examples
--------
>>> import intake
>>> cat = intake.open_esm_datastore("pangeo-cmip6.json")
>>> cat = intake.open_esm_datastore('pangeo-cmip6.json')
>>> cat.nunique()
activity_id 10
institution_id 23
Expand Down Expand Up @@ -583,18 +583,18 @@ def to_dataset_dict(
Examples
--------
>>> import intake
>>> cat = intake.open_esm_datastore("glade-cmip6.json")
>>> cat = intake.open_esm_datastore('glade-cmip6.json')
>>> sub_cat = cat.search(
... source_id=["BCC-CSM2-MR", "CNRM-CM6-1", "CNRM-ESM2-1"],
... experiment_id=["historical", "ssp585"],
... variable_id="pr",
... table_id="Amon",
... grid_label="gn",
... source_id=['BCC-CSM2-MR', 'CNRM-CM6-1', 'CNRM-ESM2-1'],
... experiment_id=['historical', 'ssp585'],
... variable_id='pr',
... table_id='Amon',
... grid_label='gn',
... )
>>> dsets = sub_cat.to_dataset_dict()
>>> dsets.keys()
dict_keys(['CMIP.BCC.BCC-CSM2-MR.historical.Amon.gn', 'ScenarioMIP.BCC.BCC-CSM2-MR.ssp585.Amon.gn'])
>>> dsets["CMIP.BCC.BCC-CSM2-MR.historical.Amon.gn"]
>>> dsets['CMIP.BCC.BCC-CSM2-MR.historical.Amon.gn']
<xarray.Dataset>
Dimensions: (bnds: 2, lat: 160, lon: 320, member_id: 3, time: 1980)
Coordinates:
Expand Down Expand Up @@ -733,16 +733,16 @@ def to_datatree(
Examples
--------
>>> import intake
>>> cat = intake.open_esm_datastore("glade-cmip6.json")
>>> cat = intake.open_esm_datastore('glade-cmip6.json')
>>> sub_cat = cat.search(
... source_id=["BCC-CSM2-MR", "CNRM-CM6-1", "CNRM-ESM2-1"],
... experiment_id=["historical", "ssp585"],
... variable_id="pr",
... table_id="Amon",
... grid_label="gn",
... source_id=['BCC-CSM2-MR', 'CNRM-CM6-1', 'CNRM-ESM2-1'],
... experiment_id=['historical', 'ssp585'],
... variable_id='pr',
... table_id='Amon',
... grid_label='gn',
... )
>>> dsets = sub_cat.to_datatree()
>>> dsets["CMIP/BCC.BCC-CSM2-MR/historical/Amon/gn"].ds
>>> dsets['CMIP/BCC.BCC-CSM2-MR/historical/Amon/gn'].ds
<xarray.Dataset>
Dimensions: (bnds: 2, lat: 160, lon: 320, member_id: 3, time: 1980)
Coordinates:
Expand Down
4 changes: 2 additions & 2 deletions intake_esm/derived.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def load(cls, name: str, package: str = None) -> 'DerivedVariableRegistry':
$PYTHONPATH before calling this function.
>>> import sys
>>> sys.path.insert(0, "/home/foo/pythonfiles")
>>> sys.path.insert(0, '/home/foo/pythonfiles')
>>> from intake_esm.derived import DerivedVariableRegistry
>>> registsry = DerivedVariableRegistry.load("registry")
>>> registsry = DerivedVariableRegistry.load('registry')
"""
modname = importlib.import_module(name, package=package)
candidates = inspect.getmembers(modname, lambda x: isinstance(x, DerivedVariableRegistry))
Expand Down
1 change: 0 additions & 1 deletion intake_esm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class set_options:
>>> cat = intake.open_esm_datastore('catalog.json')
>>> with intake_esm.set_options(attrs_prefix='cat'):
... out = cat.to_dataset_dict()
...
Or to set global options:
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,40 @@ markers = "network: tests requiring a network connection"
[tool.ruff]
line-length = 100
target-version = "py39"
extend-include = ["*.ipynb"]


builtins = ["ellipsis"]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]
[tool.ruff.lint]
per-file-ignores = {}
ignore = [
"E721", # Comparing types instead of isinstance
Expand Down Expand Up @@ -67,6 +78,7 @@ combine-as-imports = true

[tool.ruff.format]
quote-style = "single"
docstring-code-format = true

[tool.ruff.lint.pydocstyle]
convention = "numpy"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dask[complete]>=2022.02.0
fastprogress>=1.0.0
fsspec>=2022.11.0
intake>=0.6.6
intake>=0.6.6,<2
netCDF4>=1.5.5
pandas>=2.1.0
requests>=2.24.0
Expand Down

0 comments on commit 14d069c

Please sign in to comment.