Skip to content

Commit 2a5d1c0

Browse files
normanrzfm3
andauthored
Enable zarrita by default (#950)
* enable zarrita by default * deactivate zarr-python * upgrade zarrita * changelog * organize imports and add ome-metadata for zarr3 aswell * more relative imports * Zarr volume annotations (#952) * Adds support for Zarr3-based volume annotations * adds test * defaults for Volume * changelog * adds test zip * merge * merge * test_annotation with id * Update webknossos/webknossos/dataset/dataset.py Co-authored-by: Florian M <[email protected]> * Update webknossos/webknossos/annotation/annotation.py Co-authored-by: Florian M <[email protected]> * pr feedback * ci
1 parent 2e989d6 commit 2a5d1c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+540
-394
lines changed

docs/generate.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ fi
1717

1818
export PDOC_CLASS_MODULES="$(poetry run python get_keyword_mapping.py)"
1919
if [ $# -eq 1 ] && [ "$1" = "--api" ]; then
20-
poetry run pdoc ../webknossos/webknossos -t pdoc_templates/pure_pdoc -h 0.0.0.0 -p 8196
20+
poetry run pdoc ../webknossos/webknossos !webknossos.dataset._utils -t pdoc_templates/pure_pdoc -h 0.0.0.0 -p 8196
2121
else
2222
rm -rf src/api
23-
poetry run pdoc ../webknossos/webknossos -t pdoc_templates/with_mkdocs -o src/api
23+
poetry run pdoc ../webknossos/webknossos !webknossos.dataset._utils -t pdoc_templates/with_mkdocs -o src/api
2424
# rename .html files to .md
2525
find src/api -iname "*.html" -exec sh -c 'mv "$0" "${0%.html}.md"' {} \;
2626
# assert that API docs are written

webknossos/Changelog.md

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,99 +10,115 @@ and this project adheres to [Semantic Versioning](http://semver.org/) `MAJOR.MIN
1010
For upgrade instructions, please check the respective _Breaking Changes_ sections.
1111

1212
## Unreleased
13+
1314
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.14.0...HEAD)
1415

1516
### Breaking Changes
1617

1718
### Added
1819

20+
- Adds support for Zarr3-based volume annotations as introduced in [webknossos#7288](https://github.com/scalableminds/webknossos/pull/7288). [#952](https://github.com/scalableminds/webknossos-libs/pull/952)
21+
1922
### Changed
2023

21-
### Fixed
24+
- The `WK_USE_ZARRITA` env variable is no longer required. [`zarrita`](https://github.com/scalableminds/zarrita) is always installed and now the default for Zarr and Zarr3 datasets. [#950](https://github.com/scalableminds/webknossos-libs/issues/950)
25+
- Updates various dependencies. [#943](https://github.com/scalableminds/webknossos-libs/pull/943)
2226

27+
### Fixed
2328

2429
## [0.14.0](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.14.0) - 2023-10-11
30+
2531
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.13.7...v0.14.0)
2632

2733
### Breaking Changes
34+
2835
- `wait_and_ensure_success` from `webknossos.utils` now requires an `executor` argument. [#943](https://github.com/scalableminds/webknossos-libs/pull/943)
2936

3037
### Changed
31-
- Updates various dependencies. [#943](https://github.com/scalableminds/webknossos-libs/pull/943)
3238

39+
- Updates various dependencies. [#943](https://github.com/scalableminds/webknossos-libs/pull/943)
3340

3441
## [0.13.7](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.13.7) - 2023-10-07
42+
3543
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.13.6...v0.13.7)
3644

3745
### Fixed
38-
- Fixed a bug in writing compressed data. [#942](https://github.com/scalableminds/webknossos-libs/pull/942)
39-
4046

47+
- Fixed a bug in writing compressed data. [#942](https://github.com/scalableminds/webknossos-libs/pull/942)
4148

4249
## [0.13.6](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.13.6) - 2023-08-17
43-
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.13.5...v0.13.6)
4450

51+
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.13.5...v0.13.6)
4552

4653
## [0.13.5](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.13.5) - 2023-08-15
54+
4755
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.13.4...v0.13.5)
4856

4957
### Added
58+
5059
- Added `task_type` property to `Task` class. [#938](https://github.com/scalableminds/webknossos-libs/pull/938)
5160

5261
### Fixed
53-
- Fixed a bug where parallel access to the properties json leads to an JsonDecodeError in the webknossos CLI [#919](https://github.com/scalableminds/webknossos-libs/issues/919)
54-
5562

63+
- Fixed a bug where parallel access to the properties json leads to an JsonDecodeError in the webknossos CLI [#919](https://github.com/scalableminds/webknossos-libs/issues/919)
5664

5765
## [0.13.4](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.13.4) - 2023-08-14
66+
5867
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.13.3...v0.13.4)
5968

6069
### Breaking Changes
70+
6171
- Task/Project management: `open` tasks have been renamed to `pending`. Use `Task.status.pending_instance_count` instead of `Task.status.open_instance_count`. [#930](https://github.com/scalableminds/webknossos-libs/pull/930)
6272

6373
### Fixed
64-
- Fixed an infinite loop in the mag calculation during anisotropic downsampling in situations where the target mag cannot possibly be reached while adhering to the anisotropic downsampling scheme. [#934](https://github.com/scalableminds/webknossos-libs/pull/934)
65-
6674

75+
- Fixed an infinite loop in the mag calculation during anisotropic downsampling in situations where the target mag cannot possibly be reached while adhering to the anisotropic downsampling scheme. [#934](https://github.com/scalableminds/webknossos-libs/pull/934)
6776

6877
## [0.13.3](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.13.3) - 2023-08-08
78+
6979
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.13.2...v0.13.3)
7080

7181
### Added
82+
7283
- `View` has a `map_chunk` method now to run a function on each chunk and collect the results in a list.
7384

7485
### Changed
86+
7587
- As WEBKNOSSOS does not require the largest segment id. It is also not mandatory in the WEBKNOSSOS libs anymore. [#917](https://github.com/scalableminds/webknossos-libs/issues/917) The method `SegmentationLayer.refresh_largest_segment_id` was added to lookup the highest value in segmentation data and set `largest_segment_id` accordingly.
7688
- The `convert` command of the cli now has a `--category` flag, to select the LayerCategoryType.
7789

78-
7990
## [0.13.2](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.13.2) - 2023-07-26
91+
8092
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.13.1...v0.13.2)
8193

8294
### Changed
83-
- The `convert` command of the cli now has a `--category` flag, to select the LayerCategoryType.
8495

96+
- The `convert` command of the cli now has a `--category` flag, to select the LayerCategoryType.
8597

8698
## [0.13.1](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.13.1) - 2023-07-17
99+
87100
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.13.0...v0.13.1)
88101

89102
### Changed
103+
90104
- The conversion folder structures to layer names does not allow slashes in the layer name anymore. [#918](https://github.com/scalableminds/webknossos-libs/issues/918)
91105

92106
### Fixed
93-
- Fixed a bug where compression in add_layer_from_images uses too much memory [#900](https://github.com/scalableminds/webknossos-libs/issues/900)
94-
95107

108+
- Fixed a bug where compression in add_layer_from_images uses too much memory [#900](https://github.com/scalableminds/webknossos-libs/issues/900)
96109

97110
## [0.13.0](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.13.0) - 2023-06-21
111+
98112
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.12.6...v0.13.0)
99113

100114
### Added
115+
101116
- Added `duration_in_seconds` and `modified` to `AnnotationInfo`. [#914](https://github.com/scalableminds/webknossos-libs/pull/914)
102117
- Added [`zarrita`](https://github.com/scalableminds/zarrita) storage backend for arrays. zarrita supports Zarr v2 and v3 including sharding. To activate zarrita, the environment variable `WK_USE_ZARRITA` must be set. [#912](https://github.com/scalableminds/webknossos-libs/pull/912)
103118
- Added a `Zarr3` data format which supports sharding. [#912](https://github.com/scalableminds/webknossos-libs/pull/912)
104119

105120
### Changed
121+
106122
- Integrated the `wkcuber` CLI tool into `webknossos` package. [#903](https://github.com/scalableminds/webknossos-libs/pull/903)
107123
- To get an overview of all webknossos subcommands type `webknossos --help`. If the usage of a single subcommand is of interest type `webknossos <subcommand> --help`
108124
- These commands were changed:
@@ -123,63 +139,68 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
123139
- `python -m wkcuber.recubing`
124140

125141
### Fixed
126-
- 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)
127-
128142

143+
- 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)
129144

130145
## [0.12.6](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.12.6) - 2023-06-09
146+
131147
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.12.5...v0.12.6)
132148

133149
### Changed
134-
- Upgrades `wkw`. [#911](https://github.com/scalableminds/webknossos-libs/pull/911)
135150

151+
- Upgrades `wkw`. [#911](https://github.com/scalableminds/webknossos-libs/pull/911)
136152

137153
## [0.12.5](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.12.5) - 2023-06-01
154+
138155
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.12.4...v0.12.5)
139156

140157
### Added
141-
- Added support for Python 3.11. [#843](https://github.com/scalableminds/webknossos-libs/pull/843)
142158

159+
- Added support for Python 3.11. [#843](https://github.com/scalableminds/webknossos-libs/pull/843)
143160

144161
## [0.12.4](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.12.4) - 2023-05-25
162+
145163
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.12.3...v0.12.4)
146164

147165
### Added
166+
148167
- `Group.add_tree` now also accepts a tree object as a first parameter (instead of only a string). [#891](https://github.com/scalableminds/webknossos-libs/pull/891)
149168
- `Group.remove_tree_by_id` was added. [#891](https://github.com/scalableminds/webknossos-libs/pull/891)
150169

151170
### Changed
171+
152172
- Upgrades `black`, `mypy`, `pylint`, `pytest`. [#873](https://github.com/scalableminds/webknossos-libs/pull/873)
153173

154174
### Fixed
175+
155176
- Fixed poetry build backend for new versions of Poetry. [#899](https://github.com/scalableminds/webknossos-libs/pull/899)
156177
- Added axis_order fields for Zarr data format. [#902](https://github.com/scalableminds/webknossos-libs/issues/902)
157178

158-
159-
160179
## [0.12.3](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.12.3) - 2023-02-22
180+
161181
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.12.2...v0.12.3)
162182

163183
### Added
184+
164185
- Added support to import ImageJ Hyperstack tiff files via `Dataset.from_images` and `dataset.add_layer_from_images`. [#877](https://github.com/scalableminds/webknossos-libs/pull/877)
165186

166187
### Changed
188+
167189
- `Dataset.from_images` and `dataset.add_layer_from_images` now automatically convert big endian dtypes to their little endian counterparts by default. [#877](https://github.com/scalableminds/webknossos-libs/pull/877)
168190

169191
### Fixed
170-
- Fixed reading czi files with non-zero axis offsets. [#876](https://github.com/scalableminds/webknossos-libs/pull/876)
171-
172192

193+
- Fixed reading czi files with non-zero axis offsets. [#876](https://github.com/scalableminds/webknossos-libs/pull/876)
173194

174195
## [0.12.2](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.12.2) - 2023-02-20
196+
175197
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.12.1...v0.12.2)
176198
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.12.1...HEAD)
177199

178200
### Added
179201

180202
- Added `RemoteFolder` for assigning remote datasets to a WEBKNOSSOS folder. [#868](https://github.com/scalableminds/webknossos-libs/pull/868)
181203

182-
183204
## [0.12.1](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.12.1) - 2023-02-16
184205

185206
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.12.0...v0.12.1)

webknossos/poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webknossos/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ typing-extensions = "^4.0"
5454
universal-pathlib = "0.1.3"
5555
wkw = "1.1.22"
5656
zarr = "^2.16.0"
57+
zarrita = "0.2.1"
5758
zipp = "^3.5.0"
5859

5960
# A list of all of the optional dependencies, some of which are included in the
@@ -63,15 +64,14 @@ JPype1 = { version = "^1.3.0", optional = true }
6364
pims = { version = "^0.6.0", optional = true }
6465
tifffile = { version = ">=2021.11.2", optional = true }
6566
pylibCZIrw = { version = "3.5.1", source = "scm", optional = true }
66-
zarrita = "0.2.1"
6767

6868
[tool.poetry.extras]
6969
pims = ["pims"]
7070
tifffile = ["pims", "tifffile"]
7171
imagecodecs = ["pims", "imagecodecs"]
7272
bioformats = ["pims","JPype1"]
7373
czi = ["pims","pylibCZIrw"]
74-
all = ["pims","tifffile","imagecodecs","JPype1","pylibCZIrw","zarrita"]
74+
all = ["pims","tifffile","imagecodecs","JPype1","pylibCZIrw"]
7575

7676
[tool.poetry.dev-dependencies]
7777
# autoflake

webknossos/test.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export_vars
1111
# (which is standard python behavior). This is necessary so that the imports
1212
# refer to the checked out (and potentially modified) code.
1313
PYTEST="poetry run python -m pytest --suppress-no-test-exit-code"
14-
export WK_USE_ZARRITA=True
1514

1615

1716
if [ $# -gt 0 ] && [ "$1" = "--refresh-snapshots" ]; then
Binary file not shown.

webknossos/tests/test_annotation.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import tempfile
22
from pathlib import Path
33

4+
import numpy as np
45
import pytest
56

67
import webknossos as wk
8+
from webknossos.dataset import DataFormat
79
from webknossos.geometry import BoundingBox, Vec3Int
810

911
from .constants import TESTDATA_DIR, TESTOUTPUT_DIR
1012

1113
pytestmark = [pytest.mark.with_vcr]
1214

1315

14-
def test_annotation_from_zip_file() -> None:
16+
def test_annotation_from_wkw_zip_file() -> None:
1517
annotation = wk.Annotation.load(
1618
TESTDATA_DIR
1719
/ "annotations"
@@ -57,6 +59,24 @@ def test_annotation_from_zip_file() -> None:
5759
assert voxel_id == 2504698
5860

5961

62+
def test_annotation_from_zarr3_zip_file() -> None:
63+
annotation = wk.Annotation.load(
64+
TESTDATA_DIR / "annotations" / "l4_sample__explorational__suser__94b271.zip"
65+
)
66+
67+
with annotation.temporary_volume_layer_copy() as volume_layer:
68+
assert volume_layer.data_format == DataFormat.Zarr3
69+
assert volume_layer.bounding_box == BoundingBox(
70+
(3072, 3072, 512), (1024, 1024, 1024)
71+
)
72+
input_annotation_mag = volume_layer.get_mag("2-2-1")
73+
voxel_id = input_annotation_mag.read(
74+
absolute_offset=Vec3Int(3630, 3502, 1024), size=Vec3Int(2, 2, 1)
75+
)
76+
77+
assert np.array_equiv(voxel_id, 1)
78+
79+
6080
def test_annotation_from_nml_file() -> None:
6181
snapshot_path = TESTDATA_DIR / "nmls" / "generated_annotation_snapshot.nml"
6282

webknossos/webknossos/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
# The table above contains zero-width spaces in the code examples after each dot to enforce correct line-breaks.
2626

27-
from webknossos.administration import *
28-
from webknossos.annotation import *
29-
from webknossos.client import *
30-
from webknossos.dataset import *
31-
from webknossos.geometry import *
32-
from webknossos.skeleton import *
27+
from .administration import *
28+
from .annotation import *
29+
from .client import *
30+
from .dataset import *
31+
from .geometry import *
32+
from .skeleton import *

webknossos/webknossos/_nml/parameters.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
from loxun import XmlWriter
55

6-
from webknossos.geometry import BoundingBox
7-
from webknossos.geometry.bounding_box import _DEFAULT_BBOX_NAME
8-
6+
from ..geometry import BoundingBox
7+
from ..geometry.bounding_box import _DEFAULT_BBOX_NAME
98
from .utils import Vector3, enforce_not_null, filter_none_values
109

1110
DEFAULT_BOUNDING_BOX_COLOR = [0.2, 0.5, 0.1, 1]

webknossos/webknossos/_nml/segment.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
from loxun import XmlWriter
55

6-
from webknossos.geometry import Vec3Int
7-
6+
from ..geometry import Vec3Int
87
from .utils import Vector4, enforce_not_null, filter_none_values
98

109

0 commit comments

Comments
 (0)