Compress after playing all games

This commit is contained in:
andrew authored and Andrew Grant committed 2023-12-04 07:57:33 -05:00
1 parent ca630c80f2
commit ff8c01bf2d
3 files changed
+38 -18

No files matched your search

+26 -9
View File
@@ -42,12 +42,12 @@ from subprocess import PIPE, Popen, call, STDOUT
from itertools import combinations_with_replacement
from concurrent.futures import ThreadPoolExecutor
# from client import BadVersionException
from client import BadVersionException
from client import url_join
from client import try_forever
from pgn_util import compress_list_of_pgns
## Basic configuration of the Client. These timeouts can be changed at will
CLIENT_VERSION = 22 # Client version to send to the Server
@@ -492,12 +492,7 @@ class Cutechess:
@staticmethod
def pgnout_settings(config, timestamp, cutechess_idx):
test_id = int(config.workload['test']['id'])
result_id = int(config.workload['result']['id'])
# Format: <Test>-<Result>-<Time>-<Index>.pgn
return '-pgnout PGNs/%d.%d.%d.%d.pgn' % (test_id, result_id, timestamp, cutechess_idx)
return '-pgnout %s' % (Cutechess.pgn_name(config, timestamp, cutechess_idx))
@staticmethod
def update_results(results, line):
@@ -562,6 +557,16 @@ class Cutechess:
subprocess.run(['taskkill', '/f', '/im', dev_process])
subprocess.run(['taskkill', '/f', '/im', base_process])
@staticmethod
def pgn_name(config, timestamp, cutechess_idx):
test_id = int(config.workload['test']['id'])
result_id = int(config.workload['result']['id'])
# Format: <Test>-<Result>-<Time>-<Index>.pgn
return 'PGNs/%d.%d.%d.%d.pgn' % (test_id, result_id, timestamp, cutechess_idx)
class PGNHelper:
@staticmethod
@@ -694,7 +699,7 @@ class ResultsReporter(object):
for x in range(cutechess_cnt):
# Reuse logic that was given to Cutechess to decide the PGN name
fname = Cutechess.pgnout_settings(self.config, timestamp, x).split()[1]
fname = Cutechess.pgn_name(self.config, timestamp, x)
# For any game with weird Termination, report it
for header, moves in PGNHelper.slice_pgn_file(fname):
@@ -1088,6 +1093,18 @@ def complete_workload(config):
Cutechess.kill_everything(dev_name, base_name)
raise
if config.workload['test']['upload_pgns'] == 'FALSE':
return
compact = config.workload['test']['upload_pgns'] == 'COMPACT'
pgn_files = [Cutechess.pgn_name(config, timestamp, x) for x in range(cutechess_cnt)]
compressed = compress_list_of_pgns(pgn_files, compact)
with open('compressed.pgn.bz2', 'wb') as fout:
fout.write(compressed)
sys.exit()
def download_opening_book(config):
# Log our attempts to download and verify the book