Skip to content
Snippets Groups Projects
Commit c8bd3e9c authored by Mikhail Karnevskiy's avatar Mikhail Karnevskiy
Browse files

Add summary job option

parent 9e6669d3
No related branches found
No related tags found
1 merge request!74Feat: Add summary job option
......@@ -31,9 +31,14 @@ def combine_report(run_path, calibration):
group, name_param, conc_param = "_".join(comps[:-2]), comps[-2], comps[-1]
else:
group, name_param, conc_param = comps[0], "None", "None"
with open("{}/{}.rst".format(sphinx_path, group), "a") as gfile:
if conc_param != "None":
if conc_param == "summary":
title = "{}. {}".format(calibration, "Summary.")
gfile.write(title + "\n")
gfile.write( "=" *len (title) + "\n")
gfile.write("\n")
elif conc_param != "None":
title = "{}. {} = {}".format(calibration, name_param, conc_param)
gfile.write(title + "\n")
gfile.write( "=" *len (title) + "\n")
......
......@@ -358,9 +358,19 @@ def flatten_list(l):
return "_".join([str(flatten_list(v)) for v in l]) if isinstance(l, list) else l
def clean_nonfinal_cells(nb):
first_cell = False
for cell in nb.cells:
if not first_cell and cell.cell_type == 'code':
first_cell = True
continue
if '!!!FINAL!!!' not in cell.source:
cell.source = ''
def concurrent_run(temp_path, nb, nbname, args, cparm=None, cval=None,
final_job=False, job_list=[], fmtcmd="", cluster_cores=8,
sequential=False, priority=2):
sequential=False, priority=2, dependent=False):
""" Launch a concurrent job on the cluster via SLURM
"""
......@@ -376,6 +386,10 @@ def concurrent_run(temp_path, nb, nbname, args, cparm=None, cval=None,
parms = extract_parameters(nb)
params = parameter_values(parms, **args)
new_nb = replace_definitions(nb, params, execute=False)
if dependent:
suffix = "summary"
clean_nonfinal_cells(new_nb)
base_name = nbname.replace(".ipynb", "")
new_name = "{}__{}__{}.ipynb".format(
os.path.basename(base_name), cparm, suffix)
......@@ -416,6 +430,12 @@ def concurrent_run(temp_path, nb, nbname, args, cparm=None, cval=None,
else:
srun_base = []
if dependent:
srun_dep = "--dependency=afterok"
for jobid in job_list:
srun_dep += ":{}".format(jobid)
srun_base += [srun_dep]
srun_base += [os.path.abspath("{}/bin/slurm_calibrate.sh".format(os.path.dirname(__file__))), # path to helper sh
os.path.abspath(nbpath), # path to notebook
python_path, # path to python
......@@ -634,15 +654,33 @@ def run():
cvtype = p.type
break
run_overall = False
for p in parms:
if p.name == 'run_overall':
run_overall = p.value
break
for cnum, cval in enumerate(cvals):
jobid = concurrent_run(run_tmp_path, nb, notebook, args,
cvar, [cval, ] if not isinstance(
cval, list) and cvtype is list else cval,
cnum == len(list(cvals)) -
1, joblist, fmtcmd,
1 and not run_overall,
joblist, fmtcmd,
cluster_cores=cluster_cores, sequential=sequential, priority=priority)
joblist.append(jobid)
# Run summary job here if needed
if run_overall:
jobid = concurrent_run(run_tmp_path, nb, os.path.basename(notebook),
args,
final_job=True, job_list=joblist, fmtcmd=fmtcmd,
cluster_cores=cluster_cores,
sequential=sequential, priority=priority,
dependent=True)
joblist.append(jobid)
if not all([j is None for j in joblist]):
print("Submitted the following SLURM jobs: {}".format(",".join(joblist)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment