from slurm_utils import create_and_submit_batch_job
from datetime import datetime
import os
from pathlib import Path
import argparse

PROJECT_ROOT = Path(os.path.realpath(__file__)).parents[1]

parser = argparse.ArgumentParser()
parser.add_argument('--interactive', action='store_true')
args = parser.parse_args()
# DATA_DIR = 'uspto_full'
SCRIPT_DIR = 'scripts'
platform = 'lumi'
project = 'project_462000833'
slurm_args = {
    'job_dir': 'jobs',
    'job_ids_file': 'job_ids.txt',
    'output_dir': 'output',
    'platform': platform,
    'project': project,
    'time': '01:00:00',
    'partition': 'small',
    'nodes': 1,
    'ntasks-per-node': 1,
    'cpus-per-task': 1,
    'mem': '20G', # 50G not enough for uspto_full
    'with_containers': True,
    'container': 'multiguide-lumi.sif',
    'venv_path': 'multiguide-lumi-container',
    'start_array_job': 101, # 5 to 37
    'end_array_job': 189 #37
}
time_stamp = datetime.now().strftime("%Y%m%d_%H%M%S")
script_args = {"script_dir": SCRIPT_DIR,
                "use_torchrun": 'false',
                "args": {'dataset': 'uspto_full',
                         'dataset.route_idx': '$route_idx'},
                "variables": {'route_idx': '$SLURM_ARRAY_TASK_ID'}}
script_args['script_name'] = 'find_route_reactions_in_dataset.py'
task = 'find_route_reactions_in_dataset'
slurm_args['job_name'] = task
output = create_and_submit_batch_job(slurm_args, script_args, interactive=args.interactive)