Skip to content
Snippets Groups Projects
Commit 959066f7 authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Copy calibration_metadata.yml file to output directory instead of symlinking

parent 93dac475
No related branches found
No related tags found
1 merge request!674Copy calibration_metadata.yml file to output directory instead of symlinking
......@@ -447,16 +447,16 @@ def finalize(joblist, finaljob, run_path, out_path, version, title, author, repo
# Notebooks should have a karabo_id parameter, which we'll use to make a
# 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 replace any existing symlink, we create it in a temp folder & rename.
# 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:
tlp = Path(td, f"calibration_metadata_{det}.yml")
tlp.symlink_to(md_path)
tlp.replace(out_path / f"calibration_metadata_{det}.yml")
tmp_path = Path(td, f"calibration_metadata_{det}.yml")
copy(md_path, tmp_path)
tmp_path.replace(out_path / f"calibration_metadata_{det}.yml")
# For continuity, we'll also expose it as $out/calibration_metadata.yml.
# This is only useful if there's 1 calibration run per output folder,
# otherwise the last one to create the link wins.
tlp = Path(td, f"calibration_metadata.yml")
tlp.symlink_to(md_path)
tlp.replace(out_path / "calibration_metadata.yml")
# otherwise the last one to create the file wins.
tmp_path = Path(td, f"calibration_metadata.yml")
copy(md_path, tmp_path)
tmp_path.replace(out_path / "calibration_metadata.yml")
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