Skip to content

Commit

Permalink
- move the tests of the worker in a folder to avoid errors with the
Browse files Browse the repository at this point in the history
  unittest discover
- drop the local folder form the PHYTONPATH to fix the msys2 workflow
- add python 3.12 to the worker posix test
- format the code
  • Loading branch information
ppigazzini committed Feb 23, 2024
1 parent 3db99cb commit 9f7fda8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/worker_msys2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:

- name: Add packages folder to PYTHONPATH
run: |
echo "PYTHONPATH=$PYTHONPATH:$(pwd)/packages" >> $GITHUB_ENV
echo "PYTHONPATH=$(pwd)/packages" >> $GITHUB_ENV
- name: Run worker tests
run: |
python -m unittest discover -vb
python -m unittest discover -vb -s tests
7 changes: 3 additions & 4 deletions .github/workflows/worker_posix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
defaults:
run:
working-directory: worker
Expand All @@ -25,9 +25,8 @@ jobs:

- name: Add packages folder to PYTHONPATH
run: |
echo "PYTHONPATH=$PYTHONPATH:$(pwd)/packages" >> $GITHUB_ENV
echo "PYTHONPATH=$(pwd)/packages" >> $GITHUB_ENV
- name: Run worker tests
run: |
python -m unittest discover -vb
python -m unittest discover -vb -s tests
20 changes: 11 additions & 9 deletions server/fishtest/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,11 @@ def get_machines(self):
machines = (
task["worker_info"]
| {
"last_updated": task["last_updated"].replace(tzinfo=timezone.utc)
if task.get("last_updated")
else None,
"last_updated": (
task["last_updated"].replace(tzinfo=timezone.utc)
if task.get("last_updated")
else None
),
"run": run,
"task_id": task_id,
}
Expand Down Expand Up @@ -1580,9 +1582,11 @@ def stop_run(self, run_id):
self.actiondb.purge_run(
username=run["args"]["username"],
run=run,
message=f"Auto purge (not performed): {message}"
if message
else "Auto purge",
message=(
f"Auto purge (not performed): {message}"
if message
else "Auto purge"
),
)
if message == "":
print("Run {} was auto-purged".format(str(run_id)), flush=True)
Expand Down Expand Up @@ -1766,9 +1770,7 @@ def generate_spsa(self, run):
{
"name": param["name"],
"value": self.spsa_param_clip(param, c * flip),
"R": param["a"]
/ (spsa["A"] + iter_local) ** spsa["alpha"]
/ c**2,
"R": param["a"] / (spsa["A"] + iter_local) ** spsa["alpha"] / c**2,
"c": c,
"flip": flip,
}
Expand Down
4 changes: 1 addition & 3 deletions server/fishtest/stats/LLRcalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ def LLR_normalized(nelo0, nelo1, results):
t0, t1 = (
(nt0, nt1)
if len(results) == 3
else (nt0 * sqrt2, nt1 * sqrt2)
if len(results) == 5
else None
else (nt0 * sqrt2, nt1 * sqrt2) if len(results) == 5 else None
)
N, pdf = results_to_pdf(results)
return N * LLR(pdf, t0, t1, ref=1 / 2, statistic="t_value")
6 changes: 3 additions & 3 deletions server/fishtest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,9 +1250,9 @@ def tests_purge(request):
request.actiondb.purge_run(
username=username,
run=run,
message=f"Manual purge (not performed): {message}"
if message
else "Manual purge",
message=(
f"Manual purge (not performed): {message}" if message else "Manual purge"
),
)
if message != "":
request.session.flash(message)
Expand Down
13 changes: 8 additions & 5 deletions worker/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,11 +1122,14 @@ def launch_cutechess(
bufsize=1,
# The next options are necessary to be able to send a CTRL_C_EVENT to this process.
# https://stackoverflow.com/questions/7085604/sending-c-to-python-subprocess-objects-on-windows
startupinfo=subprocess.STARTUPINFO(
dwFlags=subprocess.STARTF_USESHOWWINDOW, wShowWindow=subprocess.SW_HIDE
)
if IS_WINDOWS
else None,
startupinfo=(
subprocess.STARTUPINFO(
dwFlags=subprocess.STARTF_USESHOWWINDOW,
wShowWindow=subprocess.SW_HIDE,
)
if IS_WINDOWS
else None
),
creationflags=subprocess.CREATE_NEW_CONSOLE if IS_WINDOWS else 0,
close_fds=not IS_WINDOWS,
) as p:
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": "VtjJDf5aPFs93Ni/uB1JBr4GpSxjFWgO/qd6KV2Rra620ckS7YjhXq7r/RnS8SPT"}
File renamed without changes.

0 comments on commit 9f7fda8

Please sign in to comment.