From 9daf97335e7467eebae22759a45fca5d6afea173 Mon Sep 17 00:00:00 2001 From: Matthias Saimpert Date: Thu, 6 Feb 2025 13:29:00 +0000 Subject: [PATCH] fix TimeStart, TimeEnd and TimeDuration for compilation of yarr scans... (cherry picked from commit 8cde3c6eead82a8c9c66ad39fcf7a937190b4cc1) ff21945e fix TimeStart, TimeEnd and TimeDuration for compilation of yarr scans... ee63fec7 bugfix Co-authored-by: Matthias Saimpert --- viewer/functions/checkouter.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/viewer/functions/checkouter.py b/viewer/functions/checkouter.py index 0bc9f4a42..ba221f307 100644 --- a/viewer/functions/checkouter.py +++ b/viewer/functions/checkouter.py @@ -404,23 +404,22 @@ class ScanCheckoutManager: if os.path.exists(path + "/scans.json"): shutil.rmtree(path) + start_times = [] + end_times = [] + for i, tr_id in enumerate(commit_doc): query = {"_id": ObjectId(tr_id)} tr_doc = localdb.testRun.find_one(query) yarr_version = tr_doc["yarr_version"]["git_tag"] - start_time = int(tr_doc["startTime"].timestamp()) + start_times.append(int(tr_doc["startTime"].timestamp())) + end_times.append(int(tr_doc["finishTime"].timestamp())) if i == 0: config_file["module"]["chipType"] = tr_doc["chipType"] config_file["YARR_VERSION"] = yarr_version - config_file["TimeStart"] = start_time else: if yarr_version != config_file["YARR_VERSION"]: msg = f"Scans were not obtained with the same YARR version: {config_file['YARR_VERSION']} and {yarr_version}." raise RuntimeError(msg) - if ( - start_time < config_file["TimeStart"] - ): # find the earliest possible starting time from all scans - config_file["TimeStart"] = start_time this_dir = tr_doc["testType"] os.makedirs(path + "/" + this_dir, exist_ok=True) @@ -552,6 +551,13 @@ class ScanCheckoutManager: logger.error(f"failed in dumping file to {filepath}") j += 1 + config_file["TimeStart"] = min(start_times) + config_file["TimeEnd"] = max(end_times) + config_file["TimeDuration"] = sum( + end_time - start_time + for start_time, end_time in zip(start_times, end_times) + ) + logger.info("config_file = \n" + pprint.pformat(config_file)) logger.debug(path + "/scans.json") -- GitLab