Specify config patches rather than full config files in settings
A key frustration during development is out of sync ofm_config.json files. This will become a bigger problem as there become more options, because not only will we need to copy across the bas file from the repo, we will need to re-apply any changes (such as using the HQ camera).
This MR doesn't change the base behaviour if you have a full LabThings config file. But it adds the option to specify a base config file and optionally a patch to change it based on the patching mechanism described here.
As such we can ship the OS with the following config file:
{
"base_config_file": "$OFM_LIB/ofm_config_full.json"
}
This way whatever the main config file is in the repo, will be the config file used.
In the case where the camera needs adjusting to the HQ camera this can be done as:
{
"base_config_file": "$OFM_LIB/ofm_config_full.json",
"patch": {"things": {"/camera/": {"kwargs": {"camera_board": "picamera_hq"}}}}
}
This would mean that an HQ camera microscope would otherwise stay in sync with any changes in the repo.
This method would be very compatible with the idea of a future configuration server, as it separates out configuration changes from base configuration.
Note for testing:
The ofm systemd service has no $OFM_LIB environment var. You either need to add the $OFM_LIB environment var or to the service file or try the following configuration file:
{
"base_config_file": "/var/openflexure/application/openflexure-microscope-server/ofm_config_full.json"
}
This MR contains the following
- Implement JSON patching in line with IETF RFC 7396
- Perform all tests specified in IETF RFC 7396 to check the patching method is compliant.
- Add method detecting base config file and patches instead of a full LabThings config file and applying the patch.
Before merge:
-
Tests for patching config files.
Merge checklist:
-
All new/changed functions have up to date typehints and docstrings Any UI updates have a before and after screenshot in the MR description-
Unit testing of new functionality has similar or better coverage than similar existing code -
This code has been tested on a microscope Webapp has been recompiled, with aesthetic changes checked in light and dark mode (if changed)-
With updated settings JSON (if changed) -
SmartScan and live stitching work