<s> """<STR_LIT>""" <EOL> import os . path <EOL> import csv <EOL> import borg <EOL> import borg . distributors <EOL> logger = borg . get_logger ( __name__ , default_level = "<STR_LIT>" ) <EOL> def features_for_path ( domain , task_path ) : <EOL> import os . path <EOL> import borg <EOL> logger = borg . get_logger ( __name__ , default_level = "<STR_LIT>" ) <EOL> logger . info ( "<STR_LIT>" , os . path . basename ( task_path ) ) <EOL> with domain . task_from_path ( task_path ) as task : <EOL> with borg . accounting ( ) as accountant : <EOL> ( names , values ) = domain . compute_features ( task ) <EOL> return ( <EOL> task_path , <EOL> [ "<STR_LIT>" ] + list ( names ) , <EOL> [ accountant . total . cpu_seconds ] + list ( values ) ) <EOL> @ borg . annotations ( <EOL> domain_name = ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> instances_root = ( "<STR_LIT>" , "<STR_LIT>" , None , os . path . abspath ) , <EOL> suffix = ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> skip_existing = ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> distributor_name = ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> workers = ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:w>" , int ) , <EOL> ) <EOL> def main ( <EOL> domain_name , <EOL> instances_root , <EOL> suffix = "<STR_LIT>" , <EOL> skip_existing = False , <EOL> distributor_name = "<STR_LIT>" , <EOL> workers = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> def yield_runs ( ) : <EOL> if os . path . exists ( domain_name ) : <EOL> domain = borg . load_solvers ( domain_name ) . domain <EOL> else : <EOL> domain = borg . get_domain ( domain_name ) <EOL> paths = list ( borg . util . files_under ( instances_root , domain . extensions ) ) <EOL> count = <NUM_LIT:0> <EOL> for path in paths : <EOL> if skip_existing and os . path . exists ( path + suffix ) : <EOL> continue <EOL> count += <NUM_LIT:1> <EOL> yield ( features_for_path , [ domain , path ] ) <EOL> logger . info ( "<STR_LIT>" , count ) <EOL> distributor = borg . distributors . make ( <EOL> distributor_name , <EOL> workers = workers ) <EOL> for ( cnf_path , names , values ) in distributor . do ( yield_runs ( ) ) : <EOL> csv_path = cnf_path + suffix <EOL> with open ( csv_path , "<STR_LIT:wb>" ) as csv_file : <EOL> csv . writer ( csv_file ) . writerow ( names ) <EOL> csv . writer ( csv_file ) . writerow ( values ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> borg . script ( main ) </s>
