From 1516a7c60f53cf62cf7d1f7491e8ea27e409152e Mon Sep 17 00:00:00 2001
From: Chao Peng <cpeng@anl.gov>
Date: Mon, 5 Dec 2022 14:23:04 -0600
Subject: [PATCH] add a top-level run information output

---
 benchmarks/imaging_shower_ML/config.yml       |  2 +-
 benchmarks/imaging_shower_ML/run_benchmark.py | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/benchmarks/imaging_shower_ML/config.yml b/benchmarks/imaging_shower_ML/config.yml
index bb410998..9b4c829c 100644
--- a/benchmarks/imaging_shower_ML/config.yml
+++ b/benchmarks/imaging_shower_ML/config.yml
@@ -8,6 +8,6 @@ ml_shower:epi_separation:
       if [[ ${DETECTOR} =~ athena
          || ${DETECTOR} =~ ecce && ${DETECTOR_CONFIG} =~ imaging ]] ; then
         pip3 install -r benchmarks/imaging_shower_ML/requirements.txt
-        python3 benchmarks/imaging_shower_ML/run_benchmark.py -t imcal_epi -n 1000 --pmin 1.8 --pmax 2.2 --nocut-samples
+        python3 benchmarks/imaging_shower_ML/run_benchmark.py -t imcal_epi -n 1000 --p-min 1.8 --p-max 2.2
       fi
 
diff --git a/benchmarks/imaging_shower_ML/run_benchmark.py b/benchmarks/imaging_shower_ML/run_benchmark.py
index 0620e040..bc91124a 100755
--- a/benchmarks/imaging_shower_ML/run_benchmark.py
+++ b/benchmarks/imaging_shower_ML/run_benchmark.py
@@ -12,6 +12,7 @@
 '''
 import os
 import sys
+import json
 import subprocess
 import argparse
 
@@ -268,3 +269,16 @@ if __name__ == '__main__':
 
     # TODO: collect the two-step results (e/p cut and ML)
 
+    # save run information
+    # NOTE: runs with the same outdir will be combined (overwrite if nametag is the same)
+    run_data = {args.ntag: kwargs}
+    try:
+        with open(os.path.join(args.outdir, 'result.json'), 'r') as f:
+            run_data = json.load(f)
+            run_data.update({args.ntag: kwargs})
+    except (FileNotFoundError, json.decoder.JSONDecodeError):
+        pass
+
+    with open(os.path.join(args.outdir, 'result.json'), 'w') as f:
+        f.write(json.dumps(run_data, sort_keys=True, indent=4))
+
-- 
GitLab