Esempio n. 1
0
# prevent asap other modules from defining the root logger using basicConfig
import automl.logger

from ruamel import yaml

import automl
from automl import log
from automl.utils import config_load

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='')
automl.logger.setup(root_level='DEBUG', console_level='INFO')

config = config_load("resources/config.yaml")
config.run_mode = 'script'
config.script = os.path.basename(__file__)
automl.resources.from_config(config)

scores = automl.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))
automl.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("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,
    run_mode=args.mode,
    script=os.path.basename(__file__),
    sid=sid,
) + ns.parse(extras)
if args.mode != 'local':