From b4f3d35f91aa869217936db1b62f3d32e4897278 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Thu, 13 Apr 2023 06:01:04 +0200 Subject: [PATCH 1/2] save config and code state for reproducibility Signed-off-by: Csaba Kiraly --- study.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/study.py b/study.py index 74dba63..8d6c088 100644 --- a/study.py +++ b/study.py @@ -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()) From ebe1a4c87b1f6b37e2ca598bad49c217a67b47ca Mon Sep 17 00:00:00 2001 From: Leonardo Bautista-Gomez Date: Mon, 17 Apr 2023 12:14:39 +0200 Subject: [PATCH 2/2] Make git save an option for when code is downloaded instead of cloned --- config_example.py | 3 +++ study.py | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config_example.py b/config_example.py index 39a0591..7c2267c 100644 --- a/config_example.py +++ b/config_example.py @@ -79,6 +79,9 @@ steps4StopCondition = 7 # If True, print diagnostics when the block is not available diagnostics = False +# True to save git diff and git commit +saveGit = False + def nextShape(): for run, fr, class1ratio, chi, vpn1, vpn2, blockSize, nn, netDegree, bwUplinkProd, bwUplink1, bwUplink2 in itertools.product( runs, failureRates, class1ratios, chis, validatorsPerNode1, validatorsPerNode2, blockSizes, numberNodes, netDegrees, bwUplinksProd, bwUplinks1, bwUplinks2): diff --git a/study.py b/study.py index 8d6c088..6fb9340 100644 --- a/study.py +++ b/study.py @@ -70,10 +70,11 @@ def study(): 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) + if config.saveGit: + 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)