Find Maia UCI binary from deploy venv
This commit is contained in:
@@ -13,6 +13,7 @@ Environment=MAIA_DEVICE=cpu
|
||||
Environment=MAIA_USE_AMP=false
|
||||
Environment=HF_HOME=/root/blog-backend/.cache/huggingface
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
Environment=PATH=/root/blog-backend/maia-engine-venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
ExecStart=/root/blog-backend/maia-engine-venv/bin/python -m uvicorn app.main:app --host 127.0.0.1 --port 8000
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
import chess
|
||||
import chess.engine
|
||||
@@ -37,9 +40,22 @@ def model_alias(model: str) -> str:
|
||||
return f"maia3-{model}"
|
||||
|
||||
|
||||
def engine_executable() -> str:
|
||||
executable_name = "maia3-uci.exe" if os.name == "nt" else "maia3-uci"
|
||||
venv_executable = Path(sys.executable).with_name(executable_name)
|
||||
if venv_executable.exists():
|
||||
return str(venv_executable)
|
||||
|
||||
path_executable = shutil.which("maia3-uci")
|
||||
if path_executable:
|
||||
return path_executable
|
||||
|
||||
return "maia3-uci"
|
||||
|
||||
|
||||
def engine_command(model: str) -> list[str]:
|
||||
command = [
|
||||
"maia3-uci",
|
||||
engine_executable(),
|
||||
"--model",
|
||||
model_alias(model),
|
||||
"--use-uci-history",
|
||||
|
||||
Reference in New Issue
Block a user