Support for saving metadata fragments & merging into calibration_metadata.yml
Description
We want to remove the duplication of looking up calibration constants in both a pre- notebook and the main correction notebook. If we adopt CalParrot as planned (!767 (merged)), the only remaining missing bit will be writing the constant details to the calibration_metadata.yml
file. The difficulty in doing that from the main notebooks is that they run in parallel - if two happened to write the file at the same time, it could get corrupted.
I see two possible approaches for dealing with this:
- This MR: Write metadata to fragment files, and then merge them back into
calibration_metadata.yml
in the finalize step. So we'd temporarily have one extra file per notebook. - Branch feat/update-lock-metadata-yml: provide a way to read-update-write a file while holding a lock on it, so if two notebooks tried to do this at the same time, one would be forced to wait to get the lock. However, I'd want to do some more work to allow for a timeout on acquiring the lock, which is unfortunately not as simple to do as I'd like.
One remaining concern with either option: if different copies of the notebook should find different constants - e.g. if a bug means one gets a CalParrot stored reply and the other gets a new reply from CalCat - then what is recorded in calibration_metadata.yml
will be random. Perhaps when merging, we should warn if there are conflicting values in the metadata?
How Has This Been Tested?
TBD
Types of changes
- New feature (non-breaking change which adds functionality)
Checklist:
- My code follows the code style of this project.