webknossos-libs
webknossos-libs copied to clipboard
No satisfying error handling when uploading a dataset with an empty layer
Context
- Affected library: webknossos
The error occurs when creating a Dataset that contains an empty layer using the WK python library and subsequently calling
dataset.upload(). Code to reproduce the error
import webknossos as wk
import numpy as np
def main():
dataset = wk.Dataset("testoutput/emptyLayerDataset", voxel_size=(30, 30, 32.48))
layer = dataset.add_layer(
layer_name="color", category="color", dtype_per_channel="uint8", num_channels=3
)
mag1 = layer.add_mag("1")
mag1.write(
absolute_offset=(10, 20, 30),
# assuming the layer has 3 channels:
data=(np.random.rand(3, 512, 512, 32) * 255).astype(np.uint8),
)
layer = dataset.add_layer(
layer_name="segmentation",
category="segmentation",
largest_segment_id="255",
dtype_per_channel="uint8",
num_channels=1,
)
remote_dataset = dataset.upload()
url = remote_dataset.url
print(f"Successfully uploaded {url}")
if __name__ == "__main__":
main()
Expected Behavior
A descriptive Error message like "The dataset contains an empty layer." should be thrown.
Current Behavior
The following error message appears: FileNotFoundError: Cannot create read-only dataset, could not find data at https://data-humerus.webknossos.org/data/zarr/scalable_minds/emptyLayerDataset.