#!/usr/bin/env python

# System
import argparse
import yaml

# Local
import hyppo

def parse_args():
    """
    Parse command line arguments.
    """
    parser = argparse.ArgumentParser('hyppo',description="A novel UQ-informed surrogate-based hyperparameter optimization tool.",epilog="Copyright (c) 2021, The Regents of the University of California. All rights reserved.")
    add_arg = parser.add_argument
    add_arg('operation', choices=['sampling','slurm','slurm_split','estimate','evaluation','sensitivity','surrogate'],
            help='Operation to be executed')
    add_arg('config_file',
            help='Input configuration file')
    add_arg('-d','--debug', type=int, default=0,
            help='Show model summary, for debugging purposes')
    return parser.parse_args()

def main():
    print("  ___________________________________   ")
    print(" |   _                               |  ")
    print(" |  | |  https://hpo-uq.gitlab.io/   |  ")
    print(" |  | |__ __  __ _ __  _ __   ___    |  ")
    print(" |  | '_  \ \/ /| '_ \| '_ \ / _ \   |  ")
    print(" |  | | | |\  / | |_) | |_) | (_) |  |  ")
    print(" |  |_| |_|/ /  | .__/| .__/ \___/   |  ")
    print(" |        / /   | |   | |            |  ")
    print(" |       /_/    |_|   |_|            |  ")
    print(" |___________________________________|\n")
    # Extract user arguments
    args = parse_args()
    # Load configuration file
    config = hyppo.load_config(**vars(args))
    # Execute relevant action
    eval('hyppo.'+args.operation)(config)

if __name__ == '__main__':
    main()
