From e0c1680f2deec8b87a667223a00eaddca615d43b Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Mon, 3 Feb 2025 11:21:00 +0100 Subject: [PATCH] Update to Julia 1.11 --- Manifest.toml | 73 +++++++++++++++++++++++++++++++++------------ build/build.jl | 4 +-- core/Project.toml | 4 +-- core/src/Ribasim.jl | 32 ++++---------------- core/src/logging.jl | 2 +- core/src/main.jl | 4 +-- core/src/read.jl | 6 ++-- pixi.toml | 2 +- utils/gen_python.jl | 52 +++++++++++++++++--------------- 9 files changed, 97 insertions(+), 82 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index f5050b0fc..b768e65da 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.10.8" +julia_version = "1.11.3" manifest_format = "2.0" project_hash = "921c2f0c042509feb4a1950ec24084c1ad561dd0" @@ -90,7 +90,7 @@ version = "2.4.0" [[deps.ArgTools]] uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" -version = "1.1.1" +version = "1.1.2" [[deps.ArnoldiMethod]] deps = ["LinearAlgebra", "Random", "StaticArrays"] @@ -154,6 +154,7 @@ version = "2.3.0" [[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" +version = "1.11.0" [[deps.Automa]] deps = ["PrecompileTools", "SIMD", "TranscodingStreams"] @@ -175,6 +176,7 @@ version = "0.4.7" [[deps.Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +version = "1.11.0" [[deps.BasicModelInterface]] git-tree-sha1 = "ca36dc6dc9bbeea3dbbe3901837496ece85276e5" @@ -228,6 +230,7 @@ version = "0.2.6" [[deps.CRC32c]] uuid = "8bf52ea8-c179-5cab-976a-9e18b702a9bc" +version = "1.11.0" [[deps.CRlibm_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] @@ -316,13 +319,11 @@ deps = ["FixedPointNumbers", "Random"] git-tree-sha1 = "c7acce7a7e1078a20a285211dd73cd3941a871d6" uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" version = "0.12.0" +weakdeps = ["StyledStrings"] [deps.ColorTypes.extensions] StyledStringsExt = "StyledStrings" - [deps.ColorTypes.weakdeps] - StyledStrings = "f489334b-da3d-4c2e-b8f0-e476e12c162b" - [[deps.ColorVectorSpace]] deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "Requires", "Statistics", "TensorCore"] git-tree-sha1 = "8b3b6f87ce8f65a2b4f857528fd8d70086cd72b1" @@ -506,6 +507,7 @@ version = "1.0.0" [[deps.Dates]] deps = ["Printf"] uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" +version = "1.11.0" [[deps.DelaunayTriangulation]] deps = ["AdaptivePredicates", "EnumX", "ExactPredicates", "Random"] @@ -619,6 +621,7 @@ version = "0.1.6" [[deps.Distributed]] deps = ["Random", "Serialization", "Sockets"] uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" +version = "1.11.0" [[deps.Distributions]] deps = ["AliasTables", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"] @@ -787,6 +790,7 @@ weakdeps = ["Mmap", "Test"] [[deps.FileWatching]] uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" +version = "1.11.0" [[deps.FillArrays]] deps = ["LinearAlgebra"] @@ -894,6 +898,7 @@ version = "0.5.2" [[deps.Future]] deps = ["Random"] uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" +version = "1.11.0" [[deps.GPUArraysCore]] deps = ["Adapt"] @@ -1088,6 +1093,7 @@ version = "2025.0.4+0" [[deps.InteractiveUtils]] deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +version = "1.11.0" [[deps.Interpolations]] deps = ["Adapt", "AxisAlgorithms", "ChainRulesCore", "LinearAlgebra", "OffsetArrays", "Random", "Ratios", "Requires", "SharedArrays", "SparseArrays", "StaticArrays", "WoodburyMatrices"] @@ -1291,6 +1297,7 @@ version = "2.4.0" [[deps.LazyArtifacts]] deps = ["Artifacts", "Pkg"] uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3" +version = "1.11.0" [[deps.LazyModules]] git-tree-sha1 = "a560dd966b386ac9ae60bdd3a3d3a326062d3c3e" @@ -1321,16 +1328,17 @@ version = "0.6.4" [[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "8.4.0+0" +version = "8.6.0+0" [[deps.LibGit2]] deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +version = "1.11.0" [[deps.LibGit2_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" -version = "1.6.4+0" +version = "1.7.2+0" [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] @@ -1339,6 +1347,7 @@ version = "1.11.0+1" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +version = "1.11.0" [[deps.Libffi_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] @@ -1407,6 +1416,7 @@ version = "7.3.0" [[deps.LinearAlgebra]] deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +version = "1.11.0" [[deps.LinearSolve]] deps = ["ArrayInterface", "ChainRulesCore", "ConcreteStructs", "DocStringExtensions", "EnumX", "FastLapackInterface", "GPUArraysCore", "InteractiveUtils", "KLU", "Krylov", "LazyArrays", "Libdl", "LinearAlgebra", "MKL_jll", "Markdown", "PrecompileTools", "Preferences", "RecursiveFactorization", "Reexport", "SciMLBase", "SciMLOperators", "Setfield", "SparseArrays", "Sparspak", "StaticArraysCore", "UnPack"] @@ -1462,6 +1472,7 @@ version = "0.3.29" [[deps.Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" +version = "1.11.0" [[deps.LoggingExtras]] deps = ["Dates", "Logging"] @@ -1533,6 +1544,7 @@ version = "0.4.2" [[deps.Markdown]] deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" +version = "1.11.0" [[deps.MarkdownTables]] deps = ["ArgCheck", "DisplayAs", "DocStringExtensions", "Tables"] @@ -1571,7 +1583,7 @@ version = "1.1.9" [[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.28.2+1" +version = "2.28.6+0" [[deps.MetaGraphsNext]] deps = ["Graphs", "JLD2", "SimpleTraits"] @@ -1587,6 +1599,7 @@ version = "1.2.0" [[deps.Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" +version = "1.11.0" [[deps.Mocking]] deps = ["Compat", "ExprTools"] @@ -1602,7 +1615,7 @@ version = "0.3.4" [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2023.1.10" +version = "2023.12.12" [[deps.MuladdMacro]] git-tree-sha1 = "cac9cc5499c25554cba55cd3c30543cff5ca4fab" @@ -1742,7 +1755,7 @@ version = "1.3.5+1" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.23+4" +version = "0.3.27+1" [[deps.OpenEXR]] deps = ["Colors", "FileIO", "OpenEXR_jll"] @@ -1908,9 +1921,13 @@ uuid = "30392449-352a-5448-841d-b1acce4e97dc" version = "0.43.4+0" [[deps.Pkg]] -deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.10.0" +version = "1.11.0" +weakdeps = ["REPL"] + + [deps.Pkg.extensions] + REPLExt = "REPL" [[deps.PkgVersion]] deps = ["Pkg"] @@ -1980,10 +1997,11 @@ version = "2.4.0" [[deps.Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" +version = "1.11.0" [[deps.Profile]] -deps = ["Printf"] uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" +version = "1.11.0" [[deps.ProgressLogging]] deps = ["Logging", "SHA", "UUIDs"] @@ -2021,12 +2039,14 @@ version = "2.11.1" Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" [[deps.REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] +deps = ["InteractiveUtils", "Markdown", "Sockets", "StyledStrings", "Unicode"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" +version = "1.11.0" [[deps.Random]] deps = ["SHA"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +version = "1.11.0" [[deps.RangeArrays]] git-tree-sha1 = "b9039e93773ddcfc828f12aadf7115b4b4d225f5" @@ -2238,6 +2258,7 @@ version = "1.4.8" [[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" +version = "1.11.0" [[deps.Setfield]] deps = ["ConstructionBase", "Future", "MacroTools", "StaticArraysCore"] @@ -2254,6 +2275,7 @@ version = "0.5.0" [[deps.SharedArrays]] deps = ["Distributed", "Mmap", "Random", "Serialization"] uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" +version = "1.11.0" [[deps.Showoff]] deps = ["Dates", "Grisu"] @@ -2304,6 +2326,7 @@ version = "0.1.3" [[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" +version = "1.11.0" [[deps.SoftGlobalScope]] deps = ["REPL"] @@ -2320,7 +2343,7 @@ version = "1.2.1" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -version = "1.10.0" +version = "1.11.0" [[deps.SparseConnectivityTracer]] deps = ["ADTypes", "DocStringExtensions", "FillArrays", "LinearAlgebra", "Random", "SparseArrays"] @@ -2434,9 +2457,14 @@ uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" version = "1.4.3" [[deps.Statistics]] -deps = ["LinearAlgebra", "SparseArrays"] +deps = ["LinearAlgebra"] +git-tree-sha1 = "ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0" uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -version = "1.10.0" +version = "1.11.1" +weakdeps = ["SparseArrays"] + + [deps.Statistics.extensions] + SparseArraysExt = ["SparseArrays"] [[deps.StatsAPI]] deps = ["LinearAlgebra"] @@ -2505,6 +2533,10 @@ git-tree-sha1 = "159331b30e94d7b11379037feeb9b690950cace8" uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4" version = "1.11.0" +[[deps.StyledStrings]] +uuid = "f489334b-da3d-4c2e-b8f0-e476e12c162b" +version = "1.11.0" + [[deps.SuiteSparse]] deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"] uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" @@ -2512,7 +2544,7 @@ uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" [[deps.SuiteSparse_jll]] deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" -version = "7.2.1+1" +version = "7.7.0+0" [[deps.SymbolicIndexingInterface]] deps = ["Accessors", "ArrayInterface", "RuntimeGeneratedFunctions", "StaticArraysCore"] @@ -2563,6 +2595,7 @@ version = "0.1.7" [[deps.Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +version = "1.11.0" [[deps.TestEnv]] deps = ["Pkg"] @@ -2634,6 +2667,7 @@ version = "1.4.0" [[deps.UUIDs]] deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +version = "1.11.0" [[deps.UnPack]] git-tree-sha1 = "387c1f73762231e86e0c9c5443ce3b4a0a9a0c2b" @@ -2642,6 +2676,7 @@ version = "1.0.2" [[deps.Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +version = "1.11.0" [[deps.UnicodeFun]] deps = ["REPL"] @@ -2846,7 +2881,7 @@ version = "1.5.0+0" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.52.0+1" +version = "1.59.0+0" [[deps.oneTBB_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] diff --git a/build/build.jl b/build/build.jl index 8e43d0cae..54e61fe2d 100644 --- a/build/build.jl +++ b/build/build.jl @@ -3,7 +3,7 @@ using PackageCompiler using TOML using LibGit2 -function main() +function (@main)() project_dir = "../core" license_file = "../LICENSE" output_dir = "ribasim" @@ -120,5 +120,3 @@ function add_metadata(project_dir, license_file, output_dir, git_repo, readme) # Override the Cargo.toml file with the git version set_version("cli/Cargo.toml", tag) end - -main() diff --git a/core/Project.toml b/core/Project.toml index 33fdf7f95..aac1ae353 100644 --- a/core/Project.toml +++ b/core/Project.toml @@ -61,7 +61,7 @@ Arrow = "2.3" BasicModelInterface = "0.1" CSV = "0.10" CodecZstd = "0.7, 0.8" -ComponentArrays = "0.13, 0.14, 0.15" +ComponentArrays = "0.13, 0.14, 0.15 - 0.15.22" Configurations = "0.17" DBInterface = "2.4" DataFrames = "1.4" @@ -105,7 +105,7 @@ TerminalLoggers = "0.1.7" Test = "1" TestItemRunner = "1" TranscodingStreams = "0.9, 0.10, 0.11" -julia = "1.10" +julia = "1.11" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" diff --git a/core/src/Ribasim.jl b/core/src/Ribasim.jl index ef06382dc..58ba3e05c 100644 --- a/core/src/Ribasim.jl +++ b/core/src/Ribasim.jl @@ -15,13 +15,8 @@ For more granular access, see: module Ribasim # Algorithms for solving ODEs. -using OrdinaryDiffEqCore: - OrdinaryDiffEqCore, - OrdinaryDiffEqRosenbrockAdaptiveAlgorithm, - get_du, - AbstractNLSolver, - calculate_residuals! -using DiffEqBase: DiffEqBase +using OrdinaryDiffEqCore: OrdinaryDiffEqCore, get_du, AbstractNLSolver +using DiffEqBase: DiffEqBase, calculate_residuals! using OrdinaryDiffEqNonlinearSolve: OrdinaryDiffEqNonlinearSolve, relax!, _compute_rhs! using LineSearches: BackTracking @@ -32,13 +27,10 @@ using SciMLBase: step!, check_error!, SciMLBase, - ReturnCode, successful_retcode, CallbackSet, ODEFunction, ODEProblem, - ODESolution, - VectorContinuousCallback, get_proposed_dt, DEIntegrator @@ -92,7 +84,7 @@ using SQLite: SQLite, DB, Query, esc_id using DBInterface: execute # Logging to both the console and a file -using Logging: with_logger, @logmsg, LogLevel, AbstractLogger +using Logging: Logging, with_logger, @logmsg, LogLevel, AbstractLogger import LoggingExtras using TerminalLoggers: TerminalLogger @@ -109,25 +101,13 @@ using Dates: Dates, DateTime, Millisecond, @dateformat_str # E.g. after each timestep for discrete control, # or at each saveat for saving storage and flow results. using DiffEqCallbacks: - FunctionCallingCallback, - PeriodicCallback, - PresetTimeCallback, - SavedValues, - SavingCallback + FunctionCallingCallback, PresetTimeCallback, SavedValues, SavingCallback # The network defined by the Node and Link table is converted to a graph internally. -using Graphs: - DiGraph, Edge, edges, inneighbors, nv, outneighbors, induced_subgraph, is_connected +using Graphs: DiGraph, edges, inneighbors, outneighbors, induced_subgraph, is_connected # Convenience functionality built on top of Graphs. Used to store e.g. node and edge metadata # alongside the graph. Extra metadata is stored in a NamedTuple retrieved as graph[]. -using MetaGraphsNext: - MetaGraphsNext, - MetaGraph, - label_for, - code_for, - labels, - outneighbor_labels, - inneighbor_labels +using MetaGraphsNext: MetaGraphsNext, MetaGraph, label_for, code_for, labels # Improved enumeration type compared to Base, used for e.g. node types. using EnumX: EnumX, @enumx diff --git a/core/src/logging.jl b/core/src/logging.jl index 7d40228c7..f87362107 100644 --- a/core/src/logging.jl +++ b/core/src/logging.jl @@ -31,7 +31,7 @@ function log_bottlenecks(model; converged::Bool) (; cache, p, u) = model.integrator (; basin) = p - level = converged ? LoggingExtras.Info : LoggingExtras.Warn + level = converged ? Logging.Info : Logging.Warn # Indicate convergence bottlenecks if possible with the current algorithm if hasproperty(cache, :nlsolver) diff --git a/core/src/main.jl b/core/src/main.jl index 95eb43764..818aa2249 100644 --- a/core/src/main.jl +++ b/core/src/main.jl @@ -14,13 +14,11 @@ function run(config::Config)::Model return model end -main(ARGS::Vector{String})::Cint = main(only(ARGS)) -main()::Cint = main(ARGS) +(@main)(args::Vector{String})::Cint = main(only(args)) """ main(toml_path::AbstractString)::Cint main(ARGS::Vector{String})::Cint - main()::Cint This is the main entry point of the application. Performs argument parsing and sets up logging for both terminal and file. diff --git a/core/src/read.jl b/core/src/read.jl index 92c48f2c0..496d5fb43 100644 --- a/core/src/read.jl +++ b/core/src/read.jl @@ -1591,8 +1591,8 @@ end function get_node_ids(db::DB)::Vector{NodeID} nt = get_node_ids_types(db) - node_ids = Vector{Ribasim.NodeID}(undef, length(nt.node_id)) - count = counter(Ribasim.NodeType.T) + node_ids = Vector{NodeID}(undef, length(nt.node_id)) + count = counter(NodeType.T) for (i, (; node_id, node_type)) in enumerate(Tables.rows(nt)) index = inc!(count, node_type) node_ids[i] = NodeID(node_type, node_id, index) @@ -1613,7 +1613,7 @@ end function get_node_ids(db::DB, node_type)::Vector{NodeID} node_type = NodeType.T(node_type) node_ints = get_node_ids_int32(db, node_type) - node_ids = Vector{Ribasim.NodeID}(undef, length(node_ints)) + node_ids = Vector{NodeID}(undef, length(node_ints)) for (index, node_int) in enumerate(node_ints) node_ids[index] = NodeID(node_type, node_int, index) end diff --git a/pixi.toml b/pixi.toml index 4f8ed0f8a..feda9e589 100644 --- a/pixi.toml +++ b/pixi.toml @@ -18,7 +18,7 @@ test-ribasim-python = "pytest --numprocesses=4 -m 'not regression' python/ribasi test-ribasim-python-cov = "pytest --numprocesses=4 --cov=ribasim --cov-report=xml -m 'not regression' python/ribasim/tests" test-ribasim-api = "pytest --basetemp=python/ribasim_api/tests/temp --junitxml=report.xml python/ribasim_api/tests" # Installation -install-julia = "juliaup add 1.10.8 && juliaup override set 1.10.8" +install-julia = "juliaup add 1.11.3 && juliaup override set 1.11.3" install-pre-commit = "pre-commit install" # Note that this has a Windows specific override install-ci = { depends-on = ["install-julia", "update-registry-julia"] } diff --git a/utils/gen_python.jl b/utils/gen_python.jl index d102dd223..fd2839a2f 100644 --- a/utils/gen_python.jl +++ b/utils/gen_python.jl @@ -1,9 +1,8 @@ -using Configurations -using Dates -using InteractiveUtils -using Legolas -using OteraEngine -using Ribasim +import Legolas +import Ribasim +using Dates: DateTime +using InteractiveUtils: subtypes +using OteraEngine: Template pythontype(::Type{Union{Missing, T}}) where {T} = pythontype(T) pythontype(::Type{<:AbstractString}) = "Series[Annotated[pd.ArrowDtype, pyarrow.string()]]" @@ -39,19 +38,6 @@ function get_models() ] end -# Setup template with whitespace settings that mainly strips whitespace. -# See schemas.py.jinja for the layout of the template. -model_template = Template( - normpath(@__DIR__, "templates", "schemas.py.jinja"); - config = Dict("trim_blocks" => true, "lstrip_blocks" => true, "autoescape" => false), -) - -# Write schemas.py -open(normpath(@__DIR__, "..", "python", "ribasim", "ribasim", "schemas.py"), "w") do io - init = Dict(:models => get_models()) - println(io, model_template(; init = init)) -end - function get_connectivity() """ Set up a vector contains all possible connecting node for all node types. @@ -68,13 +54,31 @@ function get_connectivity() ] end -connection_template = Template( +# Setup template with whitespace settings that mainly strips whitespace. +# See schemas.py.jinja for the layout of the template. +MODEL_TEMPLATE = Template( + normpath(@__DIR__, "templates", "schemas.py.jinja"); + config = Dict("trim_blocks" => true, "lstrip_blocks" => true, "autoescape" => false), +) + +CONNECTION_TEMPLATE = Template( normpath(@__DIR__, "templates", "validation.py.jinja"); config = Dict("trim_blocks" => true, "lstrip_blocks" => true, "autoescape" => false), ) -# Write validation.py -open(normpath(@__DIR__, "..", "python", "ribasim", "ribasim", "validation.py"), "w") do io - init = Dict(:nodes => get_connectivity()) - println(io, connection_template(; init = init)) +function (@main)(_) + # Write schemas.py + open(normpath(@__DIR__, "..", "python", "ribasim", "ribasim", "schemas.py"), "w") do io + init = Dict(:models => get_models()) + println(io, MODEL_TEMPLATE(; init = init)) + end + + # Write validation.py + open( + normpath(@__DIR__, "..", "python", "ribasim", "ribasim", "validation.py"), + "w", + ) do io + init = Dict(:nodes => get_connectivity()) + println(io, CONNECTION_TEMPLATE(; init = init)) + end end