Save metadata in-place in limited cases #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This enables the save button and makes it overwrite the existing metadata file associated with the layer. The motivation is to allow metadata changes that don't require rewriting all the layer data, which could be achieved through the standard Save selected layer ... option in napari.
But it's also a potentially dangerous/lossy operation, so it is only enabled if all the following conditions hold.
1. The layer was read with this plugin. This way we know it's an ome-zarr, we know what file to overwrite (the multiscale image group's zattrs), and can do so with ome-zarr's
write_multiscales_metadata
function.2. The layer's file path is writable. I'm assuming this won't typically apply for ome-zarr stored on remote cloud services like S3.
3. The number of axes is the same in the layer and original file. In particular,
napari-ome-zarr
splits multi-channel images into multiple layers.In the case that it is not supported, the tooltip of the save button gives a reason why.
Closes #31