Contributing¶
Contributions are welcome: bug reports and ideas as GitHub issues, and changes as pull requests.
Development setup¶
git clone https://github.com/rom-py/rompy-xbeach.git
cd rompy-xbeach
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,extra]"
Tests and style¶
pytest # the test suite
ruff check src tests # lint: the rules in ruff.toml are checked in CI
ruff format src tests # format
Test fixtures live in tests/data/. Test each component's parameters, each validator in both directions (accepted and rejected), and the files a data interface writes.
Adding a parameter or component¶
rompy-xbeach components map directly to XBeach parameters (see How rompy-xbeach works). When adding one:
- Put it where XBeach groups it: physics, sediment, output, boundaries, and so on.
- Name the field after the XBeach parameter. If the parameter is not a valid Python name, set it as the field's
alias(e.g.breaktypewithalias="break"). - Default to
Noneso that XBeach's own default applies, and give the XBeach default in the description:description="... (XBeach default: 0.8)". Usege,le,gt,ltandLiteralfor the valid values. - Use a discriminated union for a choice between variants. Each variant has a
model_typeliteral equal to the value XBeach expects; the union field writes it (e.g.wavemodel = surfbeat). - Use
bool | Componentfor a process that can be switched on with defaults or configured. - Use
XBeachDataBlobfor a file.XBeachBaseModel.get()copies it into the workspace and writes the file name under the field name. Components do not overrideget()to handle files. - Check combinations in
Config, do not rewrite them. A setting that depends on another component is checked by a validator onConfig, which raises an error saying what to use instead.
from typing import Optional
from pydantic import Field
from rompy_xbeach.types import XBeachBaseModel
class MyComponent(XBeachBaseModel):
"""What the component configures, in XBeach terms."""
my_param: Optional[float] = Field(
default=None,
description="What it does (XBeach default: 1.0)",
ge=0.0,
le=10.0,
)
The parameter index and the reference pick up new fields automatically.
Documentation¶
The docs are built with ProperDocs (a maintained fork of MkDocs 1.6), Material and mkdocstrings, using the shared configuration from rompy-docs:
pip install -e ".[docs,extra]"
properdocs serve -f mkdocs.yml # live preview
properdocs build --strict -f mkdocs.yml # what CI runs
rompy-docs check -f mkdocs.yml # compare with the shared configuration
- The reference is generated from the docstrings and field descriptions. Write docstrings in numpy style.
-
Examples in docstrings and pages run when the docs are built. Write them as markdown-exec blocks; a failing example fails the strict build. Use a plain
pythonblock only for examples that need a model run or remote data: -
Link classes with
[`Physics`][rompy_xbeach.components.physics.physics.Physics]. rompy classes resolve to the rompy site. - Notebooks live in rompy-notebooks. The Tutorial and Examples pages list them from the inventory that site publishes.
- To build against an unpublished rompy site, set
ROMPY_INVENTORYto itsobjects.inv(a URL, orfile://path).
Pull requests¶
- Create a branch from
output. - Make the change, with tests and docs.
- Run the tests,
ruff checkand the strict docs build. - Add the change to an Unreleased section at the top of the releases in
HISTORY.rst, under Breaking Changes, New Features or Bug Fixes. - Open a pull request.