File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33"""
44
55import json
6+ import shutil
7+ import subprocess
68from concurrent .futures import ThreadPoolExecutor
79from pathlib import Path
810
@@ -127,7 +129,29 @@ def _save(self) -> None:
127129 self .local_output_dir .mkdir (parents = True , exist_ok = True )
128130 (self .local_output_dir / "metadata.json" ).write_text (json .dumps (self .get_metadata (), indent = 2 ))
129131
132+ def _compress_round_logs (self ) -> None :
133+ self .logger .info ("Compressing round logs, this might take a while..." )
134+ rounds_dir = self .game .log_local / "rounds"
135+ if not rounds_dir .exists ():
136+ return
137+
138+ cmd = [
139+ "tar" ,
140+ "-zcf" ,
141+ str (self .game .log_local / "rounds.tar.gz" ),
142+ "-C" ,
143+ str (self .game .log_local ),
144+ "rounds" ,
145+ ]
146+ result = subprocess .run (cmd , capture_output = True , text = True )
147+ if result .returncode != 0 :
148+ raise RuntimeError (f"Command failed with exit code { result .returncode } :\n { result .stderr } " )
149+ # Remove the original round logs
150+ shutil .rmtree (self .game .log_local / "rounds" )
151+ self .logger .info ("Round logs compressed successfully" )
152+
130153 def end (self ) -> None :
131154 """Save output files, clean up game resources and push agents if requested."""
132155 self ._save ()
133156 self .game .end (self .cleanup_on_end )
157+ self ._compress_round_logs ()
You can’t perform that action at this time.
0 commit comments