from tqdm import tqdm
import torch

import os
import sys
sys.path.insert(1, os.path.join(sys.path[0], '..'))

from _config import load_config
from _utils import print_system_info, sp_encode


from train_single import run_experminent 

        
if __name__ == '__main__':
    print_system_info()
    configs = load_config(sys.argv[1])
    
    run_configs = tqdm(configs.run_configs, position=0, desc="Experiment")
    
    for run_config in run_configs:
        tasks = tqdm(run_config.tasks, position=1, desc="Task:", leave=False)
        for task_name in tasks:
            tasks.set_description(f'Task: {task_name}')
            torch.cuda.empty_cache()
            
            run_experminent(run_config, task_name)
