Skip to content
Snippets Groups Projects
Commit 9bcd5077 authored by Philipp Schmidt's avatar Philipp Schmidt
Browse files

Fix trying to use report-to name for karabo-id when report is skipped

parent fa628d20
No related branches found
No related tags found
Loading
......@@ -417,7 +417,6 @@ def finalize(joblist, finaljob, run_path, out_path, version, title, author, repo
)
metadata.save()
if report_to:
report_to = Path(report_to)
prepare_plots(run_path)
......@@ -435,10 +434,19 @@ def finalize(joblist, finaljob, run_path, out_path, version, title, author, repo
# Store the contents of the Slurm working directory next to the report.
# This contains elements needed for reproducibility.
slurm_archive_dir = report_to.parent / f"slurm_out_{report_to.name}"
det = metadata['calibration-configurations'].get('karabo-id', report_to.name)
else:
try:
det = metadata['calibration-configurations']['karabo-id']
except KeyError:
# Generate a hash based on job IDs to uniquely identify this
# detector.
from hashlib import sha1
det = sha1(''.join(joblist).encode('ascii')).hexdigest()[:8]
# If there is no report location, simply move the slurm_out_
# directory to the output.
slurm_archive_dir = Path(out_path) / f"slurm_out_{run_path.name}"
slurm_archive_dir = Path(out_path) / f"slurm_out_{det}"
print(f"Moving temporary files to final location: {slurm_archive_dir}")
move(str(run_path), str(slurm_archive_dir)) # Needs str until Python 3.9
......@@ -448,7 +456,7 @@ def finalize(joblist, finaljob, run_path, out_path, version, title, author, repo
# unique name like calibration_metadata_MID_DET_AGIPD1M-1.yml in the output
# folder. In case they don't, fall back to a name like the report.
# To avoid interleaved writes, we'll copy it to a temp folder, then rename.
det = metadata['calibration-configurations'].get('karabo-id', report_to.name)
with TemporaryDirectory(dir=out_path) as td:
tmp_path = Path(td, f"calibration_metadata_{det}.yml")
copy(md_path, tmp_path)
......
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