Skip to content

Commit

Permalink
Update to the renamed fastchess (no-hyphen)
Browse files Browse the repository at this point in the history
  • Loading branch information
vondele committed Jul 27, 2024
1 parent 525c6e8 commit 2e227a0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
26 changes: 13 additions & 13 deletions worker/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,13 +923,13 @@ def shorten_hash(match):
# Parse line like this:
# Warning: New-SHA doesn't have option ThreatBySafePawn
if "Warning:" in line and "doesn't have option" in line:
message = r'fast-chess says: "{}"'.format(line)
message = r'fastchess says: "{}"'.format(line)
raise RunException(message)

# Parse line like this:
# Warning: Invalid value for option P: -354
if "Warning:" in line and "Invalid value" in line:
message = r'fast-chess says: "{}"'.format(line)
message = r'fastchess says: "{}"'.format(line)
raise RunException(message)

# Parse line like this:
Expand All @@ -940,7 +940,7 @@ def shorten_hash(match):
if "on time" in line:
result["stats"]["time_losses"] += 1

# fast-chess WLD and pentanomial output parsing
# fastchess WLD and pentanomial output parsing
m = pattern_WLD.search(line)
if m:
try:
Expand Down Expand Up @@ -1083,7 +1083,7 @@ def launch_fastchess(
w_params = []
b_params = []

# Run fast-chess binary.
# Run fastchess binary.
# Stochastic rounding and probability for float N.p: (N, 1-p); (N+1, p)
idx = cmd.index("_spsa_")
cmd = (
Expand Down Expand Up @@ -1141,13 +1141,13 @@ def launch_fastchess(
tc_limit,
)
finally:
# We nicely ask fast-chess to stop.
# We nicely ask fastchess to stop.
try:
send_sigint(p)
except Exception as e:
print("\nException in send_sigint:\n", e, sep="", file=sys.stderr)
# now wait...
print("\nWaiting for fast-chess to finish ... ", end="", flush=True)
print("\nWaiting for fastchess to finish ... ", end="", flush=True)
try:
p.wait(timeout=FASTCHESS_KILL_TIMEOUT)
except subprocess.TimeoutExpired:
Expand All @@ -1157,12 +1157,12 @@ def launch_fastchess(
print("done", flush=True)
except (OSError, subprocess.SubprocessError) as e:
print(
"Exception starting fast-chess:\n",
"Exception starting fastchess:\n",
e,
sep="",
file=sys.stderr,
)
raise WorkerException("Unable to start fast-chess. Error: {}".format(str(e)))
raise WorkerException("Unable to start fastchess. Error: {}".format(str(e)))

return task_alive

Expand All @@ -1178,7 +1178,7 @@ def run_games(
clear_binaries,
global_cache,
):
# This is the main fast-chess driver.
# This is the main fastchess driver.
# It is ok, and even expected, for this function to
# raise exceptions, implicitly or explicitly, if a
# task cannot be completed.
Expand Down Expand Up @@ -1246,7 +1246,7 @@ def run_games(
start_game_index = opening_offset + input_total_games
run_seed = int(hashlib.sha1(run["_id"].encode("utf-8")).hexdigest(), 16) % (2**64)

# Format options according to fast-chess syntax.
# Format options according to fastchess syntax.
def parse_options(s):
results = []
chunks = s.split("=")
Expand Down Expand Up @@ -1348,7 +1348,7 @@ def parse_options(s):
file=sys.stderr,
)

# Add EvalFile* with full path to fast-chess options, and download the networks if missing.
# Add EvalFile* with full path to fastchess options, and download the networks if missing.
for option, net in required_nets(base_engine).items():
base_options.append("option.{}={}".format(option, net))
establish_validated_net(remote, testing_dir, net, global_cache)
Expand Down Expand Up @@ -1478,8 +1478,8 @@ def make_player(arg):
if any(substring in book.upper() for substring in ["FRC", "960"]):
variant = "fischerandom"

# Run fast-chess binary.
fastchess = "fast-chess" + EXE_SUFFIX
# Run fastchess binary.
fastchess = "fastchess" + EXE_SUFFIX
cmd = (
[
os.path.join(testing_dir, fastchess),
Expand Down
2 changes: 1 addition & 1 deletion worker/sri.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"__version": 242, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "Pxo7PbstsI9ZyRBdzHVzQu+A89WaGcVL6fDFM1KXZGvAhMKHZxVB3XEvjewddRMw", "games.py": "BzNVX1zlHRuMtutT24IaZHA1O0f8EOL0aiPQUB3ET9G8vf4ig6W+FSza3JRdIi6M"}
{"__version": 242, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "cByOSq6A68BXEYsaY62BMPesVU/KRe9J1XcTFib97wLO7jK3+acHfQ3C8xzt6aCK", "games.py": "fRFEGLGxC6j9v+l1KGNgT4jpFKgZ4bl+XufUzmqAUCXH5feGsk5HT/U7fQIG0+hR"}
32 changes: 16 additions & 16 deletions worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<fishtest>/api/nn/<nnue> GET
<github-books>/git/trees/master GET
<github-books>/git/trees/master/blobs/<sha-book> GET
<github>/repos/Disservin/fast-chess/zipball/<sha> GET
<github>/repos/Disservin/fastchess/zipball/<sha> GET
<github>/repos/<user-repo>/zipball/<sha> GET
Main loop <fishtest>/api/update_task POST
Expand Down Expand Up @@ -397,7 +397,7 @@ def get_credentials(config, options, args):


def verify_required_fastchess(fastchess_path, fastchess_sha):
# Verify that fast-chess is working and has the required minimum version.
# Verify that fastchess is working and has the required minimum version.

if not fastchess_path.exists():
return False
Expand All @@ -415,7 +415,7 @@ def verify_required_fastchess(fastchess_path, fastchess_sha):
) as p:
errors = p.stderr.read()
pattern = re.compile(
r"fast-chess alpha [0-9]*.[0-9]*.[0-9]* [0-9]*-([0-9a-f-]*)$"
r"fastchess alpha [0-9]*.[0-9]*.[0-9]* [0-9]*-([0-9a-f-]*)$"
)
short_sha = ""
for line in iter(p.stdout.readline, ""):
Expand All @@ -424,26 +424,26 @@ def verify_required_fastchess(fastchess_path, fastchess_sha):
print("Found", line.strip())
short_sha = m.group(1)
except (OSError, subprocess.SubprocessError) as e:
print("Unable to run fast-chess. Error: {}".format(str(e)))
print("Unable to run fastchess. Error: {}".format(str(e)))
return False

if p.returncode != 0:
print(
"Unable to run fast-chess. Return code: {}. Error: {}".format(
"Unable to run fastchess. Return code: {}. Error: {}".format(
format_return_code(p.returncode), errors
)
)
return False

if len(short_sha) < 7:
print(
"Unable to find a suitable sha of length 7 or more in the fast-chess version."
"Unable to find a suitable sha of length 7 or more in the fastchess version."
)
return False

if not fastchess_sha.startswith(short_sha):
print(
"fast-chess sha {} required but the version shows {}".format(
"fastchess sha {} required but the version shows {}".format(
fastchess_sha, short_sha
)
)
Expand All @@ -457,10 +457,10 @@ def setup_fastchess(worker_dir, compiler, concurrency, global_cache):
testing_dir = worker_dir / "testing"
testing_dir.mkdir(exist_ok=True)

fastchess_sha = "f1ae6f8e13f49fd649c350d70d3e1ef24d01f373"
fastchess_sha = "58c8fb35c26fe5afffc21364afa7dbadc0afa909"
username = "Disservin"

fastchess = "fast-chess" + EXE_SUFFIX
fastchess = "fastchess" + EXE_SUFFIX
if verify_required_fastchess(testing_dir / fastchess, fastchess_sha):
return True

Expand All @@ -469,11 +469,11 @@ def setup_fastchess(worker_dir, compiler, concurrency, global_cache):
item_url = (
"https://api.github.com/repos/"
+ username
+ "/fast-chess/zipball/"
+ "/fastchess/zipball/"
+ fastchess_sha
)

print("Building fast-chess from sources at {}".format(item_url))
print("Building fastchess from sources at {}".format(item_url))

should_cache = False
blob = cache_read(global_cache, fastchess_sha + ".zip")
Expand All @@ -497,7 +497,7 @@ def setup_fastchess(worker_dir, compiler, concurrency, global_cache):

cmds = [
f"make -j{concurrency} tests CXX={compiler} GIT_SHA={fastchess_sha[0:8]} GIT_DATE=01010101",
str(tmp_dir / prefix / ("fast-chess-tests" + EXE_SUFFIX)),
str(tmp_dir / prefix / ("fastchess-tests" + EXE_SUFFIX)),
"make clean",
f"make -j{concurrency} CXX={compiler} GIT_SHA={fastchess_sha[0:8]} GIT_DATE=01010101",
]
Expand All @@ -520,13 +520,13 @@ def setup_fastchess(worker_dir, compiler, concurrency, global_cache):
"Executing {} failed. Error: {}".format(cmd, errors)
)

shutil.copy("fast-chess" + EXE_SUFFIX, testing_dir)
shutil.copy("fastchess" + EXE_SUFFIX, testing_dir)
os.chdir(cd)
shutil.rmtree(tmp_dir)

except Exception as e:
print(
"Exception downloading, extracting or building fast-chess:\n",
"Exception downloading, extracting or building fastchess:\n",
e,
sep="",
file=sys.stderr,
Expand Down Expand Up @@ -829,7 +829,7 @@ def my_error(e):

# Limit concurrency so that at least STC tests can run with the evailable memory
# The memory need per engine is 16 for the TT Hash, 10 for the process 138 for the net and 16 per thread
# 60 is the need for fast-chess
# 60 is the need for fastchess
# These numbers need to be up-to-date with the server values
STC_memory = 2 * (16 + 10 + 138 + 16)
max_concurrency = int((options.max_memory - 60) / STC_memory)
Expand Down Expand Up @@ -1531,7 +1531,7 @@ def worker():
if not verify_toolchain():
return 1

# Make sure we have a working fast-chess
# Make sure we have a working fastchess
if not setup_fastchess(
worker_dir, compiler, options.concurrency, options.global_cache
):
Expand Down

0 comments on commit 2e227a0

Please sign in to comment.