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 19, 2023
1 parent 3db99cb commit d2b5397
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions worker/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,11 @@ 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"option name (EvalFile\w*) type \w+ default (nn-[a-f0-9]{12}.nnue)"
)
print("Obtaining EvalFile of {} ...".format(os.path.basename(engine)))
try:
with subprocess.Popen(
Expand All @@ -243,10 +246,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 +260,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 +1344,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, net in required_nets(base_engine).items():
base_options.append("option.{}={}".format(option_net, 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, net in required_nets(new_engine).items():
new_options.append("option.{}={}".format(option_net, 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": 225, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "Hyq1aYXjX1uofUnSW9EGBXTQN0Jfjz7+LExmFxe6qLQEX1w8vxFQOpWTrRV4YZZz", "games.py": "EJc+euDdPHVDgiYNpnf1BsLc99ZWx8LjjoT8dyLLHXCNakD7jgb8o5/lG/dezhHr"}

0 comments on commit d2b5397

Please sign in to comment.