diff --git a/cal_tools/cal_tools/tools.py b/cal_tools/cal_tools/tools.py index 476a170f7569a8da125d47391e6ec20b341b279f..28acbc0997d3a13c07b22b03eed1f057504f09e3 100644 --- a/cal_tools/cal_tools/tools.py +++ b/cal_tools/cal_tools/tools.py @@ -33,12 +33,7 @@ def combine_report(run_path, calibration): group, name_param, conc_param = comps[0], "None", "None" with open("{}/{}.rst".format(sphinx_path, group), "a") as gfile: - if conc_param == "summary": - title = "{}. {}".format(calibration, "Summary.") - gfile.write(title + "\n") - gfile.write( "=" *len (title) + "\n") - gfile.write("\n") - elif conc_param != "None": + if conc_param != "None": title = "{}. {} = {}".format(calibration, name_param, conc_param) gfile.write(title + "\n") gfile.write( "=" *len (title) + "\n") diff --git a/xfel_calibrate/calibrate.py b/xfel_calibrate/calibrate.py index fff5d3bbf2e8ca9d4a250a5b6444253d0b0c64ef..2a419cff47b3a927b1d149b407d4eb16acb8399a 100755 --- a/xfel_calibrate/calibrate.py +++ b/xfel_calibrate/calibrate.py @@ -358,16 +358,6 @@ 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, dependent=False): @@ -386,10 +376,6 @@ 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) @@ -476,6 +462,7 @@ def run(): try: notebook = notebooks[detector][caltype]["notebook"] + dep_notebooks = notebooks[detector][caltype].get("dep_notebooks", []) notebook = os.path.abspath( "{}/{}".format(os.path.dirname(__file__), notebook)) concurrency = notebooks[detector][caltype].get("concurrency", None) @@ -654,28 +641,27 @@ 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 and not run_overall, + 1 and len(dep_notebooks) == 0, joblist, fmtcmd, cluster_cores=cluster_cores, sequential=sequential, priority=priority) joblist.append(jobid) - # Run summary job here if needed - if run_overall: + # Run dependent notebooks + for i, notebook in enumerate(dep_notebooks): + notebook_path = os.path.abspath( + "{}/{}".format(os.path.dirname(__file__), notebook)) + with open(notebook_path, "r") as f: + nb = nbformat.read(f, as_version=4) jobid = concurrent_run(run_tmp_path, nb, os.path.basename(notebook), args, - final_job=True, job_list=joblist, fmtcmd=fmtcmd, + final_job=i==len(dep_notebooks)-1, + job_list=joblist, fmtcmd=fmtcmd, cluster_cores=cluster_cores, sequential=sequential, priority=priority, dependent=True)