From 8b57d5dee7f0edcf6de1519877200471900f31b4 Mon Sep 17 00:00:00 2001 From: Eirik Narjord Date: Tue, 12 Nov 2024 10:55:25 -0500 Subject: [PATCH] compressing opt results is optional --- src/optimize.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/optimize.py b/src/optimize.py index ae8285df9..b7ac9a49a 100644 --- a/src/optimize.py +++ b/src/optimize.py @@ -60,7 +60,7 @@ def make_json_serializable(obj): return obj -def results_writer_process(queue: Queue, results_filename: str): +def results_writer_process(queue: Queue, results_filename: str, compress=True): """ Manager process that handles writing results to file. Runs in a separate process and receives results through a queue. @@ -73,8 +73,8 @@ def results_writer_process(queue: Queue, results_filename: str): if data == "DONE": # Sentinel value to signal shutdown break try: - if prev_data is None: - # First data entry, write full data + if prev_data is None or not compress: + # First data entry or compression disabled, write full data output_data = data else: # Compute diff of the entire data dictionary @@ -428,7 +428,9 @@ async def main(): manager = multiprocessing.Manager() results_queue = manager.Queue() writer_process = Process( - target=results_writer_process, args=(results_queue, config["results_filename"]) + target=results_writer_process, + args=(results_queue, config["results_filename"]), + kwargs={"compress": config["optimize"]["compress_results_file"]}, ) writer_process.start()