Skip to content

Commit

Permalink
Merge branch 'main' into autodiff_wrt_time
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Oct 23, 2023
2 parents 2a04d32 + 097053c commit ef0a2cf
Show file tree
Hide file tree
Showing 69 changed files with 399 additions and 355 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<options>
<option name="artifactRules" value="ribasim\build/create_binaries/ribasim_cli =&gt; ribasim_cli.zip" />
<option name="executionTimeoutMin" value="120" />
<option name="publishArtifactCondition" value="SUCCESSFUL" />
</options>
<parameters>
<param name="conda_env_path" value="%system.teamcity.build.checkoutDir%/env_build_ribasim_cli" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<description />
<settings>
<options>
<option name="artifactRules" value="build\ribasim_cli\tests\temp =&gt; test_output.zip" />
<option name="artifactRules" value="ribasim\build\ribasim_cli\tests\temp =&gt; test_output.zip" />
</options>
<parameters>
<param name="conda_env_path" value="%system.teamcity.build.checkoutDir%/ribasim_cli_test_env" />
Expand Down
68 changes: 67 additions & 1 deletion build/create_binaries/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.9.3"
manifest_format = "2.0"
project_hash = "c56985ee841fb30b2cb92ecec4da345315a95306"
project_hash = "71b2262fd2a2bd6f9c0ade48d4062e051c3f39eb"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand All @@ -14,6 +14,19 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[deps.Compat]]
deps = ["UUIDs"]
git-tree-sha1 = "8a62af3e248a8c4bad6b32cbbe663ae02275e32c"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "4.10.0"

[deps.Compat.extensions]
CompatLinearAlgebraExt = "LinearAlgebra"

[deps.Compat.weakdeps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[deps.Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand All @@ -23,6 +36,11 @@ deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
version = "1.6.0"

[[deps.ExprTools]]
git-tree-sha1 = "27415f162e6028e81c72b82ef756bf321213b6ec"
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
version = "0.1.10"

[[deps.FileWatching]]
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"

Expand All @@ -31,6 +49,12 @@ git-tree-sha1 = "97285bbd5230dd766e9ef6749b80fc617126d496"
uuid = "c27321d9-0574-5035-807b-f59d2c89b15c"
version = "1.3.1"

[[deps.InlineStrings]]
deps = ["Parsers"]
git-tree-sha1 = "9cc2baf75c6d09f9da536ddf58eb2f29dedaf461"
uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
version = "1.4.0"

[[deps.InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down Expand Up @@ -73,6 +97,12 @@ deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.28.2+0"

[[deps.Mocking]]
deps = ["Compat", "ExprTools"]
git-tree-sha1 = "4cc0c5a83933648b615c36c2b956d94fda70641e"
uuid = "78c3b35d-d492-501b-9361-3d52fe80e533"
version = "0.7.7"

[[deps.MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
version = "2022.10.11"
Expand All @@ -87,11 +117,29 @@ git-tree-sha1 = "d24f0920777c64c0265e9725eb4a3ec450bc36dd"
uuid = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
version = "2.1.10"

[[deps.Parsers]]
deps = ["Dates", "PrecompileTools", "UUIDs"]
git-tree-sha1 = "716e24b21538abc91f6205fd1d8363f39b442851"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.7.2"

[[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
version = "1.9.2"

[[deps.PrecompileTools]]
deps = ["Preferences"]
git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f"
uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
version = "1.2.0"

[[deps.Preferences]]
deps = ["TOML"]
git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.4.1"

[[deps.Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand Down Expand Up @@ -131,11 +179,29 @@ deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
version = "1.0.3"

[[deps.TZJData]]
deps = ["Artifacts"]
git-tree-sha1 = "d39314cdbaf5b90a047db33858626f8d1cc973e1"
uuid = "dc5dba14-91b3-4cab-a142-028a31da12f7"
version = "1.0.0+2023c"

[[deps.Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
version = "1.10.0"

[[deps.TimeZones]]
deps = ["Artifacts", "Dates", "Downloads", "InlineStrings", "LazyArtifacts", "Mocking", "Printf", "Scratch", "TZJData", "Unicode", "p7zip_jll"]
git-tree-sha1 = "89e64d61ef3cd9e80f7fc12b7d13db2d75a23c03"
uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53"
version = "1.13.0"

[deps.TimeZones.extensions]
TimeZonesRecipesBaseExt = "RecipesBase"

[deps.TimeZones.weakdeps]
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"

[[deps.UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
Expand Down
3 changes: 3 additions & 0 deletions build/create_binaries/Project.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[deps]
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"

[compat]
PackageCompiler = "2"
TimeZones = "=1.13.0"
julia = "1.9"
4 changes: 3 additions & 1 deletion build/create_binaries/create_app.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ using PackageCompiler
using TOML
using LibGit2

include("strip_cldr.jl")

# change directory to this script's location
cd(@__DIR__)

Expand All @@ -16,7 +18,7 @@ create_app(
# map from binary name to julia function name
executables = ["ribasim" => "julia_main"],
precompile_execution_file = "precompile.jl",
filter_stdlibs = false,
include_lazy_artifacts = true,
force = true,
)

Expand Down
4 changes: 3 additions & 1 deletion build/create_binaries/create_lib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ using PackageCompiler
using TOML
using LibGit2

include("strip_cldr.jl")

cd(@__DIR__)

project_dir = "../libribasim"
Expand All @@ -14,7 +16,7 @@ create_library(
output_dir;
lib_name = "libribasim",
precompile_execution_file = "precompile.jl",
include_lazy_artifacts = false,
include_lazy_artifacts = true,
force = true,
)

Expand Down
2 changes: 1 addition & 1 deletion build/create_binaries/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

using Ribasim, Dates, TOML

toml_path = normpath(@__DIR__, "../../generated_testmodels/basic/basic.toml")
toml_path = normpath(@__DIR__, "../../generated_testmodels/basic/ribasim.toml")
Ribasim.run(toml_path)
24 changes: 24 additions & 0 deletions build/create_binaries/strip_cldr.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The cldr artifact has such long paths that it errors on Windows unless long paths are enabled.
# Also the artifact has many files and is over 300 MB, while we only need a single small file.
# This modifies the artifact to remove everything except the file we need.
# Since the artifact is only used on Windows, only strip do it there.
# This needs exactly TimeZones 1.13.0, which is fixed in the Project.toml.
# https://github.com/JuliaTime/TimeZones.jl/issues/373

using Artifacts

if Sys.iswindows()
# Get the artifact directory and the file path we need to keep
hash = Base.SHA1("40b35727ea0aff9a9f28b7454004b68849caf67b")
@assert artifact_exists(hash)
artifact_dir = artifact_path(hash)
keep_file =
normpath(artifact_dir, "cldr-release-43-1/common/supplemental/windowsZones.xml")
@assert isfile(keep_file)

# Read the file into memory, empty the artifact dir, and write the file back
keep_file_content = read(keep_file)
rm(artifact_dir; recursive = true)
mkpath(dirname(keep_file))
write(keep_file, keep_file_content)
end
2 changes: 1 addition & 1 deletion build/libribasim/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.3.0"

[[deps.Ribasim]]
deps = ["Arrow", "BasicModelInterface", "CodecLz4", "CodecZstd", "ComponentArrays", "Configurations", "DBInterface", "DataInterpolations", "DataStructures", "Dates", "Dictionaries", "DiffEqCallbacks", "FiniteDiff", "ForwardDiff", "Graphs", "HiGHS", "IterTools", "JuMP", "Legolas", "Logging", "LoggingExtras", "OrdinaryDiffEq", "PreallocationTools", "SQLite", "SciMLBase", "SparseArrays", "StructArrays", "Tables", "TerminalLoggers", "TimeZones", "TimerOutputs", "TranscodingStreams"]
deps = ["Arrow", "BasicModelInterface", "CodecLz4", "CodecZstd", "ComponentArrays", "Configurations", "DBInterface", "DataInterpolations", "DataStructures", "Dates", "Dictionaries", "DiffEqCallbacks", "FiniteDiff", "ForwardDiff", "Graphs", "HiGHS", "IterTools", "JuMP", "Legolas", "Logging", "LoggingExtras", "OrdinaryDiffEq", "PreallocationTools", "SQLite", "SciMLBase", "SparseArrays", "StructArrays", "Tables", "TerminalLoggers", "TimerOutputs", "TranscodingStreams"]
path = "../../core"
uuid = "aac5e3d9-0b8f-4d4f-8241-b1a7a9632635"
version = "0.3.0"
Expand Down
2 changes: 1 addition & 1 deletion build/libribasim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In [3]: argument = create_string_buffer(0)
...: c_dll.init_julia(c_int(0), byref(argument))
Out[3]: 1

In [4]: config_path = "run.toml"
In [4]: config_path = "ribasim.toml"

In [5]: c_dll.initialize(c_char_p(config_path.encode()))
Out[5]: 0
Expand Down
2 changes: 1 addition & 1 deletion build/ribasim_cli/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.3.0"

[[deps.Ribasim]]
deps = ["Arrow", "BasicModelInterface", "CodecLz4", "CodecZstd", "ComponentArrays", "Configurations", "DBInterface", "DataInterpolations", "DataStructures", "Dates", "Dictionaries", "DiffEqCallbacks", "FiniteDiff", "ForwardDiff", "Graphs", "HiGHS", "IterTools", "JuMP", "Legolas", "Logging", "LoggingExtras", "OrdinaryDiffEq", "PreallocationTools", "SQLite", "SciMLBase", "SparseArrays", "StructArrays", "Tables", "TerminalLoggers", "TimeZones", "TimerOutputs", "TranscodingStreams"]
deps = ["Arrow", "BasicModelInterface", "CodecLz4", "CodecZstd", "ComponentArrays", "Configurations", "DBInterface", "DataInterpolations", "DataStructures", "Dates", "Dictionaries", "DiffEqCallbacks", "FiniteDiff", "ForwardDiff", "Graphs", "HiGHS", "IterTools", "JuMP", "Legolas", "Logging", "LoggingExtras", "OrdinaryDiffEq", "PreallocationTools", "SQLite", "SciMLBase", "SparseArrays", "StructArrays", "Tables", "TerminalLoggers", "TimerOutputs", "TranscodingStreams"]
path = "../../core"
uuid = "aac5e3d9-0b8f-4d4f-8241-b1a7a9632635"
version = "0.3.0"
Expand Down
4 changes: 2 additions & 2 deletions build/ribasim_cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ If you have installed Julia and Ribasim, a simulation can also be started from t
line as follows:

```
julia --eval 'using Ribasim; Ribasim.run("path/to/config.toml")'
julia --eval 'using Ribasim; Ribasim.run("path/to/model/ribasim.toml")'
```

With a Ribasim CLI build this becomes:

```
ribasim path/to/config.toml
ribasim path/to/model/ribasim.toml
```
2 changes: 1 addition & 1 deletion build/ribasim_cli/src/ribasim_cli.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Ribasim

function help(x)::Cint
println(x)
println("Usage: ribasim path/to/config.toml")
println("Usage: ribasim path/to/model/ribasim.toml")
return 1
end

Expand Down
12 changes: 6 additions & 6 deletions build/ribasim_cli/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@


@pytest.mark.parametrize(
"model_constructor",
map(ribasim_testmodels.__dict__.get, ribasim_testmodels.__all__),
"model_name,model_constructor",
ribasim_testmodels.constructors.items(),
)
def test_ribasim_cli(model_constructor, tmp_path):
def test_ribasim_cli(model_name, model_constructor, tmp_path):
model = model_constructor()
assert isinstance(model, ribasim.Model)
model.write(tmp_path)
model.write(tmp_path / model_name)

executable = (
Path(__file__).parents[2]
Expand All @@ -22,10 +22,10 @@ def test_ribasim_cli(model_constructor, tmp_path):
/ "bin"
/ "ribasim.exe"
)
config_file = str(tmp_path / f"{model.modelname}.toml")
config_file = str(tmp_path / "ribasim.toml")
result = subprocess.run([executable, config_file])

if model.modelname.startswith("invalid"):
if model_name.startswith("invalid_"):
assert result.returncode != 0
else:
assert result.returncode == 0
19 changes: 14 additions & 5 deletions core/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.9.3"
manifest_format = "2.0"
project_hash = "6a00ca0892e2ca78622bd97e6159a398bf80fa0b"
project_hash = "c63b237aec6a6bf6314284b2b07a94b93a9f0a36"

[[deps.ADTypes]]
git-tree-sha1 = "5d2e21d7b0d8c22f67483ef95ebdc39c0e6b6003"
Expand Down Expand Up @@ -1217,6 +1217,12 @@ deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
version = "1.0.3"

[[deps.TZJData]]
deps = ["Artifacts"]
git-tree-sha1 = "d39314cdbaf5b90a047db33858626f8d1cc973e1"
uuid = "dc5dba14-91b3-4cab-a142-028a31da12f7"
version = "1.0.0+2023c"

[[deps.TableTraits]]
deps = ["IteratorInterfaceExtensions"]
git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
Expand Down Expand Up @@ -1251,11 +1257,14 @@ uuid = "8290d209-cae3-49c0-8002-c8c24d57dab5"
version = "0.5.2"

[[deps.TimeZones]]
deps = ["Dates", "Downloads", "InlineStrings", "LazyArtifacts", "Mocking", "Printf", "RecipesBase", "Scratch", "Unicode"]
git-tree-sha1 = "cdaa0c2a4449724aded839550eca7d7240bb6938"
pinned = true
deps = ["Artifacts", "Dates", "Downloads", "InlineStrings", "LazyArtifacts", "Mocking", "Printf", "Scratch", "TZJData", "Unicode", "p7zip_jll"]
git-tree-sha1 = "89e64d61ef3cd9e80f7fc12b7d13db2d75a23c03"
uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53"
version = "1.10.0"
version = "1.13.0"
weakdeps = ["RecipesBase"]

[deps.TimeZones.extensions]
TimeZonesRecipesBaseExt = "RecipesBase"

[[deps.TimerOutputs]]
deps = ["ExprTools", "Printf"]
Expand Down
2 changes: 1 addition & 1 deletion core/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ SciMLBase = "1.60, 2"
StructArrays = "0.6.13"
Tables = "1"
TerminalLoggers = "0.1.7"
TimeZones = "=1.10.0"
TimeZones = "=1.13.0"
TimerOutputs = "0.5"
TranscodingStreams = "0.9, 0.10"
julia = "1.9"
Expand Down
Loading

0 comments on commit ef0a2cf

Please sign in to comment.