|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +Guidance for working in this repository. |
| 4 | + |
| 5 | +## What this is |
| 6 | + |
| 7 | +`pyo_oracle` is the Python client for the **Bio-ORACLE** ERDDAP server |
| 8 | +(<https://erddap.bio-oracle.org/erddap/>). It is the Python counterpart of the R |
| 9 | +package [`biooracler`](https://github.com/bio-oracle/biooracler) and is built on |
| 10 | +top of [`erddapy`](https://github.com/ioos/erddapy). |
| 11 | + |
| 12 | +## Layout |
| 13 | + |
| 14 | +- `pyo_oracle/__init__.py` — public namespace; re-exports the API. |
| 15 | +- `pyo_oracle/main.py` — public functions: `list_layers`, `info_layer`, |
| 16 | + `load_layer`, `download_layers`, `list_local_data`. |
| 17 | +- `pyo_oracle/utils.py` — internals: `_build_griddap_server` (the single shared |
| 18 | + griddap setup path), `_layer_info`, `_layer_dataframe`, `build_constraints`, |
| 19 | + `_as_bool`, download helpers. |
| 20 | +- `pyo_oracle/_config.py` — configparser-based config (data dir, server URL, |
| 21 | + `skip_confirmation`). `config.ini` is generated and git-ignored. |
| 22 | +- `tests/` — `test_utils.py` (offline), `test_main.py` (mostly live), `test_config.py`. |
| 23 | +- `docs/` + `mkdocs.yml` — MkDocs Material site (mkdocstrings API ref). |
| 24 | + |
| 25 | +## Public API parity with `biooracler` |
| 26 | + |
| 27 | +`list_layers`, `info_layer`, `download_layers` mirror the R package. Python adds |
| 28 | +`load_layer` (in-memory pandas/xarray) and `build_constraints` (friendly |
| 29 | +subsetting helper). |
| 30 | + |
| 31 | +## Dev environment |
| 32 | + |
| 33 | +All development happens in the conda env named **`pyo_oracle`**: |
| 34 | + |
| 35 | +```bash |
| 36 | +conda env create -n pyo_oracle -f environment-dev.yaml # or `mamba` |
| 37 | +conda activate pyo_oracle |
| 38 | +pip install -e ".[dev,xarray,docs]" |
| 39 | +``` |
| 40 | + |
| 41 | +## Tests |
| 42 | + |
| 43 | +Two kinds, separated by the `integration` marker: |
| 44 | + |
| 45 | +```bash |
| 46 | +pytest -m "not integration" # offline unit tests (fast, used in CI by default) |
| 47 | +pytest # full suite incl. tests that hit the live server |
| 48 | +pytest -m integration # only the live-server tests |
| 49 | +``` |
| 50 | + |
| 51 | +The exit goal for changes is a **fully green `pytest`** in the `pyo_oracle` env. |
| 52 | + |
| 53 | +## Lint & docs |
| 54 | + |
| 55 | +```bash |
| 56 | +ruff check pyo_oracle tests |
| 57 | +mkdocs serve # live preview |
| 58 | +mkdocs build --strict # must pass (CI deploys to GitHub Pages) |
| 59 | +``` |
| 60 | + |
| 61 | +## Release flow |
| 62 | + |
| 63 | +1. Bump `version` in `pyproject.toml` and update `CHANGELOG.md`. |
| 64 | +2. Ensure `pytest`, `ruff`, and `mkdocs build --strict` pass. |
| 65 | +3. `python -m build` and inspect the artifacts. |
| 66 | +4. Push a tag — `.github/workflows/pypi-publish.yml` builds and publishes to PyPI |
| 67 | + (package name `pyo-oracle`). |
| 68 | + |
| 69 | +## Gotchas |
| 70 | + |
| 71 | +- **erddapy private API**: `_build_griddap_server` relies on |
| 72 | + `ERDDAP._constraints_original`. It is guarded with `getattr`/`hasattr` but |
| 73 | + watch this if bumping erddapy (verified against erddapy 3.2.x). |
| 74 | +- Requires `erddapy>=2.2`, `pandas>=2.0`, Python `>=3.9`. xarray loading needs |
| 75 | + the optional `xarray` extra (`xarray` + `netCDF4`). |
| 76 | +- `download_layers` with no constraints downloads the entire global layer and |
| 77 | + prompts for confirmation unless `skip_confirmation=True`. |
0 commit comments