Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.15 #648

Merged
merged 32 commits into from
Aug 17, 2024
Merged

1.15 #648

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d1b4b1c
requirements and md fixes
Aug 17, 2023
da04863
Merge branch 'master' into 1.15.0
sanderland Aug 26, 2023
016b22d
Escape the distributed contribution command settings (#653)
espadrine Aug 26, 2023
703c63d
fix: restrict the range of index when moving through variations (#670)
xiaoyifang Nov 19, 2023
0006901
can chad fix
sanderland Jan 3, 2024
7699409
Merge branch '1.15.0' of github.com:sanderland/katrain into 1.15.0
sanderland Jan 3, 2024
019e130
edit .github/workflows/osxbuild.yaml
sanderland Jan 3, 2024
236c4b5
edit .github/workflows/osxbuild.yaml
sanderland Jan 3, 2024
8b5837b
edit .github/workflows/osxbuild.yaml
sanderland Jan 3, 2024
ddad6a4
feature: add shortcut m for toggle the move num of nodes (#674)
xiaoyifang Jan 4, 2024
6603fbc
move analysis thread
sanderland Jan 9, 2024
a06b977
Merge branch '1.15.0' of github.com:sanderland/katrain into 1.15.0
sanderland Jan 9, 2024
2b9c9fe
edit katrain/core/engine.py
sanderland Jan 9, 2024
22f4f0b
2 d.p. for mean point loss in performance report (#677)
rooklift Mar 17, 2024
32b3ad9
edit katrain/gui/widgets/movetree.py
sanderland Mar 24, 2024
40e0ef3
Merge branch '1.15.0' of github.com:sanderland/katrain into 1.15.0
sanderland Mar 24, 2024
a42aba2
Add poetry and bump dependencies (#701)
lykahb Aug 16, 2024
9c1c789
upgrade linux exe, fix sound
Aug 16, 2024
1f30e6f
black
Aug 16, 2024
46baaab
ci
Aug 16, 2024
b6525bf
windows update
Aug 16, 2024
8e621b7
typo
Aug 16, 2024
97ab8d7
edit katrain/KataGo/katago
Aug 16, 2024
73f1ae3
stale
Aug 16, 2024
cacf5f0
update model
Aug 17, 2024
7125117
osx
Aug 17, 2024
34304fb
osx
Aug 17, 2024
131eb16
osx platypus
Aug 17, 2024
0ae9d33
osx py 311
Aug 17, 2024
d81eb84
platupus53
sanderland Aug 17, 2024
c08c355
edit .github/workflows/osxbuild.yaml
sanderland Aug 17, 2024
75ed688
edit .github/workflows/osxbuild.yaml
sanderland Aug 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[flake8]
ignore = E501, E203, W503, E402 # line length, space before binary op, line break before binary op, import not at top
# line length, space before binary op, line break before binary op, import not at top
ignore = E501, E203, W503, E402
exclude = .git,__pycache__,build,dist
36 changes: 19 additions & 17 deletions .github/workflows/osxbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ jobs:
osx_app:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.9

- name: Install dependencies
run: |
brew update
brew install libzip

- name: Build KataGo
run: |
export OPENSSL_ROOT_DIR=$(brew --prefix [email protected])
export OPENSSL_LIBRARIES="${OPENSSL_ROOT_DIR}/lib"
echo $OPENSSL_ROOT_DIR
ls $OPENSSL_ROOT_DIR
echo $OPENSSL_LIBRARIES
ls $OPENSSL_LIBRARIES
rm katrain/KataGo/katago
rm katrain/KataGo/*.dll
rm katrain/KataGo/katago.exe
Expand All @@ -37,14 +37,15 @@ jobs:
unzip "platypus.zip"
gunzip Platypus.app/Contents/Resources/platypus_clt.gz
gunzip Platypus.app/Contents/Resources/ScriptExec.gz
mkdir -p /usr/local/bin
mkdir -p /usr/local/share/platypus
cp Platypus.app/Contents/Resources/platypus_clt /usr/local/bin/platypus
cp Platypus.app/Contents/Resources/ScriptExec /usr/local/share/platypus/ScriptExec
cp -a Platypus.app/Contents/Resources/MainMenu.nib /usr/local/share/platypus/MainMenu.nib
chmod -R 755 /usr/local/share/platypus
sudo mkdir -p /usr/local/bin
sudo mkdir -p /usr/local/share/platypus
sudo cp Platypus.app/Contents/Resources/platypus_clt /usr/local/bin/platypus
sudo cp Platypus.app/Contents/Resources/ScriptExec /usr/local/share/platypus/ScriptExec
sudo cp -a Platypus.app/Contents/Resources/MainMenu.nib /usr/local/share/platypus/MainMenu.nib
sudo chmod -R 755 /usr/local/share/platypus
- name: Get Kivy dependencies
run: |
brew install ninja
cd ..
git clone https://github.com/kivy/kivy-sdk-packager.git
cd kivy-sdk-packager/osx
Expand All @@ -54,7 +55,8 @@ jobs:
pushd ../kivy-sdk-packager/osx/build/KaTrain.app/Contents/Resources/venv/bin
source activate
popd
python -m pip install .
python -m pip install poetry
poetry install
- name: Finalize KaTrain bundle
run: |
export KATRAIN_VERSION=`python -c 'from katrain.core.constants import VERSION;print(VERSION)' `
Expand All @@ -74,7 +76,7 @@ jobs:
mkdir osx_app
cp ../kivy-sdk-packager/osx/KaTrain.dmg osx_app/
- name: Upload app as artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: KaTrainOSX
path: osx_app
23 changes: 11 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,30 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- name: Install dependencies
run: |
pip3 install -e .
pip3 install pytest wheel twine polib
pip3 install poetry
poetry install --with dev,test

- name: Run tests
run: pytest -v -s tests
run: poetry run pytest -v -s tests

- name: Run I18N conversion
run: python i18n.py
run: poetry run python i18n.py

- name: Build
run: |
python3 setup.py sdist
python3 setup.py bdist_wheel
poetry build

- name: Release to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload --verbose dist/* || echo 'File exists'
POETRY_HTTP_BASIC_KATRAIN_USERNAME: ${{ secrets.PYPI_USER }}
POETRY_HTTP_BASIC_KATRAIN_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: poetry publish --verbose
21 changes: 21 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Close stale issues and PRs"
on:
schedule:
- cron: "30 1 * * *"

jobs:
stale:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
steps:
- uses: actions/stale@v8
with:
operations-per-run: 200
stale-issue-message: "This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 10 days."
close-issue-message: "This issue was closed because it has been stalled for 30 days with no activity."
days-before-stale: 90
days-before-close: 30
stale-pr-message: "This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 10 days."
close-pr-message: "This PR was closed because it has been stalled for 30 days with no activity."
17 changes: 8 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,27 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.11'] # '3.8', '3.9',
python-version: ['3.9', '3.12'] # '3.11',

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip3 install -e .
pip3 install pytest wheel polib
pip3 install poetry
poetry install --with dev,test

- name: Run tests
run: pytest tests
run: poetry run pytest tests

- name: Run I18N conversion
run: python i18n.py -todo
run: poetry run python i18n.py -todo

- name: Build
run: |
python3 setup.py sdist
python3 setup.py bdist_wheel
poetry build
11 changes: 6 additions & 5 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Simply download and run, everything is included.
### <a name="WindowsSources"></a>Installation from sources

* Download the repository by clicking the green *Clone or download* on this page and *Download zip*. Extract the contents.
* Make sure you have a python installation, I will assume Anaconda (Python 3.7/3.8), available [here](https://www.anaconda.com/products/individual#download-section).
* Make sure you have a python installation, I will assume Anaconda (Python 3.9 or later), available [here](https://www.anaconda.com/products/individual#download-section).
* Open 'Anaconda prompt' from the start menu and navigate to where you extracted the zip file using the `cd <folder>` command.
* Execute the command `pip3 install .`
* Start the app by running `katrain` in the command prompt.
Expand All @@ -63,7 +63,7 @@ Simply download and run, everything is included.

### <a name="LinuxQuick"></a>Quick install guide

If you have a working Python 3.6-3.8 available, you should be able to simply:
If you have a working Python 3.9 or later available, you should be able to simply:

* Run `pip3 install -U katrain` to install or upgrade.
* Run the program by executing `katrain` in a terminal.
Expand All @@ -72,15 +72,15 @@ If you have a working Python 3.6-3.8 available, you should be able to simply:

This section describes how to install KaTrain from sources,
in case you want to run it in a local directory or have more control over the process.
It assumes you have a working Python 3.6+ installation.
It assumes you have a working Python 3.9+ installation.

* Open a terminal.
* Run the command `git clone https://github.com/sanderland/katrain.git` to download the repository and
change directory using `cd katrain`
* Run the command `pip3 install .` to install the package globally, or use `--user` to install locally.
* Run the program by typing `katrain` in the terminal.
* If you prefer not to install, run without installing using `python3 -m katrain` after installing the
dependencies from `requirements.txt`.
dependencies from `poetry.lock` with `poetry install`.

A binary for KataGo is included, but if you have compiled your own, press F8 to open general settings and change the
KataGo executable path to the relevant KataGo v1.4+ binary.
Expand All @@ -101,7 +101,8 @@ sudo apt-get install python3-pip build-essential git python3 python3-dev ffmpeg
```
Then, try installing python package dependencies using:
```bash
pip3 install -r requirements.txt
pip3 install poetry
poetry install
pip3 install screeninfo # Skip on MacOS, not working
```
In case the sound is not working, or there is no available wheel for your OS or Python version, try building kivy locally using:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ In addition to shortcuts mentioned above and those shown in the main menu:
* **[~]** or **[ ` ]** or **[F12]**: Cycles through more minimalistic UI modes.
* **[k]**: Toggle display of board coordinates.
* **[p]**: Pass
* **[m]**: Toggle the move number on the board
* **[pause]**: Pause/Resume timer
* **[arrow left]** or **[z]**: Undo move. Hold shift for 10 moves at a time, or ctrl to skip to the start.
* **[arrow right]** or **[x]**: Redo move. Hold shift for 10 moves at a time, or ctrl to skip to the end.
Expand Down
1 change: 1 addition & 0 deletions katrain/KataGo/analysis_config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ maxVisits = 500
# But there's no substitute for experimenting and seeing what's best for your hardware and your usage case.
# Keep in mind that the number of threads you want doesn't necessarily have much to do with how many cores you
# have on your system, and could easily exceed the number of cores. GPU batching is (usually) the dominant consideration.
numAnalysisThreads = 12
numSearchThreads = 8

# nnMaxBatchSize is the max number of positions to send to a single GPU at once. Generally, it should be the case that:
Expand Down
Binary file modified katrain/KataGo/katago
Binary file not shown.
Binary file modified katrain/KataGo/katago.exe
Binary file not shown.
Binary file added katrain/KataGo/libcrypto-3-x64.dll
Binary file not shown.
Binary file added katrain/KataGo/libssl-3-x64.dll
Binary file not shown.
Binary file modified katrain/KataGo/libz.dll
Binary file not shown.
Binary file modified katrain/KataGo/libzip.dll
Binary file not shown.
Binary file modified katrain/KataGo/msvcp140.dll
Binary file not shown.
Binary file modified katrain/KataGo/msvcp140_1.dll
Binary file not shown.
Binary file modified katrain/KataGo/msvcp140_2.dll
Binary file not shown.
Binary file added katrain/KataGo/msvcp140_atomic_wait.dll
Binary file not shown.
Binary file added katrain/KataGo/msvcp140_codecvt_ids.dll
Binary file not shown.
Binary file modified katrain/KataGo/vcruntime140.dll
Binary file not shown.
Binary file added katrain/KataGo/vcruntime140_1.dll
Binary file not shown.
9 changes: 9 additions & 0 deletions katrain/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""isort:skip_file"""

# first, logging level lower
import os
import sys
Expand Down Expand Up @@ -124,6 +125,8 @@ def __init__(self, **kwargs):
self.contribute_popup = None

self.pondering = False
self.show_move_num = False

self.animate_contributing = False
self.message_queue = Queue()

Expand Down Expand Up @@ -173,6 +176,10 @@ def toggle_continuous_analysis(self, quiet=False):
self.pondering = not self.pondering
self.update_state()

def toggle_move_num(self):
self.show_move_num = not self.show_move_num
self.update_state()

def start(self):
if self.engine:
return
Expand Down Expand Up @@ -740,6 +747,8 @@ def _on_keyboard_down(self, _keyboard, keycode, _text, modifiers):

if keycode[1] == Theme.KEY_TOGGLE_CONTINUOUS_ANALYSIS:
self.toggle_continuous_analysis(quiet=shift_pressed)
elif keycode[1] == Theme.KEY_TOGGLE_MOVENUM:
self.toggle_move_num()
elif keycode[1] == Theme.KEY_TOGGLE_COORDINATES:
self.board_gui.toggle_coordinates()
elif keycode[1] in Theme.KEY_PAUSE_TIMER and not ctrl_pressed:
Expand Down
5 changes: 2 additions & 3 deletions katrain/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"engine": {
"katago": "",
"altcommand": "",
"model": "katrain/models/kata1-b18c384nbt-s6582191360-d3422816034.bin.gz",
"model": "katrain/models/kata1-b18c384nbt-s9996604416-d4316597426.bin.gz",
"config": "katrain/KataGo/analysis_config.cfg",
"threads": 12,
"max_visits": 500,
"fast_visits": 25,
"max_time": 8.0,
Expand All @@ -28,7 +27,7 @@
"anim_pv_time": 0.5,
"debug_level": 0,
"lang": "en",
"version": "1.14.0",
"version": "1.15.0",
"load_fast_analysis": false,
"load_sgf_rewind": true
},
Expand Down
22 changes: 12 additions & 10 deletions katrain/core/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,18 @@ def game_report(game, thresholds, depth_filter=None):
for bw in "BW"
}
sum_stats = {
bw: {
"accuracy": 100 * 0.75 ** wt_loss[bw],
"complexity": sum(w for w, aw in weights[bw]) / len(player_ptloss[bw]),
"mean_ptloss": sum(player_ptloss[bw]) / len(player_ptloss[bw]),
"weighted_ptloss": wt_loss[bw],
"ai_top_move": ai_top_move_count[bw] / len(player_ptloss[bw]),
"ai_top5_move": ai_approved_move_count[bw] / len(player_ptloss[bw]),
}
if len(player_ptloss[bw]) > 0
else {}
bw: (
{
"accuracy": 100 * 0.75 ** wt_loss[bw],
"complexity": sum(w for w, aw in weights[bw]) / len(player_ptloss[bw]),
"mean_ptloss": sum(player_ptloss[bw]) / len(player_ptloss[bw]),
"weighted_ptloss": wt_loss[bw],
"ai_top_move": ai_top_move_count[bw] / len(player_ptloss[bw]),
"ai_top5_move": ai_approved_move_count[bw] / len(player_ptloss[bw]),
}
if len(player_ptloss[bw]) > 0
else {}
)
for bw in "BW"
}
return sum_stats, histogram, player_ptloss
Expand Down
4 changes: 2 additions & 2 deletions katrain/core/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PROGRAM_NAME = "KaTrain"
VERSION = "1.14.0"
VERSION = "1.15.0"
HOMEPAGE = "https://github.com/sanderland/katrain"
CONFIG_MIN_VERSION = "1.14.0" # keep config files from this version
CONFIG_MIN_VERSION = "1.15.0" # keep config files from this version
ANALYSIS_FORMAT_VERSION = "1.0"
DATA_FOLDER = "~/.katrain"

Expand Down
2 changes: 1 addition & 1 deletion katrain/core/contribute_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, katrain):
self.max_buffer_games = 2 * settings_dict["maxSimultaneousGames"]
settings = {f"{k}={v}" for k, v in settings_dict.items()}
self.command = shlex.split(
f'"{exe}" contribute -config "{cfg}" -base-dir "{base_dir}" -override-config "{",".join(settings)}"'
f'"{exe}" contribute -config "{cfg}" -base-dir "{base_dir}" -override-config {shlex.quote(",".join(settings))}'
)
self.start()

Expand Down
2 changes: 1 addition & 1 deletion katrain/core/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __init__(self, katrain, config):
self.on_error(i18n._("Kata config not found").format(config=cfg), code="KATAGO-FILES")
return # don't start
self.command = shlex.split(
f'"{exe}" analysis -model "{model}" -config "{cfg}" -analysis-threads {config["threads"]} -override-config "homeDataDir={os.path.expanduser(DATA_FOLDER)}"'
f'"{exe}" analysis -model "{model}" -config "{cfg}" -override-config "homeDataDir={os.path.expanduser(DATA_FOLDER)}"'
)
self.start()

Expand Down
2 changes: 1 addition & 1 deletion katrain/core/sgf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def parse_ngf(cls, ngf):
key = line[4]
raw_move = line[5:7].lower()
if raw_move == "aa":
value = "" # pass
value = "" # pass
else:
value = chr(ord(raw_move[0]) - 1) + chr(ord(raw_move[1]) - 1)

Expand Down
15 changes: 6 additions & 9 deletions katrain/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import heapq
import math
import os
from pathlib import Path
import random
import struct
import sys
from typing import List, Tuple, TypeVar

try:
import importlib.resources as pkg_resources
except ImportError:
import importlib_resources as pkg_resources
import importlib.resources as pkg_resources


T = TypeVar("T")

Expand Down Expand Up @@ -49,14 +47,13 @@ def find_package_resource(path, silent_errors=False):
if path.startswith("katrain"):
if not PATHS.get("PACKAGE"):
try:
with pkg_resources.path("katrain", "gui.kv") as p:
PATHS["PACKAGE"] = os.path.split(str(p))[0]
PATHS["PACKAGE"] = str(pkg_resources.files("katrain").absolute())
except (ModuleNotFoundError, FileNotFoundError, ValueError) as e:
print(f"Package path not found, installation possibly broken. Error: {e}", file=sys.stderr)
return f"FILENOTFOUND/{path}"
return os.path.join(PATHS["PACKAGE"], path.replace("katrain\\", "katrain/").replace("katrain/", ""))
return str(Path(PATHS["PACKAGE"]) / path.replace("katrain\\", "katrain/").replace("katrain/", ""))
else:
return os.path.abspath(os.path.expanduser(path)) # absolute path
return str(Path(path).expanduser().absolute())


def pack_floats(float_list):
Expand Down
Loading