Skip to content

Commit

Permalink
Scripts: Update SBATCH and MPIEvaluator test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoutH committed Aug 31, 2023
1 parent 6fb15e3 commit 806dbb8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
18 changes: 14 additions & 4 deletions scripts/ema_model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import numpy as np
import pickle
import time

from ema_workbench import Model, RealParameter, ScalarOutcome, perform_experiments
from ema_workbench import Model, RealParameter, ScalarOutcome
from ema_workbench.em_framework.evaluators import MPIEvaluator


def some_model(x1=None, x2=None, x3=None):
return {"y": x1 * x2 + x3}
# Print current time in seconds, HH:MM;SS, without the date
print(f"Starting: {time.strftime('%H:%M:%S', time.localtime())}")
# Sleep 10 seconds
time.sleep(1)
y = x1 * x2 + x3
print(f"Ending: {time.strftime('%H:%M:%S', time.localtime())}, y = {y}")

return {"y": y}



if __name__ == "__main__":
Expand All @@ -20,7 +29,8 @@ def some_model(x1=None, x2=None, x3=None):
# specify outcomes
model.outcomes = [ScalarOutcome("y")]

results = perform_experiments(model, 25)
with MPIEvaluator(model) as evaluator:
results = evaluator.perform_experiments(scenarios=100)

with open("ema_test.pickle", "wb") as handle:
pickle.dump(results, handle, protocol=pickle.HIGHEST_PROTOCOL)
9 changes: 6 additions & 3 deletions scripts/test_script.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

#SBATCH --job-name="Python_test"
#SBATCH --time=00:00:10
#SBATCH --ntasks=10
#SBATCH --time=00:02:00
#SBATCH --ntasks=100
#SBATCH --cpus-per-task=1
#SBATCH --partition=compute
#SBATCH --mem-per-cpu=1GB
Expand All @@ -13,5 +13,8 @@ module load openmpi
module load python
module load py-numpy
module load py-mpi4py
module load py-pip

mpiexec -n 10 python -m mpi4py.futures my_model.py > py_test.log
python -m pip install --user -U -e git+https://github.com/quaquel/EMAworkbench@multi-node-development#egg=ema-workbench

mpiexec -n 100 python -m mpi4py.futures ema_model.py > ema_test.log

0 comments on commit 806dbb8

Please sign in to comment.