diff --git a/bin/slurm_finalize.sh b/bin/slurm_finalize.sh index 9eaf9a73581d5861f3fba2005324de0542e1a4f0..461d7cdd1d0112da2329efbff12fbbffdfce1bad 100755 --- a/bin/slurm_finalize.sh +++ b/bin/slurm_finalize.sh @@ -6,6 +6,7 @@ set -euo pipefail python_path=$1 temp_dir=$2 finalize_script=$3 +report_to=$4 echo "Running with the following parameters:" echo "Python path: $python_path" @@ -23,9 +24,11 @@ export MPLBACKEND=AGG # Ensure Python uses UTF-8 for files by default export LANG=en_US.UTF-8 -shopt -s failglob # Fail fast if there are no notebooks found -echo "Converting notebooks" -${python_path} -m nbconvert --to rst --TemplateExporter.exclude_input=True "$temp_dir"/*.ipynb -shopt -u failglob # Restore default glob behaviour +if [ -n "$report_to" ]; then + shopt -s failglob # Fail fast if there are no notebooks found + echo "Converting notebooks" + ${python_path} -m nbconvert --to rst --TemplateExporter.exclude_input=True "$temp_dir"/*.ipynb + shopt -u failglob # Restore default glob behaviour +fi ${python_path} "$finalize_script" diff --git a/src/xfel_calibrate/calibrate.py b/src/xfel_calibrate/calibrate.py index e83c60a41de3796751e0b7fd7873cfd650f1468e..e0ec92e718e2211b9118b889b7a7bcc9b451257a 100755 --- a/src/xfel_calibrate/calibrate.py +++ b/src/xfel_calibrate/calibrate.py @@ -83,6 +83,9 @@ def make_initial_parser(**kwargs): help='Filename (and optionally path) for output' ' report') + parser.add_argument('--skip-report', action='store_true', + help='Skip report generation in finalize step.') + parser.add_argument('--concurrency-par', type=str, help='Name of concurrency parameter.' 'If not given, it is taken from configuration.') @@ -642,6 +645,7 @@ def run_finalize(fmt_args, temp_path, job_list, sequential=False): sys.executable, # Python with calibration machinery installed temp_path, finalize_script, + fmt_args['report_to'] ] output = check_output(cmd, input=b'').decode('utf8') @@ -1057,7 +1061,9 @@ def run(): out_path.mkdir(parents=True, exist_ok=True) # Use given report name, falling back to notebook title - if args["report_to"] is None: + if args['skip_report']: + report_to = '' + elif args["report_to"] is None: report_to = out_path / title.replace(" ", "") print(f"report_to not specified, will use {report_to}") else: @@ -1086,7 +1092,8 @@ def run(): parm_subdict[name] = p.value metadata["pycalibration-version"] = version - metadata["report-path"] = f"{report_to}.pdf" + metadata["report-path"] = f"{report_to}.pdf" if report_to \ + else '# REPORT SKIPPED #' metadata["concurrency"] = { 'parameter': concurrency_par, 'default': concurrency_defval, diff --git a/src/xfel_calibrate/finalize.py b/src/xfel_calibrate/finalize.py index 3683063011ea05753aad60c7cd893c969c502831..0c3ef4cdc70c83ad8b2a89bafb05cea991dfab43 100644 --- a/src/xfel_calibrate/finalize.py +++ b/src/xfel_calibrate/finalize.py @@ -397,8 +397,6 @@ def finalize(joblist, finaljob, run_path, out_path, version, report_to, data_pat request_time='', submission_time=''): run_path = Path(run_path) - prepare_plots(run_path) - # Archiving files in slurm_tmp if finaljob: joblist.append(str(finaljob)) @@ -427,13 +425,21 @@ def finalize(joblist, finaljob, run_path, out_path, version, report_to, data_pat metadata.save() metadata.save_copy(run_path) - sphinx_path = combine_report(run_path, title) - make_titlepage(sphinx_path, title, data_path, version) - make_report( - Path(sphinx_path), - run_path, - title, - author, - version, - Path(report_to), - ) + if report_to: + prepare_plots(run_path) + + sphinx_path = combine_report(run_path, title) + make_titlepage(sphinx_path, title, data_path, version) + make_report( + Path(sphinx_path), + run_path, + title, + author, + version, + Path(report_to), + ) + else: + # If there is no report location, simply copy the slurm_out_ + # directory to the output. + slurm_archive_dir = Path(out_path) / f"slurm_out_{run_path.name}" + move(str(run_path), str(slurm_archive_dir))