Skip to content

Commit

Permalink
Fix CI (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Viren6 committed Jun 29, 2024
1 parent 966b081 commit df51ebd
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 92 deletions.
22 changes: 5 additions & 17 deletions .github/workflows/worker_msys2.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI worker msys2
name: CI worker cargo

on: [push, pull_request, workflow_dispatch]

Expand All @@ -7,27 +7,15 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
include:
- { sys: mingw64, env: x86_64, comp: gcc }
- { sys: ucrt64, env: ucrt-x86_64, comp: gcc }
- { sys: clang64, env: clang-x86_64, comp: clang }
toolchain: [stable, beta, nightly]
defaults:
run:
shell: msys2 {0}
shell: bash
working-directory: worker

steps:
- name: Setup msys and install required packages
uses: msys2/setup-msys2@v2
with:
update: true
msystem: ${{ matrix.sys }}
install: >-
make
mingw-w64-${{ matrix.env }}-python3
mingw-w64-${{ matrix.env }}-${{ matrix.comp }}
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
env/
venv/
worker/api.log*
worker/fish.exit
worker/fishtest.cfg
worker/monty.exit
worker/montytest.cfg
worker/_testing_*
worker/testing
worker/worker.lock
4 changes: 1 addition & 3 deletions server/montytest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,7 @@ def download_nn(self):
else:
self.request.rundb.increment_nn_downloads(self.request.matchdict["id"])

return HTTPFound(
"https://montychess.org/nn/" + self.request.matchdict["id"]
)
return HTTPFound("https://montychess.org/nn/" + self.request.matchdict["id"])


class InternalApi(GenericApi):
Expand Down
4 changes: 1 addition & 3 deletions server/montytest/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@


def tests_repo(run):
return run["args"].get(
"tests_repo", "https://github.com/official-monty/Monty"
)
return run["args"].get("tests_repo", "https://github.com/official-monty/Monty")


def master_diff_url(run):
Expand Down
6 changes: 3 additions & 3 deletions server/montytest/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __init__(self, db_name="montytest_new", port=-1, is_primary_instance=True):
self.actiondb.system_event(message=f"start montytest@{self.port}")

self.__is_primary_instance = is_primary_instance

# Create a lock for each active run
self.run_lock = threading.Lock()
self.active_runs = {}
Expand All @@ -118,7 +118,7 @@ def validate_data_structures(self):
# The main purpose of task is to ensure that the schemas
# in schemas.py are kept up-to-date.
print(
"Validate_data_structures: validating Fishtest's internal data structures...",
"Validate_data_structures: validating Montytest's internal data structures...",
flush=True,
)
try:
Expand Down Expand Up @@ -1256,7 +1256,7 @@ def priority(run): # lower is better
# Cache some data. Currently we record the id's
# the worker has seen, as well as the last id that was seen.
# Note that "worker_runs" is empty after a server restart.

if unique_key not in self.worker_runs:
self.worker_runs[unique_key] = {}
self.worker_runs[unique_key][run_id] = True
Expand Down
2 changes: 1 addition & 1 deletion server/montytest/schemas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file describes some of the data structures used by Fishtest so that they
# This file describes some of the data structures used by Montytest so that they
# can be statically validated before they are processed further or written
# to the database.
#
Expand Down
9 changes: 5 additions & 4 deletions server/montytest/static/css/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,11 @@ legend {
content: "\f441";
}

.mainnavbar [href="https://github.com/official-monty/Monty/tree/master/train"]::before {
content: "\f3e2";
font-family: "Font Awesome 5 Brands";
font-weight: 400;
.mainnavbar [href="https://github.com/official-monty/Monty/tree/master/train"]::before
{
content: "\f3e2";
font-family: "Font Awesome 5 Brands";
font-weight: 400;
}

.mainnavbar [href="https://github.com/official-monty/books"]::before
Expand Down
8 changes: 2 additions & 6 deletions server/montytest/static/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,8 @@ function comparer(idx, asc) {
? p1 - p2
: v1 !== "" &&
v2 !== "" &&
!isNaN(
padDotVersion(v1.replace("cargo", "")),
) &&
!isNaN(
padDotVersion(v2.replace("cargo", "")),
)
!isNaN(padDotVersion(v1.replace("cargo", ""))) &&
!isNaN(padDotVersion(v2.replace("cargo", "")))
? padDotVersionStr(v1)
.toString()
.localeCompare(padDotVersionStr(v2))
Expand Down
4 changes: 3 additions & 1 deletion server/montytest/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ def format_results(run_results, run):
run_results["pentanomial"]
)
else:
elo, elo95, los = montytest.stats.stat_util.get_elo([WLD[1], WLD[2], WLD[0]])
elo, elo95, los = montytest.stats.stat_util.get_elo(
[WLD[1], WLD[2], WLD[0]]
)

# Display the results
eloInfo = "Elo: {:.2f} ± {:.1f} (95%)".format(elo, elo95)
Expand Down
6 changes: 2 additions & 4 deletions server/montytest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,9 +1228,7 @@ def tests_run(request):

username = request.authenticated_userid
u = request.userdb.get_user(username)
master_commits_url = (
"https://api.github.com/repos/official-monty/Monty/commits"
)
master_commits_url = "https://api.github.com/repos/official-monty/Monty/commits"
return {
"args": run_args,
"is_rerun": len(run_args) > 0,
Expand Down Expand Up @@ -1416,7 +1414,7 @@ def tests_delete(request):
validate(runs_schema, run, "run")
except ValidationError as e:
message = (
f"The run object {request.POST["run-id"]} does not validate: {str(e)}"
f"The run object {request.POST['run-id']} does not validate: {str(e)}"
)
print(message, flush=True)
if "version" in run and run["version"] >= RUN_VERSION:
Expand Down
4 changes: 1 addition & 3 deletions server/tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

class CreateRunTest(unittest.TestCase):
def test_10_get_bench(self):
master_commits_url = (
"https://api.github.com/repos/official-monty/Monty/commits"
)
master_commits_url = "https://api.github.com/repos/official-monty/Monty/commits"
self.assertTrue(
re.match(
r"[1-9]\d{5,7}|None", str(get_master_info(master_commits_url)["bench"])
Expand Down
2 changes: 1 addition & 1 deletion server/tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime, timezone

import util
from fishtest.views import login, signup
from montytest.views import login, signup
from pyramid import testing


Expand Down
2 changes: 1 addition & 1 deletion server/utils/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime, timezone

import pymongo
from fishtest.util import worker_name
from montytest.util import worker_name


def show(p):
Expand Down
34 changes: 15 additions & 19 deletions worker/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import threading
import time
from base64 import b64decode
from contextlib import ExitStack
from datetime import datetime, timedelta, timezone
from pathlib import Path
from queue import Empty, Queue
Expand Down Expand Up @@ -337,7 +336,7 @@ def run_single_bench(engine, queue):

for line in iter(p.stdout.readline, ""):
if "Bench: " in line:
spl = line.split(' ')
spl = line.split(" ")
bench_sig = int(spl[1].strip())
bench_nps = float(spl[3].strip())

Expand All @@ -353,7 +352,8 @@ def verify_signature(engine, signature, active_cores):
multiprocessing.Process(
target=run_single_bench,
args=(engine, queue),
) for _ in range(active_cores)
)
for _ in range(active_cores)
]

for p in processes:
Expand Down Expand Up @@ -402,9 +402,7 @@ def download_from_github_api(
return b64decode(requests_get(git_url, timeout=HTTP_TIMEOUT).json()["content"])


def download_from_github(
item, owner="official-monty", repo="books", branch="master"
):
def download_from_github(item, owner="official-monty", repo="books", branch="master"):
try:
blob = download_from_github_raw(item, owner=owner, repo=repo, branch=branch)
except FatalException:
Expand Down Expand Up @@ -447,9 +445,7 @@ def convert_book_move_counters(book_file):
file.write(epd + "\n")


def setup_engine(
destination, worker_dir, testing_dir, remote, sha, repo_url
):
def setup_engine(destination, worker_dir, testing_dir, remote, sha, repo_url):
"""Download and build sources in a temporary directory then move exe to destination"""
tmp_dir = Path(tempfile.mkdtemp(dir=worker_dir))

Expand All @@ -471,11 +467,7 @@ def setup_engine(
establish_validated_net(remote, testing_dir, policyfile)
shutil.copyfile(testing_dir / policyfile, policyfile)

cmd = [
"make",
"montytest",
f"EXE={destination}"
]
cmd = ["make", "montytest", f"EXE={destination}"]

if os.path.exists(destination):
raise FatalException("Another worker is running in the same directory!")
Expand Down Expand Up @@ -850,21 +842,25 @@ def launch_cutechess(
# Stochastic rounding and probability for float N.p: (N, 1-p); (N+1, p)
idx = cmd.index("_spsa_")
cmd = (
cmd[:idx] + [
cmd[:idx]
+ [
"option.{}={}".format(
x["name"], math.floor(x["value"] + random.uniform(0, 1))
)
for x in w_params
] + cmd[idx + 1:]
]
+ cmd[idx + 1 :]
)
idx = cmd.index("_spsa_")
cmd = (
cmd[:idx] + [
cmd[:idx]
+ [
"option.{}={}".format(
x["name"], math.floor(x["value"] + random.uniform(0, 1))
)
for x in b_params
] + cmd[idx + 1:]
]
+ cmd[idx + 1 :]
)

# print(cmd)
Expand Down Expand Up @@ -1145,7 +1141,7 @@ def parse_options(s):
base_nps
)
)

# Value from running bench on 32 processes on Ryzen 9 7950X
# also set in rundb.py and delta_update_users.py
factor = 184087 / base_nps
Expand Down
18 changes: 0 additions & 18 deletions worker/montytest.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion worker/sri.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"__version": 0, "updater.py": "gSJX/HbsPwsZnUZaFbAgF0zwWPWXv+LEw9jBhJkxFOrCH9CZS0+4U4nE2fJdeNze", "worker.py": "McZEcv24hljihgg9DijjsEmrAE6iXvbuBhGs2aMq/dxxd0dGelvBJ4UxdZNgLKef", "games.py": "DxAfnwLSZwBZh18gVY4eSNLsIPEVvPAXLIB+wC87uRt4xqQl8TEaSQxKzxMsvvS/"}
{"__version": 0, "updater.py": "gSJX/HbsPwsZnUZaFbAgF0zwWPWXv+LEw9jBhJkxFOrCH9CZS0+4U4nE2fJdeNze", "worker.py": "dCK+GRoDlEaiD+XYH94CYmzjCPtA6JmMFomjKQhB33pb4ztuHfGjXtwtBRiYdhXx", "games.py": "tWUQJrq+nRAtrOUdMJT7uFprXhEAUZ23YRbTf7i8ACOfkt0CdiEjduPdY67FtKgp"}
11 changes: 6 additions & 5 deletions worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
import time
import traceback
import uuid
import cpuinfo
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
from configparser import ConfigParser
from contextlib import ExitStack
from datetime import datetime, timedelta, timezone
from functools import partial
from pathlib import Path

import cpuinfo

# Fall back to the provided packages if missing in the local system.

packages_dir = Path(__file__).resolve().parent / "packages"
Expand Down Expand Up @@ -1029,7 +1030,7 @@ def cargo_version():
) as p:
for line in iter(p.stdout.readline, ""):
if "cargo" in line:
ver = line.split(' ')[1].split('.')
ver = line.split(" ")[1].split(".")
major = ver[0]
minor = ver[1]
patchlevel = ver[2]
Expand Down Expand Up @@ -1549,17 +1550,17 @@ def worker():

compiler, major, minor, patchlevel = options.compiler
print("Using {} {}.{}.{}".format(compiler, major, minor, patchlevel))

try:
brand = cpuinfo.get_cpu_info()["brand_raw"]
except:
brand = "?"

try:
freq = cpuinfo.get_cpu_info()["hz_actual_friendly"]
except:
freq = ""

cpu = "{} {}".format(brand, freq)

uname = platform.uname()
Expand Down

0 comments on commit df51ebd

Please sign in to comment.