save config and code state for reproducibility

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2023-04-13 06:01:04 +02:00
parent d51cefabb7
commit b4f3d35f91
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
1 changed files with 13 additions and 0 deletions

View File

@ -2,6 +2,7 @@
import time, sys, random, copy
import importlib
import subprocess
from joblib import Parallel, delayed
from DAS import *
@ -63,6 +64,18 @@ def study():
now = datetime.now()
execID = now.strftime("%Y-%m-%d_%H-%M-%S_")+str(random.randint(100,999))
# save config and code state for reproducibility
if not os.path.exists("results"):
os.makedirs("results")
dir = "results/"+execID
if not os.path.exists(dir):
os.makedirs(dir)
with open(dir+"/git.diff", 'w') as f:
subprocess.run(["git", "diff"], stdout=f)
with open(dir+"/git.describe", 'w') as f:
subprocess.run(["git", "describe", "--always"], stdout=f)
subprocess.run(["cp", sys.argv[1], dir+"/"])
logger.info("Starting simulations:", extra=format)
start = time.time()
results = Parallel(config.numJobs)(delayed(runOnce)(config, shape ,execID) for shape in config.nextShape())