From 04a17943a1407a94c887a02b759e5e343d3d5a79 Mon Sep 17 00:00:00 2001 From: ppigazzini Date: Tue, 19 Dec 2023 21:43:51 +0100 Subject: [PATCH] Generalize the EvalFile net option --- server/fishtest/api.py | 2 +- worker/games.py | 32 +++++++++++++++----------------- worker/sri.txt | 2 +- worker/worker.py | 2 +- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/server/fishtest/api.py b/server/fishtest/api.py index 33a2bb6bbe..c559306e3e 100644 --- a/server/fishtest/api.py +++ b/server/fishtest/api.py @@ -28,7 +28,7 @@ on how frequently the main instance flushes its run cache. """ -WORKER_VERSION = 225 +WORKER_VERSION = 226 """ begin api_schema diff --git a/worker/games.py b/worker/games.py index 27ad9ea18e..310e01537f 100644 --- a/worker/games.py +++ b/worker/games.py @@ -231,8 +231,9 @@ def github_api(repo): return repo.replace("https://github.com", "https://api.github.com/repos") -def required_net(engine): - net = None +def required_nets(engine): + nets = {} + pattern = re.compile(r"(EvalFile\w*)\s+.*\s+(nn-[a-f0-9]{12}.nnue)") print("Obtaining EvalFile of {} ...".format(os.path.basename(engine))) try: with subprocess.Popen( @@ -243,10 +244,10 @@ def required_net(engine): close_fds=not IS_WINDOWS, ) as p: for line in iter(p.stdout.readline, ""): - if "EvalFile" in line: - m = re.search("nn-[a-f0-9]{12}.nnue", line) - if m: - net = m.group(0) + match = pattern.search(line) + if match: + nets[match.group(1)] = match.group(2) + except (OSError, subprocess.SubprocessError) as e: raise WorkerException( "Unable to obtain name for required net. Error: {}".format(str(e)) @@ -257,7 +258,7 @@ def required_net(engine): "UCI exited with non-zero code {}".format(format_return_code(p.returncode)) ) - return net + return nets def required_nets_from_source(): @@ -1341,17 +1342,14 @@ def parse_options(s): file=sys.stderr, ) - # Add EvalFile with full path to cutechess options, and download the networks if missimg. - net_base = required_net(base_engine) - if net_base: - base_options = base_options + ["option.EvalFile={}".format(net_base)] - net_new = required_net(new_engine) - if net_new: - new_options = new_options + ["option.EvalFile={}".format(net_new)] + # Add EvalFile* with full path to cutechess options, and download the networks if missimg. + for option, net in required_nets(base_engine).items(): + base_options.append("option.{}={}".format(option, net)) + establish_validated_net(remote, testing_dir, net) - for net in (net_base, net_new): - if net: - establish_validated_net(remote, testing_dir, net) + for option, net in required_nets(new_engine).items(): + new_options.append("option.{}={}".format(option, net)) + establish_validated_net(remote, testing_dir, net) # PGN files output setup. pgn_name = "results-" + worker_info["unique_key"] + ".pgn" diff --git a/worker/sri.txt b/worker/sri.txt index a4d55bbd25..fcd505ff3d 100644 --- a/worker/sri.txt +++ b/worker/sri.txt @@ -1 +1 @@ -{"__version": 225, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "Hyq1aYXjX1uofUnSW9EGBXTQN0Jfjz7+LExmFxe6qLQEX1w8vxFQOpWTrRV4YZZz", "games.py": "7szyHwmVhZxkiiEjEOXjCrYnys7P5aAUBef5HFa2yh8FSBXggHGKAS2G0+Qq8KsP"} +{"__version": 226, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "AlzBfLw8QpQx5mQmOXedSHxcBG5v+Jw5pyW3gTeUsdDzi+23Jhf7T8gcIUGQFu0A", "games.py": "ef8FgL7dNT3ALVmuWQA/WoLu6y5khfJR5Ji2KOaLPu4oAnEJdWt8u1hLlObie47+"} diff --git a/worker/worker.py b/worker/worker.py index 0b36f5658e..d1a34a84d4 100644 --- a/worker/worker.py +++ b/worker/worker.py @@ -55,7 +55,7 @@ # Several packages are called "expression". # So we make sure to use the locally installed one. -WORKER_VERSION = 225 +WORKER_VERSION = 226 FILE_LIST = ["updater.py", "worker.py", "games.py"] HTTP_TIMEOUT = 30.0 INITIAL_RETRY_TIME = 15.0