import amlb.logger from ruamel import yaml import amlb from amlb import log from amlb.utils import config_load root_dir = os.path.dirname(__file__) parser = argparse.ArgumentParser() parser.add_argument('predictions', type=str, help='The predictions file to load and compute the scores for.') args = parser.parse_args() # script_name = os.path.splitext(os.path.basename(__file__))[0] # log_dir = os.path.join(args.outdir if args.outdir else '.', 'logs') # os.makedirs(log_dir, exist_ok=True) # now_str = datetime_iso(date_sep='', time_sep='') amlb.logger.setup(root_level='DEBUG', console_level='INFO') config = config_load("resources/config.yaml") config.run_mode = 'script' config.root_dir = root_dir config.script = os.path.basename(__file__) amlb.resources.from_config(config) scores = amlb.TaskResult.score_from_predictions_file(args.predictions) log.info("\n\nScores computed from %s:\n%s", args.predictions, yaml.dump(dict(scores), default_flow_style=False))
args.constraint, extras.get('run_mode', args.mode)]) .lower(), now_str)).replace("/", "_") log_dir = amlb.resources.output_dirs(args.outdir or os.path.join(os.getcwd(), 'logs'), session=sid, subdirs='logs' if args.outdir else '', create=True)['logs' if args.outdir else 'session'] # now_str = datetime_iso(time=False, no_sep=True) if args.profiling: logging.TRACE = logging.INFO amlb.logger.setup(log_file=os.path.join(log_dir, '{script}.{now}.log'.format(script=script_name, now=now_str)), root_file=os.path.join(log_dir, '{script}.{now}.full.log'.format(script=script_name, now=now_str)), root_level='INFO', app_level='DEBUG', console_level='INFO', print_to_log=True) log.info("Running `%s` on `%s` benchmarks in `%s` mode.", args.framework, args.benchmark, args.mode) log.debug("Script args: %s.", args) config = config_load(os.path.join(root_dir, "resources", "config.yaml")) # allowing config override from user_dir: useful to define custom benchmarks and frameworks for example. config_user = config_load(os.path.join(args.userdir if args.userdir is not None else config.user_dir, "config.yaml")) # config listing properties set by command line config_args = ns.parse( {'results.save': args.keep_scores}, input_dir=args.indir, output_dir=args.outdir, user_dir=args.userdir, root_dir=root_dir, script=os.path.basename(__file__), run_mode=args.mode, parallel_jobs=args.parallel,
app=args.logging.upper(), root=args.logging.upper()) if args. logging else {}) | ns(console='INFO', app='DEBUG', root='INFO') # adding defaults if needed amlb.logger.setup(log_file=os.path.join( log_dir, '{script}.{now}.log'.format(script=script_name, now=now_str)), root_file=os.path.join( log_dir, '{script}.{now}.full.log'.format(script=script_name, now=now_str)), root_level=log_levels.root, app_level=log_levels.app, console_level=log_levels.console, print_to_log=True) log.info("Running benchmark `%s` on `%s` framework in `%s` mode.", args.framework, args.benchmark, args.mode) log.debug("Script args: %s.", args) config_default = config_load( os.path.join(default_dirs.root_dir, "resources", "config.yaml")) config_default_dirs = default_dirs # allowing config override from user_dir: useful to define custom benchmarks and frameworks for example. config_user = config_load( extras.get( 'config', os.path.join(args.userdir or default_dirs.user_dir, "config.yaml"))) # config listing properties set by command line config_args = ns.parse( {'results.save': args.keep_scores}, input_dir=args.indir, output_dir=args.outdir,