-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
pixi run ribasim-models
to run all test models (#1224)
This runs them all in a single Julia session to avoid latency. I didn't add this to CI for now since we already run them all on TeamCity using the CLI. But this is especially helpful during development to see which models fail and why. If I intentionally break two models you see this output at the end: ``` [ Info: Ran 32 models, 30 passed, 2 failed. Failed models: bucket rating_curve ``` And in between the normal output: ``` [ Info: Running model bucket ERROR: expect key: starttime Stacktrace: [1] error(s::String) @ Base .\error.jl:35 [2] macro expansion @ C:\Users\visser_mn\.julia\packages\Configurations\Yxczn\src\from_dict.jl:0 [inlined] [3] from_dict_specialize(::Type{Ribasim.config.Toml}, d::Dict{String, Any}) @ Ribasim.config C:\Users\visser_mn\.julia\packages\Configurations\Yxczn\src\codegen.jl:362 [4] #from_dict#4 @ C:\Users\visser_mn\.julia\packages\Configurations\Yxczn\src\from_dict.jl:46 [inlined] [5] from_dict @ C:\Users\visser_mn\.julia\packages\Configurations\Yxczn\src\from_dict.jl:33 [inlined] [6] from_toml(::Type{Ribasim.config.Toml}, filename::String; kw::@kwargs{}) @ Configurations C:\Users\visser_mn\.julia\packages\Configurations\Yxczn\src\from_toml.jl:18 [7] from_toml @ C:\Users\visser_mn\.julia\packages\Configurations\Yxczn\src\from_toml.jl:8 [inlined] [8] #Config#62 @ D:\Ribasim\core\src\config.jl:147 [inlined] [9] Config @ D:\Ribasim\core\src\config.jl:146 [inlined] ┌ Error: Simulation failed │ modelname = "bucket" └ @ Main D:\Ribasim\utils\testmodelrun.jl:15 ``` --------- Co-authored-by: Hofer-Julian <[email protected]>
- Loading branch information
1 parent
0438c15
commit 4610c0d
Showing
6 changed files
with
103 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Julia Run Testmodels | ||
on: | ||
push: | ||
branches: [main, update/pixi-lock, update/julia-manifest] | ||
paths-ignore: [".teamcity/**"] | ||
tags: ["*"] | ||
pull_request: | ||
merge_group: | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
# needed to allow julia-actions/cache to delete old caches that it has created | ||
permissions: | ||
actions: write | ||
contents: read | ||
jobs: | ||
test: | ||
name: Julia ${{ matrix.os }} - ${{ matrix.arch }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
# https://github.com/Deltares/Ribasim/issues/825 | ||
# - macOS-latest | ||
- windows-latest | ||
arch: | ||
- x64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: julia-actions/cache@v1 | ||
with: | ||
cache-compiled: "true" | ||
cache-registries: "true" | ||
- uses: prefix-dev/[email protected] | ||
with: | ||
pixi-version: "v0.15.2" | ||
- name: Prepare pixi | ||
run: pixi run install-ci | ||
- name: Run testmodels with Ribasim Core | ||
run: | | ||
pixi run ribasim-core-testmodels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Ribasim | ||
|
||
include("utils.jl") | ||
|
||
function main(ARGS) | ||
toml_paths = get_testmodels() | ||
n_model = length(toml_paths) | ||
n_pass = 0 | ||
n_fail = 0 | ||
failed = String[] | ||
|
||
for toml_path in toml_paths | ||
modelname = basename(dirname(toml_path)) | ||
@info "Running model $modelname" | ||
if Ribasim.main(toml_path) != 0 | ||
@error "Simulation failed" modelname | ||
push!(failed, modelname) | ||
n_fail += 1 | ||
else | ||
n_pass += 1 | ||
end | ||
end | ||
|
||
@info "Ran $n_model models, $n_pass passed, $n_fail failed." | ||
if n_fail > 0 | ||
println("Failed models:") | ||
foreach(println, failed) | ||
end | ||
end | ||
|
||
main(ARGS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Shared utility functions that are not part of the Ribasim core | ||
|
||
using Glob: glob | ||
|
||
"Retrieve the names of the valid test models" | ||
function get_testmodels()::Vector{String} | ||
models_dir = normpath(@__DIR__, "..", "generated_testmodels") | ||
toml_paths = sort(glob("**/ribasim.toml", models_dir)) | ||
filter(x -> !startswith(basename(dirname(x)), "invalid_"), toml_paths) | ||
end |