Skip to content

Commit

Permalink
Merge branch 'main' into split_vertical_fluxes
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Mar 25, 2024
2 parents 560f695 + 0acbbed commit c20d4a2
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions utils/generate-testmodels.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import multiprocessing
import shutil
from functools import partial
from pathlib import Path

import ribasim_testmodels


def generate_model(args, datadir):
model_name, model_constructor = args
model = model_constructor()
model.write(datadir / model_name / "ribasim.toml")
return model_name


if __name__ == "__main__":
datadir = Path("generated_testmodels")
if datadir.is_dir():
Expand All @@ -18,7 +28,10 @@
Don't put important stuff in here, it will be emptied for every run."""
)

for model_name, model_constructor in ribasim_testmodels.constructors.items():
print(f"Generating {model_name}")
model = model_constructor()
model.write(datadir / model_name / "ribasim.toml")
generate_model_partial = partial(generate_model, datadir=datadir)

with multiprocessing.Pool(processes=4) as p:
for model_name in p.imap_unordered(
generate_model_partial, ribasim_testmodels.constructors.items()
):
print(f"Generated {model_name}")

0 comments on commit c20d4a2

Please sign in to comment.