expand cli for endgames

This commit is contained in:
Maximilian Keßler 2024-01-13 15:38:57 +01:00
parent 816bf0d940
commit 60aa757ba0
Signed by: max
GPG key ID: BCC5A619923C0BA5
2 changed files with 8 additions and 4 deletions

View file

@ -16,10 +16,15 @@ import fetch_games
import ratings import ratings
import stats import stats
import render_site import render_site
import endgames
from log_setup import logger from log_setup import logger
def subcommand_analyze_endgames():
endgames.work_thread()
def subcommand_init(force: bool, no_fetch_variants: bool): def subcommand_init(force: bool, no_fetch_variants: bool):
tables = database.get_existing_tables() tables = database.get_existing_tables()
if len(tables) > 0 and not force: if len(tables) > 0 and not force:
@ -101,6 +106,7 @@ def get_parser() -> argparse.ArgumentParser:
subparsers.add_parser('process-ratings', help="Process ratings of all games.") subparsers.add_parser('process-ratings', help="Process ratings of all games.")
subparsers.add_parser('process-stats', help="Process statistics for all players.") subparsers.add_parser('process-stats', help="Process statistics for all players.")
subparsers.add_parser('generate-site', help="Generate the website from the DB.") subparsers.add_parser('generate-site', help="Generate the website from the DB.")
subparsers.add_parser('analyze-endgames', help="Run endgame analysis on games in DB. Resource intensive!")
subparsers.add_parser('run', help="Run the automatic suite: Fetch + process games and render site.") subparsers.add_parser('run', help="Run the automatic suite: Fetch + process games and render site.")
fetch_parser = subparsers.add_parser('fetch', help='Fetch new data.') fetch_parser = subparsers.add_parser('fetch', help='Fetch new data.')
@ -122,6 +128,7 @@ def main():
'generate-site': subcommand_generate_site, 'generate-site': subcommand_generate_site,
'fetch': subcommand_fetch, 'fetch': subcommand_fetch,
'run': subcommand_run, 'run': subcommand_run,
'analyze-endgames': subcommand_analyze_endgames
}[args.command] }[args.command]
if args.verbose: if args.verbose:

View file

@ -231,9 +231,6 @@ def work_thread():
time.sleep(60 * constants.ENDGAME_ANALYSIS_QUERY_INTERVAL_MINUTES) time.sleep(60 * constants.ENDGAME_ANALYSIS_QUERY_INTERVAL_MINUTES)
else: else:
(game_id, ) = res (game_id, ) = res
logger.info("Analyisng endgame of {}".format(game_id)) logger.info("Analyzing endgame of game {}".format(game_id))
return_code = analyze_and_store_game(game_id) return_code = analyze_and_store_game(game_id)
print("Finished endgame analysis of {}: Returncode {}".format(game_id, return_code)) print("Finished endgame analysis of {}: Returncode {}".format(game_id, return_code))
work_thread()