import argparse
import json

import sys
from pathlib import Path

sys.path.append("..")

from config import CONFIG_DIR
from experiments.grid_runs import execute_grid_run
from experiments.grid_runs_utils import initialize_grid_run


# defaults
default_run_config_path = CONFIG_DIR / "run_default.json"


def main():

    # parse args
    p = argparse.ArgumentParser()
    p.add_argument("-r", "--run-config-path", type=Path, default=default_run_config_path)
    args = p.parse_args()

    # load configs
    run_config = json.loads(args.run_config_path.read_text())

    # init
    grid_run_name = initialize_grid_run(run_config=run_config)

    # run
    results = execute_grid_run(grid_run_name, run_config=run_config)

if __name__ == "__main__":
    main()
