Skip to content

Commit

Permalink
Continue server migration (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Viren6 authored Jun 27, 2024
1 parent 019636b commit d74c7d8
Show file tree
Hide file tree
Showing 88 changed files with 300 additions and 282 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
id: prettier
continue-on-error: true
run: |
npx prettier --check "server/fishtest/static/{css/*.css,html/*.html,js/*.js}"
npx prettier --check "server/montytest/static/{css/*.css,html/*.html,js/*.js}"
- name: Check linters and formatters status
run: |
Expand All @@ -66,4 +66,4 @@ jobs:
echo "Run the following commands to format the code:"
echo "pipx run black --exclude='env|packages' ."
echo "pipx run isort --profile black --skip env --skip venv --skip worker/packages ."
echo "npx prettier --write 'server/fishtest/static/{css/*.css,html/*.html,js/*.js}'"
echo "npx prettier --write 'server/montytest/static/{css/*.css,html/*.html,js/*.js}'"
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# List of authors for fishtest, as of December 14, 2023
# List of authors for montytest, as of December 14, 2023

Gary Linscott (glinscott)

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
### Overview
[![CI server](https://github.com/official-monty/montytest/actions/workflows/server.yaml/badge.svg)](https://github.com/official-stockfish/montytest/actions/workflows/server.yaml) [![CI worker posix](https://github.com/official-monty/montytest/actions/workflows/worker_posix.yaml/badge.svg)](https://github.com/official-monty/montytest/actions/workflows/worker_posix.yaml) [![CI worker msys2](https://github.com/official-monty/montytest/actions/workflows/worker_msys2.yaml/badge.svg)](https://github.com/official-monty/montytest/actions/workflows/worker_msys2.yaml) [![CI lint](https://github.com/official-monty/montytest/actions/workflows/lint.yaml/badge.svg)](https://github.com/official-monty/montytest/actions/workflows/lint.yaml)
Montytest is a fishtest derivative: https://github.com/official-stockfish/fishtest

Fishtest is a distributed task queue for testing chess engines. The main instance
Montytest is a distributed task queue for testing chess engines. The main instance
for testing the chess engine [Monty](https://github.com/official-monty/Monty) is at this web page https://montychess.org

Developers submit patches with new ideas and improvements, CPU contributors install a fishtest worker on their computers to play some chess games in the background to help the developers testing the patches.
Developers submit patches with new ideas and improvements, CPU contributors install a montytest worker on their computers to play some chess games in the background to help the developers testing the patches.

The fishtest worker:
The montytest worker:
- Automatically connects to the server to download a chess opening book, the [cutechess-cli](https://github.com/cutechess/cutechess) chess game manager and the chess engine sources (both for the current Monty and for the patch with the new idea). The sources will be compiled according to the type of the worker platform.
- Starts a batch of games using cutechess-cli.
- Uploads the games results on the server.

The fishtest server:
The montytest server:
- Manages the queue of the tests with customizable priorities.
- Computes several probabilistic values from the game results sent by the workers.
- Updates and publishes the results of ongoing tests.
- Knows how to stop tests when they are statistically significant and publishes the final tests results.

To get more information, such as the worker/server install and configuration instructions, visit the [Fishtest Wiki](https://github.com/official-monty/montytest/wiki).
To get more information, such as the worker/server install and configuration instructions, visit the [montytest Wiki](https://github.com/official-monty/montytest/wiki).
2 changes: 1 addition & 1 deletion server/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include *.txt *.ini *.cfg *.rst
recursive-include fishtest *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.mem
recursive-include montytest *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.mem
14 changes: 7 additions & 7 deletions server/development.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
###

[app:main]
use = egg:fishtest_server
use = egg:montytest_server

pyramid.reload_templates = true
pyramid.debug_authorization = false
Expand All @@ -15,10 +15,10 @@ pyramid.includes = pyramid_debugtoolbar

debugtoolbar.hosts = 0.0.0.0/0 ::1

mako.directories = fishtest:templates
mako.directories = montytest:templates

fishtest.port = 6542
fishtest.primary_port = 6542
montytest.port = 6542
montytest.primary_port = 6542

###
# wsgi server configuration
Expand All @@ -35,7 +35,7 @@ port = 6542
###

[loggers]
keys = root, fishtest
keys = root, montytest

[handlers]
keys = console
Expand All @@ -47,10 +47,10 @@ keys = generic
level = INFO
handlers = console

[logger_fishtest]
[logger_montytest]
level = DEBUG
handlers =
qualname = fishtest
qualname = montytest

[handler_console]
class = StreamHandler
Expand Down
14 changes: 7 additions & 7 deletions server/fishtest/__init__.py → server/montytest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import traceback
from pathlib import Path

from fishtest.rundb import RunDb
from montytest.rundb import RunDb
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.config import Configurator
Expand All @@ -15,7 +15,7 @@
from pyramid.security import forget
from pyramid.session import SignedCookieSessionFactory

from fishtest import helpers
from montytest import helpers


def thread_stack_dump(sig, frame):
Expand All @@ -34,11 +34,11 @@ def main(global_config, **settings):
# trigger with: kill -USR1 <pid>
signal.signal(signal.SIGUSR1, thread_stack_dump)

session_factory = SignedCookieSessionFactory("fishtest")
session_factory = SignedCookieSessionFactory("montytest")
config = Configurator(
settings=settings,
session_factory=session_factory,
root_factory="fishtest.models.RootFactory",
root_factory="montytest.models.RootFactory",
)
config.include("pyramid_mako")
config.set_default_csrf_options(require_csrf=False)
Expand All @@ -59,8 +59,8 @@ def file_hash(file):
for j in static_full_path(i).glob(f"*.{i}")
}

port = int(settings.get("fishtest.port", -1))
primary_port = int(settings.get("fishtest.primary_port", -1))
port = int(settings.get("montytest.port", -1))
primary_port = int(settings.get("montytest.primary_port", -1))
# If the port number cannot be determined like during unit tests or CI,
# assume the instance is primary for backward compatibility.
is_primary_instance = port == primary_port
Expand Down Expand Up @@ -112,7 +112,7 @@ def init_rundb(event):
def group_finder(username, request):
return request.userdb.get_user_groups(username)

secret = Path("~/fishtest.secret").expanduser().read_text()
secret = Path("~/montytest.secret").expanduser().read_text()
config.set_authentication_policy(
AuthTktAuthenticationPolicy(
secret, callback=group_finder, hashalg="sha512", http_only=True
Expand Down
8 changes: 4 additions & 4 deletions server/fishtest/actiondb.py → server/montytest/actiondb.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime, timezone

from fishtest.schemas import action_schema
from fishtest.util import hex_print, worker_name
from montytest.schemas import action_schema
from montytest.util import hex_print, worker_name
from pymongo import DESCENDING
from vtjson import ValidationError, validate

Expand Down Expand Up @@ -117,7 +117,7 @@ def dead_task(self, username=None, run=None, task_id=None):
def system_event(self, message=None):
self.insert_action(
action="system_event",
username="fishtest.system",
username="montytest.system",
message=message,
)

Expand Down Expand Up @@ -224,7 +224,7 @@ def insert_action(self, **action):
)
print(message, flush=True)
self.log_message(
username="fishtest.system",
username="montytest.system",
message=message,
)
return
Expand Down
8 changes: 4 additions & 4 deletions server/fishtest/api.py → server/montytest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from datetime import datetime, timezone
from urllib.parse import urlparse

from fishtest.schemas import api_access_schema, api_schema, gzip_data
from fishtest.stats.stat_util import SPRT_elo, get_elo
from fishtest.util import strip_run, worker_name
from montytest.schemas import api_access_schema, api_schema, gzip_data
from montytest.stats.stat_util import SPRT_elo, get_elo
from montytest.util import strip_run, worker_name
from pyramid.httpexceptions import (
HTTPBadRequest,
HTTPException,
Expand All @@ -23,7 +23,7 @@
Important note
==============
APIs hosted on the primary Fishtest instance have read and write access
APIs hosted on the primary montytest instance have read and write access
to the `run_cache` via `rundb.get_run()` and `rundb.buffer()`
APIs hosted on secondary instances have read access to the `run`
Expand Down
2 changes: 1 addition & 1 deletion server/fishtest/helpers.py → server/montytest/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fishtest.util import get_hash, get_tc_ratio
from montytest.util import get_hash, get_tc_ratio


def tests_repo(run):
Expand Down
File renamed without changes.
38 changes: 19 additions & 19 deletions server/fishtest/rundb.py → server/montytest/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import time
from datetime import datetime, timedelta, timezone

import fishtest.stats.stat_util
import montytest.stats.stat_util
from bson.binary import Binary
from bson.codec_options import CodecOptions
from bson.errors import InvalidId
from bson.objectid import ObjectId
from fishtest.actiondb import ActionDb
from fishtest.schemas import (
from montytest.actiondb import ActionDb
from montytest.schemas import (
RUN_VERSION,
cache_schema,
compute_committed_games,
Expand All @@ -27,9 +27,9 @@
pgns_schema,
runs_schema,
)
from fishtest.stats.stat_util import SPRT_elo
from fishtest.userdb import UserDb
from fishtest.util import (
from montytest.stats.stat_util import SPRT_elo
from montytest.userdb import UserDb
from montytest.util import (
GeneratorAsFileReader,
Scheduler,
crash_or_time,
Expand All @@ -44,7 +44,7 @@
update_residuals,
worker_name,
)
from fishtest.workerdb import WorkerDb
from montytest.workerdb import WorkerDb
from pymongo import DESCENDING, MongoClient
from vtjson import ValidationError, validate

Expand All @@ -53,10 +53,10 @@

class RunDb:

def __init__(self, db_name="fishtest_new", port=-1, is_primary_instance=True):
def __init__(self, db_name="montytest_new", port=-1, is_primary_instance=True):
# MongoDB server is assumed to be on the same machine, if not user should
# use ssh with port forwarding to access the remote host.
self.conn = MongoClient(os.getenv("FISHTEST_HOST") or "localhost")
self.conn = MongoClient(os.getenv("MONTYTEST_HOST") or "localhost")
codec_options = CodecOptions(tz_aware=True, tzinfo=timezone.utc)
self.db = self.conn[db_name].with_options(codec_options=codec_options)
self.userdb = UserDb(self.db)
Expand Down Expand Up @@ -84,7 +84,7 @@ def __init__(self, db_name="fishtest_new", port=-1, is_primary_instance=True):
}

if self.port >= 0:
self.actiondb.system_event(message=f"start fishtest@{self.port}")
self.actiondb.system_event(message=f"start montytest@{self.port}")

self.__is_primary_instance = is_primary_instance

Expand Down Expand Up @@ -171,7 +171,7 @@ def validate_random_run(self):
print(message, flush=True)
if "version" in run and run["version"] >= RUN_VERSION:
self.actiondb.log_message(
username="fishtest.system",
username="montytest.system",
message=message,
)

Expand Down Expand Up @@ -341,7 +341,7 @@ def update_aggregated_data(self):
self.update_itp()

# This will be moved to a more suitable place once we have documented more
# internal Fishtest data structures.
# internal montytest data structures.
try:
validate(
cache_schema,
Expand Down Expand Up @@ -515,7 +515,7 @@ def upload_pgn(self, run_id, pgn_zip):
message = f"Internal Error. Pgn record has the wrong format: {str(e)}"
print(message, flush=True)
self.actiondb.log_message(
username="fishtest.system",
username="montytest.system",
message=message,
)
self.pgndb.insert_one(
Expand Down Expand Up @@ -599,7 +599,7 @@ def exit_run(self, signum, frame):
self.scheduler.stop()
self.flush_all()
if self.port >= 0:
self.actiondb.system_event(message=f"stop fishtest@{self.port}")
self.actiondb.system_event(message=f"stop montytest@{self.port}")
sys.exit(0)

def get_run(self, r_id):
Expand Down Expand Up @@ -1248,12 +1248,12 @@ def finished_run_message(self, run):
else:
results = run["results"]
if "pentanomial" in results:
elo, elo95, los = fishtest.stats.stat_util.get_elo(
elo, elo95, los = montytest.stats.stat_util.get_elo(
results["pentanomial"]
)
else:
WLD = [results["wins"], results["losses"], results["draws"]]
elo, elo95, los = fishtest.stats.stat_util.get_elo(
elo, elo95, los = montytest.stats.stat_util.get_elo(
[WLD[1], WLD[2], WLD[0]]
)
if run["is_green"]:
Expand Down Expand Up @@ -1387,7 +1387,7 @@ def count_games(d):

if "sprt" in run["args"]:
sprt = run["args"]["sprt"]
fishtest.stats.stat_util.update_SPRT(run["results"], sprt)
montytest.stats.stat_util.update_SPRT(run["results"], sprt)
if sprt["state"] != "":
task_finished = True
self.set_inactive_task(task_id, run)
Expand Down Expand Up @@ -1480,7 +1480,7 @@ def stop_run(self, run_id):
print(message, flush=True)
if "version" in run and run["version"] >= RUN_VERSION:
self.actiondb.log_message(
username="fishtest.system",
username="montytest.system",
message=message,
)
self.buffer(run, True)
Expand Down Expand Up @@ -1583,7 +1583,7 @@ def purge_run(self, run, p=0.001, res=7.0, iters=1):
run["results"] = results
revived = True
if "sprt" in run["args"] and "state" in run["args"]["sprt"]:
fishtest.stats.stat_util.update_SPRT(results, run["args"]["sprt"])
montytest.stats.stat_util.update_SPRT(results, run["args"]["sprt"])
if run["args"]["sprt"]["state"] != "":
revived = False

Expand Down
2 changes: 1 addition & 1 deletion server/fishtest/schemas.py → server/montytest/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def action_is(x):
"_id?": ObjectId,
"time": float,
"action": "system_event",
"username": "fishtest.system",
"username": "montytest.system",
"message": action_message,
},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ legend {
content: "\f02d";
}

.mainnavbar .stockfish-repo::before {
.mainnavbar .monty-repo::before {
content: "\f578";
}

Expand Down Expand Up @@ -463,7 +463,7 @@ header.navbar {
}

.brand-logo {
background-image: url(../img/stockfish.png);
background-image: url(../img/monty.png);
background-position: center;
background-size: cover;
height: 40px;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html lang="en">
<head>
<title>Site Maintenance | Stockfish Testing Framework</title>
<title>Site Maintenance | Monty Testing Framework</title>
<meta charset="utf-8" />
<meta name="robots" content="noindex" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Expand Down Expand Up @@ -58,8 +58,8 @@
<body>
<article>
<div class="header">
<img src="/img/stockfish.png" alt="logo" />
<h2>Stockfish Testing Framework</h2>
<img src="/img/monty.png" alt="logo" />
<h2>Monty Testing Framework</h2>
</div>
<h1>We&rsquo;ll be back soon!</h1>
<div>
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit d74c7d8

Please sign in to comment.