__author__ = "Lukas Leufen"
__date__ = '2020-06-29'

import argparse
from mlair.workflows import DefaultWorkflowHPC
from mlair.helpers import remove_items
from mlair.configuration.defaults import DEFAULT_PLOT_LIST
from mlair.model_modules.model_class import IntelliO3_ts_architecture
import os


def load_stations(external_station_list=None):
    import json
    if external_station_list is None:
        external_station_list = 'supplement/station_list_north_german_plain_rural.json'
    try:
        filename = external_station_list
        with open(filename, 'r') as jfile:
            stations = json.load(jfile)
    except FileNotFoundError:
        stations = None
    return stations


def main(parser_args):
    plots = remove_items(DEFAULT_PLOT_LIST, "PlotConditionalQuantiles")
    workflow = DefaultWorkflowHPC(#stations=load_stations('supplement/German_background_stations.json'),
        stations=["DEBW013", "DEBW087", "DEBW107", "DEBW076"],
        epochs=1,
        train_model=True, create_new_model=True, network="UBA",
        #model=IntelliO3_ts_architecture,
        oversampling_method="bin_oversampling",
        evaluate_bootstraps=False, plot_list=["PlotOversamplingContingency"],
        competitors=["intellitest"],
        #competitor_path="/p/project/deepacf/intelliaq/gramlich1/mlair/competitors/o3",
        window_lead_time=1, oversampling_bins=2, oversampling_rates_cap=2,
        **parser_args.__dict__)
    workflow.run()


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('--experiment_date', metavar='--exp_date', type=str, default="testrun",
                        help="set experiment date as string")
    args = parser.parse_args()
    main(args)