in generate/run_ioi_slurm.py [0:0]
def main():
args = parse_args()
# Create output directory if it doesn't exist
output_dir = Path(args.slurm_dir or SLURM_SCRIPT_DIR)
output_dir.mkdir(parents=True, exist_ok=True)
# Create logs directory if it doesn't exist
logs_dir = Path(args.logs_dir or LOGS_DIR)
logs_dir.mkdir(parents=True, exist_ok=True)
# Generate the Slurm script
slurm_script, job_name = create_slurm_script(args, logs_dir)
# Create a timestamp for the filename
from datetime import datetime
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
# Save the script to a file
script_path = output_dir / f"{job_name}_{timestamp}.slurm"
with open(script_path, "w") as f:
f.write(slurm_script)
logger.info(f"Slurm script saved to: {script_path}")
# Make the script executable
os.chmod(script_path, 0o755)
# Submit the job if not a dry run
if not args.dry_run:
try:
result = subprocess.run(
["sbatch", str(script_path)],
check=True,
capture_output=True,
text=True
)
print(f"Job submitted: {result.stdout.strip()} find logs at {LOGS_DIR}/{job_name}")
except subprocess.CalledProcessError as e:
print(f"Error submitting job: {e}")
print(f"Error output: {e.stderr}")
else:
print("Dry run - job not submitted")