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,24 +174,22 @@ 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))
|
||||||
for (seed, num_players, deck_str) in res:
|
with alive_progress.alive_bar(total=len(res), title='Check for infeasibility reasons in var {}'.format(variant_id)) as bar:
|
||||||
deck = compress.decompress_deck(deck_str)
|
for (seed, num_players, deck_str) in res:
|
||||||
reasons = analyze(hanab_game.HanabiInstance(deck, num_players))
|
deck = compress.decompress_deck(deck_str)
|
||||||
if reasons:
|
reasons = analyze(hanab_game.HanabiInstance(deck, num_players))
|
||||||
print("found infeasible seed {}: {}".format(seed, reasons))
|
for reason in reasons:
|
||||||
else:
|
database.cur.execute(
|
||||||
print("found nothing for seed {}".format(seed))
|
"INSERT INTO score_upper_bounds (seed, score_upper_bound, reason) "
|
||||||
for reason in reasons:
|
"VALUES (%s,%s,%s) "
|
||||||
database.cur.execute(
|
"ON CONFLICT (seed, reason) DO UPDATE "
|
||||||
"INSERT INTO score_upper_bounds (seed, score_upper_bound, reason) "
|
"SET score_upper_bound = EXCLUDED.score_upper_bound",
|
||||||
"VALUES (%s,%s,%s) "
|
(seed, reason.score_upper_bound, reason.type.value)
|
||||||
"ON CONFLICT (seed, reason) DO UPDATE "
|
)
|
||||||
"SET score_upper_bound = EXCLUDED.score_upper_bound",
|
database.cur.execute(
|
||||||
(seed, reason.score_upper_bound, reason.type.value)
|
"UPDATE seeds SET feasible = (%s) WHERE seed = (%s)",
|
||||||
)
|
(False, seed)
|
||||||
database.cur.execute(
|
)
|
||||||
"UPDATE seeds SET feasible = (%s) WHERE seed = (%s)",
|
bar()
|
||||||
(False, seed)
|
|
||||||
)
|
|
||||||
database.conn.commit()
|
database.conn.commit()
|
||||||
|
|
Loading…
Reference in a new issue