1.7.3 (#337)
* download fix * download fix * mac fix * close fix * package * Update osxbuild.yaml
This commit is contained in:
1 parent
faabe9ccba
commit
1cbee4f5e7
5 files changed
+46
-39
No files matched your search
@@ -67,4 +67,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
files: KaTrainOSX/*
|
files: KaTrainOSX/*
|
||||||
draft: true
|
draft: true
|
||||||
fail_on_unmatched_files: true
|
fail_on_unmatched_files: true
|
||||||
+4
-3
@@ -551,8 +551,9 @@ class KaTrainGui(Screen, KaTrainBase):
|
|||||||
@property
|
@property
|
||||||
def popup_open(self) -> Popup:
|
def popup_open(self) -> Popup:
|
||||||
app = App.get_running_app()
|
app = App.get_running_app()
|
||||||
first_child = app.root_window.children[0]
|
if app:
|
||||||
return first_child if isinstance(first_child, Popup) else None
|
first_child = app.root_window.children[0]
|
||||||
|
return first_child if isinstance(first_child, Popup) else None
|
||||||
|
|
||||||
def _on_keyboard_down(self, _keyboard, keycode, _text, modifiers):
|
def _on_keyboard_down(self, _keyboard, keycode, _text, modifiers):
|
||||||
self.last_key_down = keycode
|
self.last_key_down = keycode
|
||||||
@@ -715,7 +716,7 @@ class KaTrainApp(MDApp):
|
|||||||
if getattr(self, "gui", None):
|
if getattr(self, "gui", None):
|
||||||
self.gui.play_mode.save_ui_state()
|
self.gui.play_mode.save_ui_state()
|
||||||
if self.gui.engine:
|
if self.gui.engine:
|
||||||
self.gui.engine.shutdown()
|
self.gui.engine.shutdown(finish=None)
|
||||||
|
|
||||||
def signal_handler(self, _signal, _frame):
|
def signal_handler(self, _signal, _frame):
|
||||||
if self.gui.debug_level >= OUTPUT_DEBUG:
|
if self.gui.debug_level >= OUTPUT_DEBUG:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
PROGRAM_NAME = "KaTrain"
|
PROGRAM_NAME = "KaTrain"
|
||||||
VERSION = "1.7.2"
|
VERSION = "1.7.3"
|
||||||
HOMEPAGE = "https://github.com/sanderland/katrain"
|
HOMEPAGE = "https://github.com/sanderland/katrain"
|
||||||
CONFIG_MIN_VERSION = "1.7.0" # keep config files from this version
|
CONFIG_MIN_VERSION = "1.7.0" # keep config files from this version
|
||||||
ANALYSIS_FORMAT_VERSION = "1.0"
|
ANALYSIS_FORMAT_VERSION = "1.0"
|
||||||
|
|||||||
+14
-10
@@ -1,16 +1,17 @@
|
|||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import platform
|
||||||
import queue
|
import queue
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Callable, Dict, List, Optional
|
from typing import Callable, Dict, List, Optional
|
||||||
|
|
||||||
from kivy.utils import platform
|
from kivy.utils import platform as kivy_platform
|
||||||
|
|
||||||
from katrain.core.constants import OUTPUT_DEBUG, OUTPUT_ERROR, OUTPUT_EXTRA_DEBUG, OUTPUT_KATAGO_STDERR
|
from katrain.core.constants import OUTPUT_DEBUG, OUTPUT_ERROR, OUTPUT_EXTRA_DEBUG, OUTPUT_KATAGO_STDERR
|
||||||
from katrain.core.game_node import GameNode
|
from katrain.core.game_node import GameNode
|
||||||
@@ -60,14 +61,14 @@ class KataGoEngine:
|
|||||||
self.shell = True
|
self.shell = True
|
||||||
else:
|
else:
|
||||||
if not exe:
|
if not exe:
|
||||||
if platform == "win":
|
if kivy_platform == "win":
|
||||||
exe = "katrain/KataGo/katago.exe"
|
exe = "katrain/KataGo/katago.exe"
|
||||||
elif platform == "linux":
|
elif kivy_platform == "linux":
|
||||||
exe = "katrain/KataGo/katago"
|
exe = "katrain/KataGo/katago"
|
||||||
else:
|
else:
|
||||||
exe = find_package_resource("katrain/KataGo/katago-osx") # github actions built
|
exe = find_package_resource("katrain/KataGo/katago-osx") # github actions built
|
||||||
if not os.path.isfile(exe):
|
if not os.path.isfile(exe) or "arm" in platform.machine():
|
||||||
exe = "katago" # e.g. MacOS after brewing
|
exe = "katago" # e.g. MacOS after brewing
|
||||||
|
|
||||||
model = find_package_resource(config["model"])
|
model = find_package_resource(config["model"])
|
||||||
cfg = find_package_resource(config["config"])
|
cfg = find_package_resource(config["config"])
|
||||||
@@ -166,10 +167,13 @@ class KataGoEngine:
|
|||||||
self.wait_to_finish()
|
self.wait_to_finish()
|
||||||
if process:
|
if process:
|
||||||
self.katago_process = None
|
self.katago_process = None
|
||||||
|
self.katrain.log("Terminating KataGo process", OUTPUT_DEBUG)
|
||||||
process.terminate()
|
process.terminate()
|
||||||
for t in [self.stderr_thread, self.analysis_thread, self.write_stdin_thread]:
|
self.katrain.log("Terminated KataGo process", OUTPUT_DEBUG)
|
||||||
if t:
|
if finish is not None: # don't care if exiting app
|
||||||
t.join()
|
for t in [self.write_stdin_thread, self.analysis_thread, self.stderr_thread]:
|
||||||
|
if t:
|
||||||
|
t.join()
|
||||||
|
|
||||||
def is_idle(self):
|
def is_idle(self):
|
||||||
return not self.queries and self.write_queue.empty()
|
return not self.queries and self.write_queue.empty()
|
||||||
|
|||||||
+26
-24
@@ -225,7 +225,7 @@ class QuickConfigGui(MDBoxLayout):
|
|||||||
for c in widget.children:
|
for c in widget.children:
|
||||||
self._set_properties_subtree(c)
|
self._set_properties_subtree(c)
|
||||||
|
|
||||||
def update_config(self, save_to_file=True):
|
def update_config(self, save_to_file=True, close_popup=True):
|
||||||
updated = set()
|
updated = set()
|
||||||
for multikey, value in self.collect_properties(self).items():
|
for multikey, value in self.collect_properties(self).items():
|
||||||
old_value, conf, key = self.get_setting(multikey)
|
old_value, conf, key = self.get_setting(multikey)
|
||||||
@@ -235,14 +235,14 @@ class QuickConfigGui(MDBoxLayout):
|
|||||||
updated.add(multikey)
|
updated.add(multikey)
|
||||||
if save_to_file:
|
if save_to_file:
|
||||||
self.katrain.save_config()
|
self.katrain.save_config()
|
||||||
if self.popup:
|
if self.popup and close_popup:
|
||||||
self.popup.dismiss()
|
self.popup.dismiss()
|
||||||
return updated
|
return updated
|
||||||
|
|
||||||
|
|
||||||
class ConfigTimerPopup(QuickConfigGui):
|
class ConfigTimerPopup(QuickConfigGui):
|
||||||
def update_config(self, save_to_file=True):
|
def update_config(self, save_to_file=True, close_popup=True):
|
||||||
super().update_config(save_to_file=save_to_file)
|
super().update_config(save_to_file=save_to_file, close_popup=close_popup)
|
||||||
for p in self.katrain.players_info.values():
|
for p in self.katrain.players_info.values():
|
||||||
p.periods_used = 0
|
p.periods_used = 0
|
||||||
self.katrain.controls.timer.paused = True
|
self.katrain.controls.timer.paused = True
|
||||||
@@ -283,8 +283,8 @@ class NewGamePopup(QuickConfigGui):
|
|||||||
if rules is not None:
|
if rules is not None:
|
||||||
self.rules_spinner.select_key(rules.strip())
|
self.rules_spinner.select_key(rules.strip())
|
||||||
|
|
||||||
def update_config(self, save_to_file=True):
|
def update_config(self, save_to_file=True, close_popup=True):
|
||||||
super().update_config(save_to_file=save_to_file)
|
super().update_config(save_to_file=save_to_file, close_popup=close_popup)
|
||||||
self.katrain.log(f"New game settings: {self.katrain.config('game')}", OUTPUT_DEBUG)
|
self.katrain.log(f"New game settings: {self.katrain.config('game')}", OUTPUT_DEBUG)
|
||||||
if self.restart.active:
|
if self.restart.active:
|
||||||
self.katrain.log("Restarting Engine", OUTPUT_DEBUG)
|
self.katrain.log("Restarting Engine", OUTPUT_DEBUG)
|
||||||
@@ -356,8 +356,8 @@ class ConfigTeacherPopup(QuickConfigGui):
|
|||||||
)
|
)
|
||||||
super().build_and_set_properties()
|
super().build_and_set_properties()
|
||||||
|
|
||||||
def update_config(self, save_to_file=True):
|
def update_config(self, save_to_file=True, close_popup=True):
|
||||||
super().update_config(save_to_file=save_to_file)
|
super().update_config(save_to_file=save_to_file, close_popup=close_popup)
|
||||||
self.build_and_set_properties()
|
self.build_and_set_properties()
|
||||||
|
|
||||||
|
|
||||||
@@ -421,13 +421,13 @@ class ConfigAIPopup(QuickConfigGui):
|
|||||||
self.options_grid.add_widget(Label(size_hint_x=None))
|
self.options_grid.add_widget(Label(size_hint_x=None))
|
||||||
Clock.schedule_once(self.estimate_rank_from_options)
|
Clock.schedule_once(self.estimate_rank_from_options)
|
||||||
|
|
||||||
def update_config(self, save_to_file=True):
|
def update_config(self, save_to_file=True, close_popup=True):
|
||||||
super().update_config(save_to_file=save_to_file)
|
super().update_config(save_to_file=save_to_file, close_popup=close_popup)
|
||||||
self.katrain.update_calculated_ranks()
|
self.katrain.update_calculated_ranks()
|
||||||
Clock.schedule_once(self.katrain.controls.update_players, 0)
|
Clock.schedule_once(self.katrain.controls.update_players, 0)
|
||||||
|
|
||||||
|
|
||||||
class ConfigPopup(QuickConfigGui):
|
class BaseConfigPopup(QuickConfigGui):
|
||||||
MODEL_ENDPOINTS = {
|
MODEL_ENDPOINTS = {
|
||||||
"Latest distributed model": "https://katagotraining.org/api/networks/newest_training/",
|
"Latest distributed model": "https://katagotraining.org/api/networks/newest_training/",
|
||||||
"Strongest distributed model": "https://katagotraining.org/api/networks/get_strongest/",
|
"Strongest distributed model": "https://katagotraining.org/api/networks/get_strongest/",
|
||||||
@@ -465,13 +465,6 @@ class ConfigPopup(QuickConfigGui):
|
|||||||
super().__init__(katrain)
|
super().__init__(katrain)
|
||||||
self.paths = [self.katrain.config("engine/model"), "katrain/models", DATA_FOLDER]
|
self.paths = [self.katrain.config("engine/model"), "katrain/models", DATA_FOLDER]
|
||||||
self.katago_paths = [self.katrain.config("engine/katago"), DATA_FOLDER]
|
self.katago_paths = [self.katrain.config("engine/katago"), DATA_FOLDER]
|
||||||
Clock.schedule_once(self.check_katas)
|
|
||||||
self.last_clicked_download_models = 0
|
|
||||||
MDApp.get_running_app().bind(language=self.check_models)
|
|
||||||
MDApp.get_running_app().bind(language=self.check_katas)
|
|
||||||
|
|
||||||
def build_and_set_properties(self, *_args):
|
|
||||||
super().build_and_set_properties()
|
|
||||||
|
|
||||||
def check_models(self, *args):
|
def check_models(self, *args):
|
||||||
all_models = [self.MODELS, self.MODEL_DESC, self.katrain.config("dist_models", {})]
|
all_models = [self.MODELS, self.MODEL_DESC, self.katrain.config("dist_models", {})]
|
||||||
@@ -492,7 +485,8 @@ class ConfigPopup(QuickConfigGui):
|
|||||||
|
|
||||||
done = set()
|
done = set()
|
||||||
model_files = []
|
model_files = []
|
||||||
for path in self.paths + [self.model_path.text]:
|
distributed_training_models = os.path.expanduser(os.path.join(DATA_FOLDER, "katago_contribute/kata1/models"))
|
||||||
|
for path in self.paths + [self.model_path.text, distributed_training_models]:
|
||||||
path = path.rstrip("/\\")
|
path = path.rstrip("/\\")
|
||||||
if path.startswith("katrain"):
|
if path.startswith("katrain"):
|
||||||
path = path.replace("katrain", PATHS["PACKAGE"].rstrip("/\\"), 1)
|
path = path.replace("katrain", PATHS["PACKAGE"].rstrip("/\\"), 1)
|
||||||
@@ -608,7 +602,7 @@ class ConfigPopup(QuickConfigGui):
|
|||||||
if not any(os.path.split(f)[1] == filename for f in self.model_files.values):
|
if not any(os.path.split(f)[1] == filename for f in self.model_files.values):
|
||||||
savepath = os.path.expanduser(os.path.join(DATA_FOLDER, filename))
|
savepath = os.path.expanduser(os.path.join(DATA_FOLDER, filename))
|
||||||
savepath_tmp = savepath + ".part"
|
savepath_tmp = savepath + ".part"
|
||||||
self.katrain.log(f"Downloading {name} model from {url} to {savepath_tmp}", OUTPUT_INFO)
|
self.katrain.log(f"Downloading {name} from {url} to {savepath_tmp}", OUTPUT_INFO)
|
||||||
Clock.schedule_once(
|
Clock.schedule_once(
|
||||||
lambda _dt, _savepath=savepath, _savepath_tmp=savepath_tmp, _url=url, _name=name: ProgressLoader(
|
lambda _dt, _savepath=savepath, _savepath_tmp=savepath_tmp, _url=url, _name=name: ProgressLoader(
|
||||||
self.download_progress_box,
|
self.download_progress_box,
|
||||||
@@ -685,7 +679,8 @@ class ConfigPopup(QuickConfigGui):
|
|||||||
savepath_tmp = os.path.expanduser(os.path.join(DATA_FOLDER, filename))
|
savepath_tmp = os.path.expanduser(os.path.join(DATA_FOLDER, filename))
|
||||||
exe_path_name = os.path.expanduser(os.path.join(DATA_FOLDER, exe_name))
|
exe_path_name = os.path.expanduser(os.path.join(DATA_FOLDER, exe_name))
|
||||||
self.katrain.log(f"Downloading binary {name} from {url} to {savepath_tmp}", OUTPUT_INFO)
|
self.katrain.log(f"Downloading binary {name} from {url} to {savepath_tmp}", OUTPUT_INFO)
|
||||||
progress = ProgressLoader(
|
ProgressLoader(
|
||||||
|
root_instance=self.katago_download_progress_box,
|
||||||
download_url=url,
|
download_url=url,
|
||||||
path_to_file=savepath_tmp,
|
path_to_file=savepath_tmp,
|
||||||
downloading_text=f"Downloading {name}: " + "{}",
|
downloading_text=f"Downloading {name}: " + "{}",
|
||||||
@@ -700,7 +695,6 @@ class ConfigPopup(QuickConfigGui):
|
|||||||
f"Download of {mname} failed or cancelled ({error})", OUTPUT_ERROR
|
f"Download of {mname} failed or cancelled ({error})", OUTPUT_ERROR
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
progress.start(self.katago_download_progress_box)
|
|
||||||
downloading = True
|
downloading = True
|
||||||
if not downloading:
|
if not downloading:
|
||||||
if not self.KATAGOS.get(platform):
|
if not self.KATAGOS.get(platform):
|
||||||
@@ -712,8 +706,16 @@ class ConfigPopup(QuickConfigGui):
|
|||||||
Label(text=i18n._("All binaries downloaded"), font_name=i18n.font_name, text_size=(None, dp(50)))
|
Label(text=i18n._("All binaries downloaded"), font_name=i18n.font_name, text_size=(None, dp(50)))
|
||||||
)
|
)
|
||||||
|
|
||||||
def update_config(self, save_to_file=True):
|
|
||||||
updated = super().update_config(save_to_file=save_to_file)
|
class ConfigPopup(BaseConfigPopup):
|
||||||
|
def __init__(self, katrain):
|
||||||
|
super().__init__(katrain)
|
||||||
|
Clock.schedule_once(self.check_katas)
|
||||||
|
MDApp.get_running_app().bind(language=self.check_models)
|
||||||
|
MDApp.get_running_app().bind(language=self.check_katas)
|
||||||
|
|
||||||
|
def update_config(self, save_to_file=True, close_popup=True):
|
||||||
|
updated = super().update_config(save_to_file=save_to_file, close_popup=close_popup)
|
||||||
self.katrain.debug_level = self.katrain.config("general/debug_level", OUTPUT_INFO)
|
self.katrain.debug_level = self.katrain.config("general/debug_level", OUTPUT_INFO)
|
||||||
|
|
||||||
ignore = {"max_visits", "fast_visits", "max_time", "enable_ownership", "wide_root_noise"}
|
ignore = {"max_visits", "fast_visits", "max_time", "enable_ownership", "wide_root_noise"}
|
||||||
|
|||||||
Reference in new issue
Block a user