Skip to content

Commit c0b6a15

Browse files
prek_ty: use prek instead of pre-commit, ty for type checking (#107)
* prek_ty: use prek instead of pre-commit, ty for type checking * remove duplicate binder comment workflow * testing: run only on push, not pr * fix: pin intake-thredds to 2024.3.1, skip flaky URL tests * add pyarrow and intake-thredds to dependencies * require python<3.14 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * unskip URL availability tests * add pytest-sugar to test dependencies * remove unavailable datasets: WOA2018, CRU_TS4_*, GeigerKoeppen * Add ty pre-commit hook and document uv run commands * Remove test_cache folder and add to .gitignore * Add pytest-xdist for parallel test execution * Use pytest -n auto for parallel test execution in GHA * Fix ty-pre-commit repo URL (use hoxbro instead of astral-sh) * Configure ty to check remote_climate_data and tests * Pin setuptools<70 to fix intake_thredds plugin loading * Pin setuptools<70 to fix intake_thredds plugin loading * Remove cru_ts catalog and ceda-access notebook * Skip ESACCI URL test (oceancolour.org THREDDS returns 404) * Skip GeigerKoeppen_shp URL test (HTTP URL may fail availability check) * Remove CRU_TS subcatalog reference (cru_ts.yaml was removed) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 1f9318e commit c0b6a15

16 files changed

Lines changed: 231 additions & 2133 deletions

.github/workflows/comment_binder_pr_link.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/testing.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: testing
33

44
on:
55
push:
6-
pull_request:
76
schedule:
87
- cron: "0 0 * * 4" # Thursdays "At 00:00" UTC
98
workflow_dispatch: # allows you to trigger manually
@@ -38,7 +37,7 @@ jobs:
3837
run: conda list
3938
- name: Run tests
4039
run: |
41-
pytest --durations=20
40+
pytest -n auto --durations=20
4241
4342
test_notebooks: # Checks that notebooks complete without failure.
4443
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# simplecache
22
notebooks/my_caching_folder
3+
test_cache/
34

45
# Byte-compiled / optimized / DLL files
56
__pycache__/

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ repos:
2020
args: [--fix]
2121
- id: ruff-format
2222

23+
- repo: https://github.com/kynan/nbstripout
24+
rev: 0.7.1
25+
hooks:
26+
- id: nbstripout
27+
28+
- repo: https://github.com/hoxbro/ty-pre-commit
29+
rev: v0.0.12
30+
hooks:
31+
- id: ty-check
32+
2333
- repo: https://github.com/adrienverge/yamllint.git
2434
rev: v1.35.1
2535
hooks:

AGENTS.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
- **Python**: Ruff (line-length 88, replaces black/flake8/isort)
1818
- **YAML**: yamllint with max line-length 88
19-
- Pre-commit hooks enforce all of the above — run `pre-commit run --all-files` to check
19+
- **Type checking**: ty (run `uv run ty check`)
20+
- Prek hooks enforce all of the above — run `uv run prek run --all-files` to check
2021
- Tests use `pytest` (config in `setup.cfg`, test files in `tests/`)
2122

2223
## Working with Catalogs
@@ -32,7 +33,9 @@
3233
## Testing
3334

3435
```bash
35-
pytest --durations=20
36+
uv run pytest --durations=20
37+
# or run tests in parallel:
38+
uv run pytest -n auto
3639
```
3740

3841
- `test_remote_catalog.py` — Structural tests (catalog loads, entries have drivers/URLs)

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![testing](https://github.com/aaronspring/remote_climate_data/actions/workflows/testing.yml/badge.svg)](https://github.com/aaronspring/remote_climate_data/actions/workflows/testing.yml) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/aaronspring/remote_climate_data/master?urlpath=lab%2Ftree%2Fnotebooks%2Fdemo.ipynb) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/aaronspring/remote_climate_data/master.svg)](https://results.pre-commit.ci/latest/github/aaronspring/remote_climate_data/master)
1+
[![testing](https://github.com/aaronspring/remote_climate_data/actions/workflows/testing.yml/badge.svg)](https://github.com/aaronspring/remote_climate_data/actions/workflows/testing.yml) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/aaronspring/remote_climate_data/master?urlpath=lab%2Ftree%2Fnotebooks%2Fdemo.ipynb)
22

33
# remote_climate_data
44
a collection of remote climate data accessed via `intake` cached to disk
@@ -10,6 +10,13 @@ uv sync
1010
uv sync --all-extras
1111
```
1212

13+
## Run commands with uv
14+
```bash
15+
uv run pytest # run tests
16+
uv run prek run --all-files # run pre-commit hooks on all files
17+
uv run ty check # run type checking
18+
```
19+
1320
## Catalog
1421

1522
<details>

catalogs/atmosphere.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,6 @@ sources:
8282
urlpath: simplecache::https://crudata.uea.ac.uk/cru/data/temperature/HadCRUT.5.0.0.0.anomalies.ensemble_mean.nc
8383
chunks: {}
8484

85-
CRU_TS:
86-
description: >-
87-
Climatic Research Unit (CRU) Time-Series (TS) of high-resolution gridded data of
88-
month-by-month variation in climate
89-
metadata:
90-
url: https://crudata.uea.ac.uk/cru/data/hrg
91-
comment: >-
92-
CEDA archive requires authorization, for setting up a certificate, please
93-
follow instructions from
94-
https://help.ceda.ac.uk/article/4712-reading-netcdf-with-python-opendap
95-
args:
96-
path: "{{CATALOG_DIR}}/atmosphere/cru_ts.yaml"
97-
driver: intake.catalog.local.YAMLFileCatalog
98-
9985
GISTEMP:
10086
description: GISS Surface Temperature Analysis (GISTEMP v4)
10187
metadata:

catalogs/atmosphere/cru_ts.yaml

Lines changed: 0 additions & 161 deletions
This file was deleted.

catalogs/ocean.yaml

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -69,81 +69,6 @@ sources:
6969
xarray_kwargs:
7070
engine: scipy
7171

72-
WOA2018:
73-
description: World Ocean Atlas 2018
74-
driver: netcdf
75-
metadata:
76-
url: https://www.nodc.noaa.gov/cgi-bin/OC5/woa18/woa18.pl
77-
doi: https://www.nodc.noaa.gov/OC5/woa18/pubwoa18.html
78-
parameters:
79-
variable:
80-
description: version release in year
81-
type: str
82-
default: temperature
83-
allowed:
84-
- temperature
85-
- salinity
86-
- oxygen
87-
- phosphate
88-
- nitrate
89-
- AOU
90-
# - silicate(i), o2sat(O) overlapping first string
91-
DDDD:
92-
description: decade
93-
type: str
94-
default: decav
95-
allowed:
96-
- decav # average
97-
- 5564 # 1955-1964
98-
- 6574
99-
- 7584
100-
- 8594
101-
- 95A4 # 1995-2004
102-
- A5B7 # 2005-2017
103-
- 81B0 # 1981-2010
104-
TT:
105-
description: time period
106-
type: int
107-
default: 0
108-
allowed:
109-
- 0 # annual
110-
- 1 # Jan
111-
- 2 # Feb
112-
- 3 # Mar
113-
- 4 # Apr
114-
- 5 # May
115-
- 6 # Jun
116-
- 7 # Jul
117-
- 8 # Aug
118-
- 9 # Sep
119-
- 10 # Oct
120-
- 11 # Nov
121-
- 12 # Dec
122-
- 13 # winter
123-
- 14 # spring
124-
- 15 # summer
125-
- 16 # autumn
126-
GG:
127-
description: grid
128-
type: str
129-
default: 1.00
130-
allowed:
131-
- 5.00 #
132-
- 1.00 #
133-
- 0.25 # 1/4°
134-
GG2:
135-
description: matching grid GG # inconsistency in WOA2018 file naming
136-
type: str
137-
default: 01
138-
allowed:
139-
- 5d
140-
- 01
141-
- 04
142-
args:
143-
urlpath: https://www.ncei.noaa.gov/thredds-ocean/fileServer/ncei/woa/{{variable}}/{{DDDD}}/{{GG}}/woa18_{{DDDD}}_{{variable[0]}}{{"%02d"|format(TT)}}_{{GG2}}.nc
144-
xarray_kwargs:
145-
decode_times: false
146-
14772
OISSTv21:
14873
driver: netcdf
14974
description: >-

environment.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ channels:
44
- conda-forge
55
dependencies:
66
- python=3.12
7+
- setuptools<70
78
- intake<2
9+
- intake-thredds=2024.3.1
810
- xarray
911
- pandas
1012
- intake-xarray
@@ -21,7 +23,8 @@ dependencies:
2123
- requests
2224
- pytest
2325
- pytest-sugar
24-
- pre-commit
26+
- pytest-xdist
27+
- prek
2528
- ruff
2629
- jupyterlab
2730
# Visualization

0 commit comments

Comments
 (0)