Skip to content

Commit

Permalink
Merge branch 'main' into expose_user_demands
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Feb 8, 2024
2 parents 2f88214 + 83de69f commit 8425005
Show file tree
Hide file tree
Showing 18 changed files with 107 additions and 61 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/core_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
- uses: julia-actions/julia-processcoverage@v1
with:
directories: core/src
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
files: lcov.info
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/julia_auto_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Julia auto update

on:
schedule:
# At 03:00 on day 1 of the month
- cron: "0 3 1 * *"
# At 03:00 on day 2 of the month
- cron: "0 3 2 * *"
# on demand
workflow_dispatch:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pixi_auto_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Pixi auto update

on:
schedule:
# At 03:00 on day 1 of the month
- cron: "0 3 1 * *"
# At 03:00 on day 3 of the month
- cron: "0 3 3 * *"
# on demand
workflow_dispatch:

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ jobs:
run: pytest --numprocesses=auto --cov=ribasim --cov-report=xml python/ribasim/tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion core/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "Ribasim"
uuid = "aac5e3d9-0b8f-4d4f-8241-b1a7a9632635"
authors = ["Deltares and contributors <[email protected]>"]
manifest = "../Manifest.toml"
version = "0.7.0"
version = "2024.02.0"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
3 changes: 3 additions & 0 deletions core/src/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ function main(ARGS::Vector{String})::Cint
logger =
Ribasim.setup_logger(; verbosity = config.logging.verbosity, stream = io)
with_logger(logger) do
ribasim_version = pkgversion(Ribasim)
(; starttime, endtime) = config
@info "Starting a Ribasim simulation." ribasim_version starttime endtime
model = Ribasim.run(config)
if successful_retcode(model)
@info "The model finished successfully"
Expand Down
10 changes: 5 additions & 5 deletions core/src/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ end

@version BasinStaticV1 begin
node_id::Int
drainage::Float64
potential_evaporation::Float64
infiltration::Float64
precipitation::Float64
urban_runoff::Float64
drainage::Union{Missing, Float64}
potential_evaporation::Union{Missing, Float64}
infiltration::Union{Missing, Float64}
precipitation::Union{Missing, Float64}
urban_runoff::Union{Missing, Float64}
end

@version BasinTimeV1 begin
Expand Down
5 changes: 5 additions & 0 deletions core/test/run_models_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ end
@test ispath(toml_path)
model = Ribasim.run(toml_path)
@test model isa Ribasim.Model
@test model.integrator.u.storage [1000]
@test model.integrator.p.basin.precipitation == [0.0]
@test model.integrator.p.basin.potential_evaporation == [0.0]
@test model.integrator.p.basin.drainage == [0.0]
@test model.integrator.p.basin.infiltration == [0.0]
@test successful_retcode(model)
end

Expand Down
38 changes: 21 additions & 17 deletions docs/contribute/release.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ title: "Release process"
# What is a release

The [Ribasim repository](https://github.com/Deltares/Ribasim) contains several components, e.g., the Julia core, the Python tooling and QGIS plugin.
The components are currently only guaranteed to work together if they are built at the same time.
Therefore we release Ribasim as a collection of all the components at once.
The components are currently only guaranteed to work together if they have the same version number.
Therefore we release Ribasim as a collection of all the components at once, all carrying the same version number.
For maximum interoperability it is suggested to only release all components together, and not individually.

For these releases we use [Calender Versioning](https://calver.org/), which makes it clear in which month the release was made.
Expand All @@ -19,19 +19,28 @@ This section provides a guide for developers to follow when preparing a new rele

Before starting the release process, ensure that all tests are passing and that all features intended for the release are complete and merged into the main branch.

## Update version numbers of the components as needed
## Update version numbers of the components

The components have their own version number which generally uses [Semantic Versioning](https://semver.org/), with minor version signifying a breaking release for pre-1.0 versions, as [documented here](https://pkgdocs.julialang.org/v1/compatibility/#compat-pre-1.0). If a component did not change at all between releases, the version number can stay the same.
Determine the new version number like `2023.08.0`, filling in the current year, month and a sequential "MICRO" number.
This follows `YYYY.0M.MICRO` from [calver](https://calver.org/).

Now submit a pull request which updates the version numbers of the components as needed.
You can use [PR #623](https://github.com/Deltares/Ribasim/pull/623) as an example.
Update the version numbers in the repository to the new version number.
A single find and replace can update all 5 locations:

In general for Python packages the version number is in `__init__.py`, for Julia it is `Project.toml`, and for QGIS `metadata.txt`
- `pixi.toml`
- `core/Project.toml`
- `python/ribasim/ribasim/__init__.py`
- `python/ribasim_api/ribasim_api/__init__.py`
- `ribasim_qgis/metadata.txt`

Now submit a pull request to update the version numbers.

## Create a new release

Create a new tag like `v2023.08.0`, filling in the current year, month and a sequential "MICRO" number.
This follows `vYYYY.0M.MICRO` from [calver](https://calver.org/).
When the pull request is merged to main, checkout the commit that updates the version numbers.

Create a new tag, which is the letter `v` followed by the version number, like, `v2023.08.0`.

This can be done by executing:
```bash
git tag <tagname>
Expand Down Expand Up @@ -59,19 +68,14 @@ All changes
```

## Release Ribasim Python to PyPI
## Release the Ribasim Python packages to PyPI

To be able to install packages with `pip`, they need to be released on the Python Package Index (PyPI).
In order to publish Ribasim Python or Ribasim API follow the following steps:

1) Update `__version__` in `__init__.py`

2) Open a terminal and run `pixi run build-ribasim-python-wheel` or `pixi run build-ribasim-api-wheel`

3) Make a new commit with the updated version number, and push to remote

4) Publish on PyPI with `pixi run publish-ribasim-python` or `pixi run publish-ribasim-api`
1) Open a terminal and run `pixi run publish-ribasim-python`

2) Open a terminal and run `pixi run publish-ribasim-api`

## Do manual checks

Expand Down
62 changes: 46 additions & 16 deletions docs/schema/BasinStatic.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,59 @@
"type": "integer"
},
"drainage": {
"format": "double",
"type": "number"
"format": "default",
"anyOf": [
{
"type": "null"
},
{
"type": "number"
}
]
},
"potential_evaporation": {
"format": "double",
"type": "number"
"format": "default",
"anyOf": [
{
"type": "null"
},
{
"type": "number"
}
]
},
"infiltration": {
"format": "double",
"type": "number"
"format": "default",
"anyOf": [
{
"type": "null"
},
{
"type": "number"
}
]
},
"precipitation": {
"format": "double",
"type": "number"
"format": "default",
"anyOf": [
{
"type": "null"
},
{
"type": "number"
}
]
},
"urban_runoff": {
"format": "double",
"type": "number"
"format": "default",
"anyOf": [
{
"type": "null"
},
{
"type": "number"
}
]
},
"remarks": {
"description": "a hack for pandera",
Expand All @@ -37,11 +72,6 @@
}
},
"required": [
"node_id",
"drainage",
"potential_evaporation",
"infiltration",
"precipitation",
"urban_runoff"
"node_id"
]
}
2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "Ribasim"
version = "0.5.0"
version = "2024.02.0"
description = "Water resources modeling"
authors = ["Deltares and contributors <[email protected]>"]
channels = ["conda-forge"]
Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.7.0"
__version__ = "2024.02.0"


from ribasim import models, utils
Expand Down
10 changes: 5 additions & 5 deletions python/ribasim/ribasim/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class BasinState(BaseModel):

class BasinStatic(BaseModel):
node_id: int
drainage: float
potential_evaporation: float
infiltration: float
precipitation: float
urban_runoff: float
drainage: float | None = None
potential_evaporation: float | None = None
infiltration: float | None = None
precipitation: float | None = None
urban_runoff: float | None = None
remarks: str = Field("", description="a hack for pandera")


Expand Down
2 changes: 1 addition & 1 deletion python/ribasim_api/ribasim_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.6.0"
__version__ = "2024.02.0"

from ribasim_api.ribasim_api import RibasimApi

Expand Down
2 changes: 1 addition & 1 deletion python/ribasim_testmodels/ribasim_testmodels/backwater.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def backwater_model():
flow_boundary=flow_boundary,
manning_resistance=manning_resistance,
starttime="2020-01-01 00:00:00",
endtime="2030-01-01 00:00:00",
endtime="2021-01-01 00:00:00",
)

return model
10 changes: 5 additions & 5 deletions python/ribasim_testmodels/ribasim_testmodels/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ def bucket_model() -> ribasim.Model:
static = pd.DataFrame(
data={
"node_id": [1],
"drainage": [0.0],
"potential_evaporation": [0.0],
"infiltration": [0.0],
"precipitation": [0.0],
"urban_runoff": [0.0],
"drainage": [np.nan],
"potential_evaporation": [np.nan],
"infiltration": [np.nan],
"precipitation": [np.nan],
"urban_runoff": [np.nan],
}
)
basin = ribasim.Basin(profile=profile, static=static, state=state)
Expand Down
2 changes: 1 addition & 1 deletion python/ribasim_testmodels/ribasim_testmodels/two_basin.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ def two_basin_model() -> ribasim.Model:
tabulated_rating_curve=rating_curve,
terminal=terminal,
starttime="2020-01-01 00:00:00",
endtime="2030-01-01 00:00:00",
endtime="2021-01-01 00:00:00",
)
return ribasim_model
2 changes: 1 addition & 1 deletion ribasim_qgis/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
name=Ribasim-QGIS
qgisMinimumVersion=3.0
description=QGIS plugin to setup Ribasim models
version=0.7
version=2024.02.1
author=Deltares and contributors
[email protected]

Expand Down

0 comments on commit 8425005

Please sign in to comment.