add progress bar when checking for infeasibility
This commit is contained in:
parent
29cae8f139
commit
2a230d1444
@ -24,7 +24,7 @@ def update_trivially_feasible_games(variant_id):
|
||||
variant: variants.Variant = variants.Variant.from_db(variant_id)
|
||||
database.cur.execute("SELECT seed FROM seeds WHERE variant_id = (%s) AND feasible is null", (variant_id,))
|
||||
seeds = database.cur.fetchall()
|
||||
logger.info('Checking variant {} (id {}), found {} seeds to check...'.format(variant.name, variant_id, len(seeds)))
|
||||
logger.verbose('Checking variant {} (id {}), found {} seeds to check...'.format(variant.name, variant_id, len(seeds)))
|
||||
|
||||
with alive_progress.alive_bar(total=len(seeds), title='{} ({})'.format(variant.name, variant_id)) as bar:
|
||||
for (seed,) in seeds:
|
||||
|
@ -1,6 +1,8 @@
|
||||
from enum import Enum
|
||||
from typing import List
|
||||
|
||||
import alive_progress
|
||||
|
||||
from hanabi import database
|
||||
from hanabi import logger
|
||||
from hanabi import hanab_game
|
||||
@ -172,14 +174,11 @@ def run_on_database(variant_id):
|
||||
(variant_id,)
|
||||
)
|
||||
res = database.cur.fetchall()
|
||||
logger.info("Checking {} seeds of variant {} for infeasibility".format(len(res), variant_id))
|
||||
logger.verbose("Checking {} seeds of variant {} for infeasibility".format(len(res), variant_id))
|
||||
with alive_progress.alive_bar(total=len(res), title='Check for infeasibility reasons in var {}'.format(variant_id)) as bar:
|
||||
for (seed, num_players, deck_str) in res:
|
||||
deck = compress.decompress_deck(deck_str)
|
||||
reasons = analyze(hanab_game.HanabiInstance(deck, num_players))
|
||||
if reasons:
|
||||
print("found infeasible seed {}: {}".format(seed, reasons))
|
||||
else:
|
||||
print("found nothing for seed {}".format(seed))
|
||||
for reason in reasons:
|
||||
database.cur.execute(
|
||||
"INSERT INTO score_upper_bounds (seed, score_upper_bound, reason) "
|
||||
@ -192,4 +191,5 @@ def run_on_database(variant_id):
|
||||
"UPDATE seeds SET feasible = (%s) WHERE seed = (%s)",
|
||||
(False, seed)
|
||||
)
|
||||
bar()
|
||||
database.conn.commit()
|
||||
|
Loading…
Reference in New Issue
Block a user