Skip to content

Commit

Permalink
Generalize the EvalFile net option
Browse files Browse the repository at this point in the history
  • Loading branch information
ppigazzini committed Dec 20, 2023
1 parent 3db99cb commit 04a1794
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion server/fishtest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
on how frequently the main instance flushes its run cache.
"""

WORKER_VERSION = 225
WORKER_VERSION = 226

"""
begin api_schema
Expand Down
32 changes: 15 additions & 17 deletions worker/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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))
Expand All @@ -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():
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion worker/sri.txt
Original file line number Diff line number Diff line change
@@ -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+"}
2 changes: 1 addition & 1 deletion worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 04a1794

Please sign in to comment.