Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuous integration of unit tests #5

Closed
gijsber opened this issue Sep 19, 2022 · 1 comment
Closed

Continuous integration of unit tests #5

gijsber opened this issue Sep 19, 2022 · 1 comment
Assignees
Labels
test Relates to unit testing

Comments

@gijsber
Copy link
Contributor

gijsber commented Sep 19, 2022

Run unit tests on GitHub Actions

@visr visr changed the title Continuous integration Continuous integration of unit tests Oct 28, 2022
@visr visr assigned AmyWilcox1 and unassigned AmyWilcox1 and visr Oct 28, 2022
@visr visr added the test Relates to unit testing label Oct 28, 2022
@visr visr added this to Ribasim Oct 28, 2022
@visr visr moved this to 🔲 Todo in Ribasim Nov 15, 2022
@visr visr assigned evetion and unassigned AmyWilcox1 Nov 17, 2022
@visr visr moved this from 🔲 Todo to 👀 In review in Ribasim Nov 17, 2022
@visr visr moved this from 👀 In review to ✅ Done in Ribasim Nov 18, 2022
@gijsber gijsber added this to the EndOf22 package milestone Nov 28, 2022
@Hofer-Julian
Copy link
Contributor

Fixed by 4d8dc4e

visr added a commit that referenced this issue Feb 12, 2024
Needed for #1110.

Before node IDs were globally unique. If you had the ID, you could look
up the type in the Node table. When designing #1110 we came to the
conclusion that this was not the right choice. It requires you to be
aware of the IDs that are used throughout the model, whereas with this
you only need to make sure that `Pump #5` doesn't already exist.

Most of the updates in this PR were to correct the tests. Some of the
code and error messages became easier to read. If we talk about a node
then we always know what the type is, there is no need to look it up
first.

Most tables stay the same, e.g. if you have a `Terminal / static` table
with a `node_id` Int column, you know that this refers to a Terminal
NodeID. Only when connecting to other nodes do we need to specify the
type next to the ID. So the `Edge` table now gets `from_node_type` next
to `from_node_id`, the `PidControl / static` gets `listen_node_type`
next to `listen_node_id`, etc. These extra columns are currently
automatically filled in by Ribasim-Python on model save, hence they
don't require changing the test models.

In terms of implementation, this basically adds the `type` field to
`NodeID` and fixes the resulting errors.

```julia
struct NodeID
    type::NodeType.T
    value::Int
end
```

It does not yet test if models with the same node IDs (`Pump #1` and
`Basin #1`) work, but this is hard to do right now with Ribasim Python,
so best left for a later moment.

---------

Co-authored-by: Hofer-Julian <[email protected]>
visr added a commit that referenced this issue Mar 14, 2024
Fixes #1244

Having a node name in validation error messages is slightly nicer, but
we were only doing it in two places. And the ID printing of `Pump #5` is
quite nice and compact.
visr added a commit that referenced this issue Jul 23, 2024
Fixes #1350

This is an example `ribasim.log`:

```
┌ Info: Starting a Ribasim simulation.
│   cli.ribasim_version = 2024.9.0
│   starttime = 2020-01-01T00:00:00
│   endtime = 2020-12-01T00:00:00
└ @ Ribasim D:\repo\ribasim\Ribasim\core\src\main.jl:42
┌ Error: Invalid edge type 'foo' for edge #0 from node #1 to node #2.
└ @ Ribasim D:\repo\ribasim\Ribasim\core\src\validation.jl:520
┌ Error: Invalid edge type 'bar' for edge #1 from node #2 to node #3.
└ @ Ribasim D:\repo\ribasim\Ribasim\core\src\validation.jl:520
ERROR: Invalid edge types found.
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:35
  [2] Ribasim.Model(config::Ribasim.config.Config)
    @ Ribasim D:\repo\ribasim\Ribasim\core\src\model.jl:59
  [3] run(config::Ribasim.config.Config)
    @ Ribasim D:\repo\ribasim\Ribasim\core\src\main.jl:11
  [4] (::Ribasim.var"#215#217"{IOStream, Ribasim.config.Config})()
    @ Ribasim D:\repo\ribasim\Ribasim\core\src\main.jl:45
  [5] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging .\logging.jl:515
  [6] with_logger
    @ .\logging.jl:627 [inlined]
  [7] #214
    @ D:\repo\ribasim\Ribasim\core\src\main.jl:36 [inlined]
  [8] open(::Ribasim.var"#214#216"{Ribasim.config.Config}, ::String, ::Vararg{String}; kwargs::@kwargs{})
    @ Base .\io.jl:396
  [9] open
    @ .\io.jl:393 [inlined]
 [10] main(toml_path::String)
    @ Ribasim D:\repo\ribasim\Ribasim\core\src\main.jl:34
 [11] (::Main.var"##227".var"#1#2")()
    @ Main.var"##227" d:\repo\ribasim\Ribasim\core\test\main_test.jl:42
 [12] (::IOCapture.var"#5#9"{DataType, Main.var"##227".var"#1#2", IOContext{Base.PipeEndpoint}, IOContext{Base.PipeEndpoint}, Base.PipeEndpoint, Base.PipeEndpoint})()
    @ IOCapture C:\Users\visser_mn\.julia\packages\IOCapture\Y5rEA\src\IOCapture.jl:170
 [13] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging .\logging.jl:515
 [14] with_logger
    @ .\logging.jl:627 [inlined]
 [15] capture(f::Main.var"##227".var"#1#2"; rethrow::Type, color::Bool, passthrough::Bool, capture_buffer::IOBuffer, io_context::Vector{Any})
    @ IOCapture C:\Users\visser_mn\.julia\packages\IOCapture\Y5rEA\src\IOCapture.jl:167
 [16] capture(f::Function)
    @ IOCapture C:\Users\visser_mn\.julia\packages\IOCapture\Y5rEA\src\IOCapture.jl:100
 [17] top-level scope
    @ d:\repo\ribasim\Ribasim\core\test\main_test.jl:41
 [18] eval
    @ .\boot.jl:385 [inlined]
 [19] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
    @ Base .\loading.jl:2076
 [20] include_string(m::Module, txt::String, fname::String)
    @ Base .\loading.jl:2086
 [21] #invokelatest#2
    @ .\essentials.jl:892 [inlined]
 [22] invokelatest
    @ .\essentials.jl:889 [inlined]
 [23] #8
    @ c:\Users\visser_mn\.vscode\extensions\julialang.language-julia-1.83.2\scripts\packages\VSCodeTestServer\src\VSCodeTestServer.jl:115 [inlined]
 [24] withpath(f::VSCodeTestServer.var"#8#10"{UInt64, String, String, Module}, path::String)
    @ VSCodeTestServer c:\Users\visser_mn\.vscode\extensions\julialang.language-julia-1.83.2\scripts\packages\VSCodeTestServer\src\VSCodeTestServer.jl:20
 [25] run_testitem_handler(conn::VSCodeTestServer.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, params::VSCodeTestServer.TestserverRunTestitemRequestParams)
    @ VSCodeTestServer c:\Users\visser_mn\.vscode\extensions\julialang.language-julia-1.83.2\scripts\packages\VSCodeTestServer\src\VSCodeTestServer.jl:114
 [26] dispatch_msg(x::VSCodeTestServer.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::VSCodeTestServer.JSONRPC.MsgDispatcher, msg::Dict{String, Any})
    @ VSCodeTestServer.JSONRPC c:\Users\visser_mn\.vscode\extensions\julialang.language-julia-1.83.2\scripts\packages\JSONRPC\src\typed.jl:67
 [27] serve_in_env(conn::Base.PipeEndpoint)
    @ VSCodeTestServer c:\Users\visser_mn\.vscode\extensions\julialang.language-julia-1.83.2\scripts\packages\VSCodeTestServer\src\VSCodeTestServer.jl:215
 [28] #14
    @ c:\Users\visser_mn\.vscode\extensions\julialang.language-julia-1.83.2\scripts\packages\VSCodeTestServer\src\VSCodeTestServer.jl:234 [inlined]
 [29] (::VSCodeTestServer.TestEnv.var"#3#4"{VSCodeTestServer.var"#14#16"{Base.PipeEndpoint}})()
    @ VSCodeTestServer.TestEnv c:\Users\visser_mn\.vscode\extensions\julialang.language-julia-1.83.2\scripts\packages\TestEnv\src\julia-1.9\activate_do.jl:19
 [30] withenv(::VSCodeTestServer.TestEnv.var"#3#4"{VSCodeTestServer.var"#14#16"{Base.PipeEndpoint}}, ::Pair{String, String}, ::Vararg{Pair{String}})
    @ Base .\env.jl:257
 [31] (::Pkg.Operations.var"#117#122"{String, Bool, Bool, Bool, VSCodeTestServer.TestEnv.var"#3#4"{VSCodeTestServer.var"#14#16"{Base.PipeEndpoint}}, Pkg.Types.PackageSpec})()
    @ Pkg.Operations C:\Users\visser_mn\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1825
 [32] with_temp_env(fn::Pkg.Operations.var"#117#122"{String, Bool, Bool, Bool, VSCodeTestServer.TestEnv.var"#3#4"{VSCodeTestServer.var"#14#16"{Base.PipeEndpoint}}, Pkg.Types.PackageSpec}, temp_env::String)
    @ Pkg.Operations C:\Users\visser_mn\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1706
 [33] (::Pkg.Operations.var"#115#120"{Nothing, Bool, Bool, Bool, VSCodeTestServer.TestEnv.var"#3#4"{VSCodeTestServer.var"#14#16"{Base.PipeEndpoint}}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String})(tmp::String)
    @ Pkg.Operations C:\Users\visser_mn\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1795
 [34] mktempdir(fn::Pkg.Operations.var"#115#120"{Nothing, Bool, Bool, Bool, VSCodeTestServer.TestEnv.var"#3#4"{VSCodeTestServer.var"#14#16"{Base.PipeEndpoint}}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String}, parent::String; prefix::String)
    @ Base.Filesystem .\file.jl:766
 [35] mktempdir(fn::Function, parent::String)
    @ Base.Filesystem .\file.jl:762
 [36] mktempdir
    @ .\file.jl:762 [inlined]
 [37] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project; preferences::Nothing, force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool)
    @ Pkg.Operations C:\Users\visser_mn\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1753
 [38] sandbox
    @ C:\Users\visser_mn\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1744 [inlined]
 [39] activate(f::VSCodeTestServer.var"#14#16"{Base.PipeEndpoint}, pkg::String; allow_reresolve::Bool)
    @ VSCodeTestServer.TestEnv c:\Users\visser_mn\.vscode\extensions\julialang.language-julia-1.83.2\scripts\packages\TestEnv\src\julia-1.9\activate_do.jl:17
 [40] activate
    @ c:\Users\visser_mn\.vscode\extensions\julialang.language-julia-1.83.2\scripts\packages\TestEnv\src\julia-1.9\activate_do.jl:12 [inlined]
 [41] serve(conn::Base.PipeEndpoint, project_path::String, package_path::String, package_name::String; is_dev::Bool, crashreporting_pipename::Nothing)
    @ VSCodeTestServer c:\Users\visser_mn\.vscode\extensions\julialang.language-julia-1.83.2\scripts\packages\VSCodeTestServer\src\VSCodeTestServer.jl:233
 [42] serve(conn::Base.PipeEndpoint, project_path::String, package_path::String, package_name::String)
    @ VSCodeTestServer c:\Users\visser_mn\.vscode\extensions\julialang.language-julia-1.83.2\scripts\packages\VSCodeTestServer\src\VSCodeTestServer.jl:219
 [43] top-level scope
    @ c:\Users\visser_mn\.vscode\extensions\julialang.language-julia-1.83.2\scripts\testserver\testserver_main.jl:17
 [44] include(mod::Module, _path::String)
    @ Base .\Base.jl:495
 [45] exec_options(opts::Base.JLOptions)
    @ Base .\client.jl:318
 [46] _start()
    @ Base .\client.jl:552
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Relates to unit testing
Projects
Archived in project
Development

No branches or pull requests

5 participants