Skip to content

Commit 85a706e

Browse files
authored
Add wflow version field to TOML (#950)
* Add TOML field * Add test wflow_version * Update docs * Update changelog
1 parent 5e33fc6 commit 85a706e

6 files changed

Lines changed: 17 additions & 3 deletions

File tree

Wflow/src/config_init.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ function convert_value(::Type{T}, value::Any) where {T}
1313
T_ = get_something_type(T)
1414
if T_ <: AbstractConfigSection
1515
init_config_section(T_, value)
16+
elseif T_ == VersionNumber
17+
VersionNumber(value)
1618
else
1719
convert(T_, value)
1820
end
@@ -254,6 +256,9 @@ function to_dict(
254256
!getfield(value, :_was_specified)
255257
continue
256258
end
259+
if value isa VersionNumber
260+
value = string(value)
261+
end
257262
dict[String(field_name)] = to_dict(value)
258263
end
259264
return dict

Wflow/src/config_structure.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ end
260260

261261
# Fields with a default value are optional
262262
@kwdef mutable struct Config <: AbstractConfigSection
263+
wflow_version::Union{Nothing, VersionNumber} = nothing
263264
dir_input::String = "."
264265
dir_output::String = "."
265266
fews_run__flag::Bool = false

Wflow/test/io.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@test dirname(config) == dirname(tomlpath)
1212

1313
# test if the values are parsed as expected
14+
@test config.wflow_version == v"1.1.0"
1415
@test config.time.starttime === DateTime(2000, 1, 1)
1516
@test config.time.endtime === DateTime(2000, 2)
1617
@test config.output.netcdf_grid.path == "output_moselle.nc"

Wflow/test/sbm_config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
dir_input = "data/input"
77
dir_output = "data/output"
8+
wflow_version = "1.1"
89

910
[logging]
1011
loglevel = "info"

docs/changelog.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ subsurface_water__instantaneous_volume_flow_rate = "ssf"
7272
domain via `input.subbasin_location__count`, or specify specific subcatchments by linking
7373
`input.subbasin_location__count` to a subcatchment map, and indicate which subbasins
7474
should be active by providing their IDs in `input.subbasin_active_location__count`.
75+
- Added an optional `wflow_version` field to the config .toml file. This setting is used by
76+
the wflow model builder `hydromt_wflow` for incremental Wflow.jl version upgrading.
7577

7678
## v1.0.2 - 2026-03-05
7779

docs/user_guide/toml_file.qmd

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@ structured in several sections, which are explained below.
1010
## General
1111
The file paths provided in this file are relative to the location of the TOML file, or to
1212
`dir_input` and `dir_output` if they are specified. To indicate that a wflow model [runs
13-
from Delft-FEWS](fews.qmd), the `fews_run__flag` setting needs to be set at `true`.
13+
from Delft-FEWS](fews.qmd), the `fews_run__flag` setting needs to be set at `true`. The
14+
`wflow_version` setting represents the Wflow.jl version compatibility of the config .toml
15+
file. This setting is used by the wflow plugin
16+
[hydroMT-wflow](https://github.com/Deltares/hydromt_wflow) for incremental Wflow.jl version
17+
upgrading.
1418

1519
```toml
1620
dir_input = "data/input" # optional, default is the path of the TOML
1721
dir_output = "data/output" # optional, default is the path of the TOML
18-
fews_run__flag = false # optional, default value is false
22+
fews_run__flag = false # optional, default value is false
23+
wflow_version = "1.1" # optional, default value is `nothing`
1924
```
2025

21-
2226
## Time info
2327
Time information is optional. When omitted, wflow will perform computations for each
2428
timestamp in the forcing netCDF file, except for the first forcing timestamp, which is

0 commit comments

Comments
 (0)