def main()

in scripts/regression.py [0:0]


def main():
    args = parse_args()

    args.branches = (
        args.branches.split(",") if isinstance(args.branches, str) else args.branches
    )
    args.models = (
        args.models.split(",") if isinstance(args.models, str) else args.models
    )
    args.tasks = (
        ALL_TASKS
        if args.tasks == "all_tasks"
        else utils.pattern_match(args.tasks.split(","), ALL_TASKS)
        if isinstance(args.tasks, str)
        else args.tasks
    )

    global initial_branch
    initial_branch = (
        subprocess.check_output("git branch --show-current", shell=True)
        .decode("ascii")
        .strip()
    )

    # TODO: implement proper timing for each task
    # TODO: reduce IO by sharing tasks between models?

    results, runtime = eval_models(args)
    print(results, runtime)

    runs = []
    for branch in args.branches:
        runs.append((branch, *eval_models(args, branch)))

    os.system(f"git checkout {initial_branch}")

    print("")
    print(f"|task|{'|'.join(map(lambda model: Path(model).name, args.models))}|")
    print(f"|--|{'--|' * len(args.models)}")
    for task in args.tasks:
        print(
            f"|{task} ({initial_branch})|{'|'.join(map(lambda model: format_value(args, results, model, task), args.models))}|"
        )
        for branch, branch_results, branch_runtime in runs:
            print(
                f"|{task} ({branch})|{'|'.join(map(lambda model: format_value(args, branch_results, model, task), args.models))}|"
            )
            print(
                f"|{task} (diff)|{'|'.join(map(lambda model: format_diff(args, results, branch_results, model, task), args.models))}|"
            )

    print("")
    print("|branch|runtime|%|")
    print("|--|--|--|")
    print(f"|{initial_branch}|{runtime:.1f}s|100%|")
    for branch, _, branch_runtime in runs:
        print(f"|{branch}|{branch_runtime:.1f}s|{100 * branch_runtime / runtime:.2f}%|")