Skip to content

Commit

Permalink
Fix LTC page excluding SMP LTC tests
Browse files Browse the repository at this point in the history
Also, essentially by necessity, fix the num_finished_runs count which is inaccurate in master, see also official-stockfish#1428

This does require rebuilding the relevant index, which will also become larger with a more relaxed bound
  • Loading branch information
dubslow committed Feb 17, 2023
1 parent 8bd445a commit 1a4059d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
15 changes: 8 additions & 7 deletions server/fishtest/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
get_chi2,
get_hash,
get_tc_ratio,
is_ltc,
post_in_fishcooking_results,
remaining_hours,
update_residuals,
Expand Down Expand Up @@ -94,7 +95,6 @@ def __init__(self, db_name="fishtest_new"):
self.task_runs = []

self.task_duration = 900 # 15 minutes
self.ltc_lower_bound = 40 # Beware: this is used as a filter in an index!
self.pt_info = {
"pt_version": "SF_15",
"pt_branch": "e6e324eb28fd49c1fc44b3b65784f85a773ec61c",
Expand Down Expand Up @@ -548,7 +548,7 @@ def get_finished_runs(
if username:
q["args.username"] = username
if ltc_only:
q["tc_base"] = {"$gte": self.ltc_lower_bound}
q["tc_base"] = {"$gte": 20} # String comparison, SMP LTC is 20 th 8
if success_only:
q["is_green"] = True
if yellow_only:
Expand All @@ -558,11 +558,12 @@ def get_finished_runs(
q, skip=skip, limit=limit, sort=[("last_updated", DESCENDING)]
)

count = self.runs.count_documents(q)

# Don't show runs that were deleted
runs_list = [run for run in c if not run.get("deleted")]
return [runs_list, count]
if ltc_only:
predicate = lambda run: not run.get("deleted") and is_ltc(run)
else
predicate = lambda run: not run.get("deleted")
runs_list = list(filter(predicate, c))
return runs_list, len(runs_list)

def get_results(self, run, save_run=True):
if not run["results_stale"]:
Expand Down
4 changes: 2 additions & 2 deletions server/fishtest/templates/run_table.mak
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
% endif

<%
from fishtest.util import get_cookie, is_active_sprt_ltc
from fishtest.util import get_cookie, is_ltc
if toggle:
cookie_name = toggle+"_state"
%>
Expand Down Expand Up @@ -109,7 +109,7 @@
</td>

<td style="width: 13%;" class="run-live">
<span class="${'rounded ltc-highlight me-1' if is_active_sprt_ltc(run) else 'me-1'}">
<span class="${'rounded ltc-highlight me-1' if not run["finished"] and "sprt" in run["args"] and is_ltc(run) else 'me-1'}">
% if 'sprt' in run['args']:
<a href="/tests/live_elo/${str(run['_id'])}" target="_blank">sprt</a>
% else:
Expand Down
9 changes: 3 additions & 6 deletions server/fishtest/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,9 @@ def get_tc_ratio(tc, threads=1, base="10+0.1"):
return threads * estimate_game_duration(tc) / estimate_game_duration(base)


def is_active_sprt_ltc(run):
return (
not run["finished"]
and "sprt" in run["args"]
and get_tc_ratio(run["args"]["tc"], run["args"]["threads"]) > 4
) # SMP-STC ratio is 4
def is_ltc(run):
# SMP-STC ratio is 4
return get_tc_ratio(run["args"]["tc"], run["args"].get("threads", 1)) > 4


def remaining_hours(run):
Expand Down
3 changes: 2 additions & 1 deletion server/fishtest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
format_results,
get_chi2,
get_hash,
is_ltc,
password_strength,
update_residuals,
)
Expand Down Expand Up @@ -885,7 +886,7 @@ def new_run_message(request, run):
if run["args"]["new_tc"] != run["args"]["tc"]
else ""
)
ret += "(LTC)" if run["tc_base"] >= request.rundb.ltc_lower_bound else ""
ret += "(LTC)" if is_ltc(run) else ""
ret += f" Book:{run['args']['book']}"
ret += f" Threads:{run['args']['threads']}"
ret += "(SMP)" if run["args"]["threads"] > 1 else ""
Expand Down
2 changes: 1 addition & 1 deletion server/utils/create_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def create_runs_indexes():
("tc_base", DESCENDING),
],
name="finished_ltc_runs",
partialFilterExpression={"finished": True, "tc_base": {"$gte": 40}},
partialFilterExpression={"finished": True, "tc_base": {"$gte": 20}}, # SMP LTC is 20 th 8
)
db["runs"].create_index(
[("args.username", DESCENDING), ("last_updated", DESCENDING)], name="user_runs"
Expand Down

0 comments on commit 1a4059d

Please sign in to comment.