add progress bar when checking for infeasibility
This commit is contained in:
parent
29cae8f139
commit
2a230d1444
2 changed files with 21 additions and 21 deletions
|
@ -24,7 +24,7 @@ def update_trivially_feasible_games(variant_id):
|
||||||
variant: variants.Variant = variants.Variant.from_db(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,))
|
database.cur.execute("SELECT seed FROM seeds WHERE variant_id = (%s) AND feasible is null", (variant_id,))
|
||||||
seeds = database.cur.fetchall()
|
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:
|
with alive_progress.alive_bar(total=len(seeds), title='{} ({})'.format(variant.name, variant_id)) as bar:
|
||||||
for (seed,) in seeds:
|
for (seed,) in seeds:
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
import alive_progress
|
||||||
|
|
||||||
from hanabi import database
|
from hanabi import database
|
||||||
from hanabi import logger
|
from hanabi import logger
|
||||||
from hanabi import hanab_game
|
from hanabi import hanab_game
|
||||||
|
@ -172,14 +174,11 @@ def run_on_database(variant_id):
|
||||||
(variant_id,)
|
(variant_id,)
|
||||||
)
|
)
|
||||||
res = database.cur.fetchall()
|
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:
|
for (seed, num_players, deck_str) in res:
|
||||||
deck = compress.decompress_deck(deck_str)
|
deck = compress.decompress_deck(deck_str)
|
||||||
reasons = analyze(hanab_game.HanabiInstance(deck, num_players))
|
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:
|
for reason in reasons:
|
||||||
database.cur.execute(
|
database.cur.execute(
|
||||||
"INSERT INTO score_upper_bounds (seed, score_upper_bound, reason) "
|
"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)",
|
"UPDATE seeds SET feasible = (%s) WHERE seed = (%s)",
|
||||||
(False, seed)
|
(False, seed)
|
||||||
)
|
)
|
||||||
|
bar()
|
||||||
database.conn.commit()
|
database.conn.commit()
|
||||||
|
|
Loading…
Reference in a new issue