webknossos-libs
webknossos-libs copied to clipboard
Error when uploading annotations with fallback_layer: Resolution restrictions result in zero resolutions
Hi,
I tried to upload annotations with a fallback_layer included:
# test.py
import webknossos as wk
fallback_layer = wk.Dataset\
.open_remote('https://webknossos.org/datasets/Demo_Organization/kasthuri2011')\
.get_segmentation_layers()[0]
annotation = wk.Annotation(
name="test_annotation",
dataset_name = fallback_layer.dataset.name,
voxel_size = fallback_layer.dataset.voxel_size,
)
annotation.user_bounding_boxes = [
wk.BoundingBox((5300, 8000, 1024), (256, 256, 256), name="my_bbox")
]
annotation.add_volume_layer(
name = wk.SEGMENTATION_CATEGORY,
fallback_layer = fallback_layer,
)
annotation.upload()
and I ran the script on Ubuntu 22.04.03 LTS via:
git clone https://github.com/scalableminds/webknossos-libs.git
cd webknossos-libs/webknossos
export WK_TOKEN=<my private webknossos.org access token>
poetry install
poetry run python test.py
However, the upload fails with the error message:
Resolution restrictions result in zero resolutions
See complete error message
Traceback (most recent call last):
File "/home/XXX/src/webknossos-libs/webknossos/webknossos/client/api_client/_abstract_api_client.py", line 215, in _assert_good_response
response.raise_for_status()
File "/home/XXX/.cache/pypoetry/virtualenvs/webknossos-7ql79mED-py3.10/lib/python3.10/site-packages/httpx/_models.py", line 749, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://webknossos.org/api/v5/annotations/upload'
For more information check: https://httpstatuses.com/400
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/XXX/src/webknossos-libs/webknossos/test.py", line 16, in <module>
annotation.upload()
File "/home/XXX/src/webknossos-libs/webknossos/webknossos/annotation/annotation.py", line 514, in upload
response_annotation_info = client.annotation_upload(
File "/home/XXX/src/webknossos-libs/webknossos/webknossos/client/api_client/wk_api_client.py", line 146, in annotation_upload
return self.post_multipart_with_json_response(
File "/home/XXX/src/webknossos-libs/webknossos/webknossos/client/api_client/_abstract_api_client.py", line 103, in post_multipart_with_json_response
response = self._post(route, multipart_data=multipart_data, files=files)
File "/home/XXX/src/webknossos-libs/webknossos/webknossos/client/api_client/_abstract_api_client.py", line 139, in _post
return self._request(
File "/home/XXX/src/webknossos-libs/webknossos/webknossos/client/api_client/_abstract_api_client.py", line 181, in _request
self._assert_good_response(response)
File "/home/XXX/src/webknossos-libs/webknossos/webknossos/client/api_client/_abstract_api_client.py", line 217, in _assert_good_response
raise UnexpectedStatusError(response) from e
webknossos.client.api_client.errors.UnexpectedStatusError: An error occurred while performing a POST request for URL https://webknossos.org/api/v5/annotations/upload.
If this is unexpected, please double-check your WEBKNOSSOS URL and credentials.
If the error persists, it might be caused by a version mismatch of the python client and the WEBKNOSSOS server API version.
See https://github.com/scalableminds/webknossos-libs/releases for current releases.
Got response status 400 with body: {"messages":[{"error":"Unsuccessful WS request to https://webknossos.org/tracings/volume/62dcde7d-4483-4d81-bbb8-2af293c7f027/initialData (ID: 425).Status: 400. Response: {\"messages\":[{\"error\":\"Resolution restrictions result in zero resolutions\"}]}"}]}
Strangely it works when I exclude the add_volume_layer line ...
My guess is, that add_volume_layer does not produce valid annotations.