Skip to content

Commit 48ebc5d

Browse files
authored
adds durations to AnnotationInfo (#914)
* adds durations to AnnotationInfo * re-generate client * changelog * fixes a bug with upsampling a dataset that has a non-aligned bounding… (#915) * fixes a bug with upsampling a dataset that has a non-aligned bounding box * changelog * assert
1 parent bd12e56 commit 48ebc5d

26 files changed

+89
-49
lines changed

webknossos/Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
1515
### Breaking Changes
1616

1717
### Added
18+
- Added `duration_in_seconds` and `modified` to `AnnotationInfo`. [#914](https://github.com/scalableminds/webknossos-libs/pull/914)
1819

1920
### Changed
2021
- Integrated the `wkcuber` CLI tool into `webknossos` package. [#903](https://github.com/scalableminds/webknossos-libs/pull/903)
@@ -37,6 +38,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
3738
- `python -m wkcuber.recubing`
3839

3940
### Fixed
41+
- Fixed a bug where upsampling of a layer would fail, if the layer had a bounding box that doesn't align with the from_mag mag. [#915](https://github.com/scalableminds/webknossos-libs/pull/915)
4042

4143

4244
## [0.12.6](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.12.6) - 2023-06-09

webknossos/__generate_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ def iterate_request_ids_with_responses() -> Iterable[Tuple[str, bytes]]:
294294
"firstName",
295295
"lastName",
296296
"created",
297+
"modified",
297298
"lastActivity",
298299
# "teams", added 2022-07, optional for backwards-compatibility
299300
"experiences",

webknossos/tests/dataset/test_upsampling.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
import numpy as np
44

5-
from webknossos import COLOR_CATEGORY, Dataset, Mag, Vec3Int
5+
from webknossos import (
6+
COLOR_CATEGORY,
7+
SEGMENTATION_CATEGORY,
8+
BoundingBox,
9+
Dataset,
10+
Mag,
11+
Vec3Int,
12+
)
613
from webknossos.dataset._upsampling_utils import upsample_cube, upsample_cube_job
714
from webknossos.dataset.sampling_modes import SamplingModes
815

@@ -125,3 +132,21 @@ def test_upsample_multi_channel(tmp_path: Path) -> None:
125132
target_buffer = l.get_mag("1").read()
126133
assert np.any(target_buffer != 0)
127134
assert np.all(target_buffer == joined_buffer)
135+
136+
137+
def test_upsampling_non_aligned(tmp_path: Path) -> None:
138+
ds = Dataset(tmp_path / "test", (50, 50, 50))
139+
l = ds.add_layer(
140+
"color", SEGMENTATION_CATEGORY, dtype_per_channel="uint8", largest_segment_id=0
141+
)
142+
l.bounding_box = BoundingBox(topleft=(0, 0, 0), size=(8409, 10267, 5271))
143+
l.add_mag(32)
144+
145+
l.upsample(
146+
from_mag=Mag(32),
147+
finest_mag=Mag(8),
148+
sampling_mode=SamplingModes.ISOTROPIC,
149+
compress=True,
150+
)
151+
# The original bbox should be unchanged
152+
assert l.bounding_box == BoundingBox(topleft=(0, 0, 0), size=(8409, 10267, 5271))

webknossos/webknossos/annotation/annotation_info.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class AnnotationInfo:
2525
description: str
2626
type: AnnotationType
2727
state: AnnotationState
28+
duration_in_seconds: Optional[int]
29+
modified: Optional[int]
2830

2931
def download_annotation(self) -> Annotation:
3032
"""Downloads and returns the annotation that is discribed by this AnnotationInfo object"""
@@ -46,6 +48,11 @@ def _from_generated_response(
4648
description=response.description,
4749
type=AnnotationType(response.typ),
4850
state=AnnotationState(response.state),
51+
duration_in_seconds=response.tracing_time // 1000
52+
if response.tracing_time is not None
53+
and not isinstance(response.tracing_time, Unset)
54+
else None,
55+
modified=response.modified,
4956
)
5057

5158
@property

webknossos/webknossos/client/_generated/api/default/annotation_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def _get_kwargs(
3737
def _parse_response(
3838
*, response: httpx.Response
3939
) -> Optional[Union[AnnotationInfoResponse200, Any]]:
40-
if response.status_code == 200:
40+
if response.status_code == HTTPStatus.OK:
4141
response_200 = AnnotationInfoResponse200.from_dict(response.json())
4242

4343
return response_200
44-
if response.status_code == 400:
44+
if response.status_code == HTTPStatus.BAD_REQUEST:
4545
response_400 = cast(Any, None)
4646
return response_400
4747
return None

webknossos/webknossos/client/_generated/api/default/annotation_infos_by_task_id.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _get_kwargs(
3232
def _parse_response(
3333
*, response: httpx.Response
3434
) -> Optional[Union[Any, List["AnnotationInfosByTaskIdResponse200Item"]]]:
35-
if response.status_code == 200:
35+
if response.status_code == HTTPStatus.OK:
3636
response_200 = []
3737
_response_200 = response.json()
3838
for response_200_item_data in _response_200:
@@ -43,7 +43,7 @@ def _parse_response(
4343
response_200.append(response_200_item)
4444

4545
return response_200
46-
if response.status_code == 400:
46+
if response.status_code == HTTPStatus.BAD_REQUEST:
4747
response_400 = cast(Any, None)
4848
return response_400
4949
return None

webknossos/webknossos/client/_generated/api/default/build_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def _get_kwargs(
2929
def _parse_response(
3030
*, response: httpx.Response
3131
) -> Optional[Union[Any, BuildInfoResponse200]]:
32-
if response.status_code == 200:
32+
if response.status_code == HTTPStatus.OK:
3333
response_200 = BuildInfoResponse200.from_dict(response.json())
3434

3535
return response_200
36-
if response.status_code == 400:
36+
if response.status_code == HTTPStatus.BAD_REQUEST:
3737
response_400 = cast(Any, None)
3838
return response_400
3939
return None

webknossos/webknossos/client/_generated/api/default/current_user_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _get_kwargs(
2929
def _parse_response(
3030
*, response: httpx.Response
3131
) -> Optional[CurrentUserInfoResponse200]:
32-
if response.status_code == 200:
32+
if response.status_code == HTTPStatus.OK:
3333
response_200 = CurrentUserInfoResponse200.from_dict(response.json())
3434

3535
return response_200

webknossos/webknossos/client/_generated/api/default/dataset_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def _get_kwargs(
4040
def _parse_response(
4141
*, response: httpx.Response
4242
) -> Optional[Union[Any, DatasetInfoResponse200]]:
43-
if response.status_code == 200:
43+
if response.status_code == HTTPStatus.OK:
4444
response_200 = DatasetInfoResponse200.from_dict(response.json())
4545

4646
return response_200
47-
if response.status_code == 400:
47+
if response.status_code == HTTPStatus.BAD_REQUEST:
4848
response_400 = cast(Any, None)
4949
return response_400
5050
return None

webknossos/webknossos/client/_generated/api/default/dataset_list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _get_kwargs(
6363
def _parse_response(
6464
*, response: httpx.Response
6565
) -> Optional[Union[Any, List["DatasetListResponse200Item"]]]:
66-
if response.status_code == 200:
66+
if response.status_code == HTTPStatus.OK:
6767
response_200 = []
6868
_response_200 = response.json()
6969
for response_200_item_data in _response_200:
@@ -74,7 +74,7 @@ def _parse_response(
7474
response_200.append(response_200_item)
7575

7676
return response_200
77-
if response.status_code == 400:
77+
if response.status_code == HTTPStatus.BAD_REQUEST:
7878
response_400 = cast(Any, None)
7979
return response_400
8080
return None

0 commit comments

Comments
 (0)