Skip to content

Commit

Permalink
add missing node types to Python API docs (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
visr authored Oct 27, 2023
1 parent cf4bce9 commit afe1bcc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
10 changes: 8 additions & 2 deletions docs/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ quartodoc:
contents:
- Basin
- FractionalFlow
- TabulatedRatingCurve
- Pump
- Outlet
- User
- LevelBoundary
- FlowBoundary
- LinearResistance
- ManningResistance
- Pump
- TabulatedRatingCurve
- Terminal
- DiscreteControl
- PidControl
- title: Utility functions
desc: Collection of utility functions.
contents:
Expand Down
20 changes: 9 additions & 11 deletions docs/contribute/addnode.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -239,26 +239,24 @@ There are several parts of the documentation which should be updated with the ne
- `docs/core/equations` should contain a short explanation and if possible an analytical expression for the behaviour of the new node;
- `docs/core/usage.qmd` should contain a short explanation of the node and the possible schemas associated with it;
- The example models constructed in `docs/python/examples.ipynb` should be extended with the new node type or a new example model with the new node type should be made.
- In `_quarto.yml` add `NewNodeType` to the "Node types" contents for the Python API reference.


# Finishing up

When a new node type is created, one needs to run

```
julia --project=docs docs/gen_schema.jl
pixi run codegen
```
to create new JSON Schemas in the docs folder.

:::{.callout-note}
If you haven't done so before, you first need to instantiate your docs environment.
Run `julia --project=docs`, followed by running `instantiate` in the Pkg mode (press `]`).
:::
This will derive all JSON Schemas from the julia code, and write them to the docs folder.
From these JSON Schemas the Python modules `models.py` and `config.py` are generated.

To generate the Python module `models.py` and `config.py` from the JSON Schemas, run:
Since adding a node type touches both the Python and Julia code,
it is a good idea to run both the [Python test suite](python.qmd#test) and [Julia test suite](core.qmd#test) locally before creating a pull request.
You can run all tests with:

```
pixi run codegen
pixi run tests
```

Since adding a node type touches both the Python and Julia code,
it is a good idea to run both the [Python test suite](python.qmd#test) and [Julia test suite](core.qmd#test) locally before creating a pull request.
4 changes: 3 additions & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ test-ribasim-core = { cmd = "julia --project=core --eval 'using Pkg; Pkg.instant
generate-testmodels = "python utils/generate-testmodels.py"
tests = { depends_on = ["lint", "test-ribasim-python", "test-ribasim-core"] }
# Codegen
generate-schema = "julia --project=docs docs/gen_schema.jl"
generate-schema = { cmd = "julia --project=docs docs/gen_schema.jl", depends_on = [
"instantiate-julia-docs",
] }
generate-python = """\
datamodel-codegen --use-title-as-name --use-double-quotes --disable-timestamp --use-default --strict-nullable --input-file-type=jsonschema --input docs/schema/root.schema.json --output python/ribasim/ribasim/models.py && \
datamodel-codegen --use-title-as-name --use-double-quotes --disable-timestamp --use-default --strict-nullable --input-file-type=jsonschema --input docs/schema/Config.schema.json --output python/ribasim/ribasim/config.py"""
Expand Down

0 comments on commit afe1bcc

Please sign in to comment.