<s> import argparse <EOL> import sqlite3 <EOL> from operator import itemgetter <EOL> import os <EOL> import sys <EOL> parser = argparse . ArgumentParser ( description = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , metavar = '<STR_LIT>' , default = False , type = str , nargs = '<STR_LIT:+>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , action = '<STR_LIT:store_true>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , metavar = '<STR_LIT>' , type = int , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( ) <EOL> conn = sqlite3 . connect ( args . database ) <EOL> conn . text_factory = str <EOL> cur = conn . cursor ( ) <EOL> if not args . tables : <EOL> cmd = cur . execute ( "<STR_LIT>" ) <EOL> tbls = [ t for t , in cmd . fetchall ( ) ] <EOL> else : <EOL> tbls = args . tables <EOL> print '<STR_LIT>' , tbls <EOL> for tbl in tbls : <EOL> try : <EOL> print '<STR_LIT>' , tbl <EOL> cmd = cur . execute ( "<STR_LIT>" . format ( args . base_on , tbl ) ) <EOL> vals = cmd . fetchall ( ) <EOL> vals = sorted ( vals , key = itemgetter ( <NUM_LIT:1> ) , reverse = args . descending ) <EOL> print vals <EOL> topk = args . keep_topk if args . keep_topk < len ( vals ) else len ( vals ) <EOL> print '<STR_LIT>' , topk <EOL> for i in xrange ( topk , len ( vals ) ) : <EOL> exp_id = vals [ i ] [ <NUM_LIT:0> ] <EOL> print '<STR_LIT>' , vals [ i ] <EOL> print os . system ( '<STR_LIT>' . format ( args . model_root_dir , exp_id ) ) <EOL> except : <EOL> print '<STR_LIT>' , sys . exc_info ( ) [ <NUM_LIT:0> ] <EOL> conn . close ( ) </s>
