Skip to content

Commit

Permalink
compressing opt results is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
enarjord committed Nov 12, 2024
1 parent 7ba59e5 commit 8b57d5d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 8b57d5d

Please sign in to comment.