<jupyter_start><jupyter_text>I want to streamline the process of submitting several optimization jobs for individual bins.It is similar enouch to the mcmc config notebook that I'm gonna port some functionality from that here.<jupyter_code>from os import path
import numpy as np
import h5py
training_file = '/scratch/users/swmclau2/xi_zheng07_cosmo_lowmsat/PearceRedMagicXiCosmoFixedNd.hdf5'
f = h5py.File(training_file, 'r')
rbins = f.attrs['scale_bins']
rpoints = (rbins[1:]+rbins[:-1])/2.0
np.save('/home/users/swmclau2/Git/pearce/bin/optimization/sloppy_joes_indiv_bins/rpoints.npy', rpoints)<jupyter_output><empty_output><jupyter_text>orig_sbatch_fname = '/home/users/swmclau2/Git/pearce/bin/mcmc/config/pearce_mcmc_config_test.sbatch'with open(orig_sbatch_fname, 'r') as f:    lines = []    for line in f:        lines.append(line)        orig_sbatch = ''.join(lines)<jupyter_code>sbatch_template = """#!/bin/bash
#SBATCH --job-name={ridx:02d}_sloppy_joes_optimization_indiv_bin
#SBATCH --time=04:00:00
#SBATCH -p iric
#SBATCH -o {dirname}/sloppy_joes_optimization_indiv_bin_{ridx:02d}.out
#SBATCH --ntasks=16
#SBATCH --exclusive

module load python/2.7.13
module load py-scipystack
module load hdf5/1.10.0p1
python {dirname}/sloppy_joes_optimization_indiv_bins.py {ridx:02d}
"""
directory = "/home/users/swmclau2/Git/pearce/bin/optimization/sloppy_joes_indiv_bins"
jobname_template = "sloppy_joes_indiv_bin_{ridx:02d}"
for ridx,  _ in enumerate(rpoints):
        jobname = jobname_template.format(ridx=ridx)
            
        with open(path.join(directory, jobname + '.sbatch'), 'w') as f:
            f.write(sbatch_template.format(dirname = directory, ridx = ridx))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.123094958968347, 'fraction_numerical': 0.022860492379835874, 'mean_word_length': 5.441509433962264, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '572573', 'license': 'MIT', 'n_tokens_mistral': 691, 'n_tokens_neox': 653, 'n_words': 113, 'path': 'notebooks/Streamline Individual Bin Optimization.ipynb', 'repo_name': 'mclaughlin6464/pearce', 'size': '1706'}