Skip to content

Commit 1c8a6a6

Browse files
valentin-pinkauvalentin-pinkaufm3normanrz
authored
refactor dataset, remote_dataset, and layer (#1371)
* making the path optional in dataset, and layers * typecheck. format. lint * add default for version. fix structuring * fix more type errors * add reserve manual upload. * implement upload on dataset object. * update to api_version 11 * use enrich_path * remove status from valid DatasetProperties * add default argument * always ask for included paths in dataset_info * make dataset.path and layer.path optional * moved dataset_properties * format * fix ruff for __init__ * fix missing import * fix copy of attachments * fix imports * fix import * move layer_categories.py * reorder code in structuring * reorder is None check * improve comment * move layer category * move imports * no need for conversion anymore * fix disambiguate * fix schema * wk now has lower case user emails * wk now has lower case user emails * missing 7 cassettes. * elaborate comment about legacy field DatasetProperties.id * add_attachment_as_copy now supports RemoteDatasets * don't use RemoteDataset type * fix user names * missing one cassette * separate type names and container names * do not pass includePaths * all cassettes! * allow add_attachment_as_copy to publish attachments to remote datasets * update cassettes * rename manual_upload to upload_to_path*s * Adapt reserve routes to pass dataset_id in path; add new reserve_dataset_upload_to_paths_for_preliminary * remove default for version * add publish_to_preliminary_dataset * add announce_dataset_upload.py * update docs * allow moving of the data when publishing * use dataset updatePartial, update snapshots * Allow saving RemoteDataset DatasetProperties changes back to server * in case of symlink, directly link, no move * rename * add env variable to __init__.py * move layer to link * consolidate upload * Revert "move layer to link" This reverts commit 3fed75a. * format * use corrent variable * refactor dataset, remote_dataset, and layer * clean up * refactor packages. typecheck runs through * fixed imports * move _array * add layer and remote_layer to mag view * rename attachments_type * move download to abstract dataset * move open_remote to abstract_dataset.py * remove init * make magview generic over layer * adapt comment * add_layer_like now accepts RemoteLayers. remove test for adding remote layers with a zarr-streaming path * update snapshots * increase chunk shape * add changelog * format and lint * remove unnecessary asserts * fix magview rechunk * remove unused method * clean up, removing code from older iterations * removed None checks * update changelog * format * restore from_remote_layer method * use Mapping * move download_mesh to RemoteSegmentationLayer * move Dataset.get_remote_datasets -> RemoteDataset.list and Dataset.open_remote -> RemoteDataset.open * use RemoteDataset.open instead of Dataset.open_remote * fix usage of deprecated methods * format * add backwards compatible deprecated is_foreign property on MagView * make ensure_layer compatible with remote layers * update changelog * update cassettes * update api version to 12 * rename * add upload_to_webknossos example to docs * remove old link * fix changelog * allow new name to be passed to LayerToLink.from_remote_layer * add tests for upload to common storage * lint & format * update cassettes * move _parse_remote, _disambiguate_remote, get_remote_datasets from abstract dataset to dataset or remote dataset * Update webknossos/Changelog.md Co-authored-by: Norman Rzepka <[email protected]> * add deprecation to changelog * fix changelog * format and fix ensure_layer * add missing cassettes * skip upload tests --------- Co-authored-by: valentin-pinkau <[email protected]> Co-authored-by: Florian M <[email protected]> Co-authored-by: Norman Rzepka <[email protected]>
1 parent 0d176ae commit 1c8a6a6

File tree

137 files changed

+12504
-8377
lines changed

Some content is hidden

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

137 files changed

+12504
-8377
lines changed

docs/mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ nav:
245245
- webknossos-py/examples/download_tiff_stack.md
246246
- webknossos-py/examples/remote_datasets.md
247247
- webknossos-py/examples/convert_4d_tiff.md
248-
- webknossos-py/examples/announce_dataset_upload.md
249248
- webknossos-py/examples/accessing_metadata.md
250249
- webknossos-py/examples/explore_and_add_remote.md
250+
- webknossos-py/examples/upload_to_webknossos.md
251251
- Annotation Examples:
252252
- webknossos-py/examples/apply_merger_mode.md
253253
- webknossos-py/examples/learned_segmenter.md

docs/src/webknossos-py/examples/announce_dataset_upload.md

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Upload dataset to WEBKNOSSOS
2+
3+
This example demonstrates the process of uploading a Dataset.
4+
5+
```python
6+
--8<--
7+
webknossos/examples/upload_to_webknossos.py
8+
--8<--
9+
```

webknossos/Changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,22 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
1414

1515
### Breaking Changes
1616
- Removed Docker image `scalableminds/webknossos-cli` build. It will not be released further. [#1376](https://github.com/scalableminds/webknossos-libs/pull/1376)
17+
- `Dataset.add_layer_as_ref(remote_layer.path)` does not work anymore. Please use `Dataset.add_layer_as_ref(remote_layer)` instead. [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371])
18+
- Due to the refactoring, the imports of various classes have changed. Please update your code accordingly. [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371])
19+
- Deprecated a number of methods [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371]):
20+
- `Dataset.open_remote()`, use `RemoteDataset.open` instead.
21+
- `RemoteDatset.download_mesh()`, use `remote_segmentation_layer.download_mesh()` instead.
22+
- `Dataset.get_remote_datasets()`, use `RemoteDataset.list()` instead.
23+
- `Dataset.download()`, use `RemoteDataset.download()` instead.
24+
- `mag_view.is_foreign`, use `layer.is_mag_view_foreign(mag_view)` instead.
25+
- `Dataset.trigger_reload_in_datastore()`, use `RemoteDataset.trigger_reload_in_datastore()` instead.
1726

1827
### Added
28+
- Dataset.add_layer_as_ref() now accepts RemoteLayer objects as well as Layer objects. [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371])
1929

2030
### Changed
31+
- Refactored the architecture, by introducing RemoteLayers, RemoteSegmentationLayers and their abstract base classes. [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371])
32+
- Updated the api version of the webknossos-api to 12. [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371])
2133

2234
### Fixed
2335

webknossos/examples/accessing_metadata.py

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

33

44
def main() -> None:
5-
l4_sample_dataset = wk.Dataset.open_remote("l4_sample")
5+
l4_sample_dataset = wk.RemoteDataset.open("l4_sample")
66
# Access the metadata of the dataset
77
print(l4_sample_dataset.metadata)
88

webknossos/examples/announce_dataset_upload.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

webknossos/examples/apply_merger_mode.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
from pathlib import Path
2-
31
import fastremap
42

53
import webknossos as wk
64

7-
TESTDATA_DIR = Path(__file__).parent.parent / "testdata"
8-
95

106
def main() -> None:
117
####################################
@@ -18,15 +14,14 @@ def main() -> None:
1814
).skeleton
1915

2016
###############################################
21-
# Download and open the corresponding dataset #
17+
# Open the corresponding dataset #
2218
###############################################
2319

24-
dataset = wk.Dataset.download(
20+
input_dataset = wk.RemoteDataset.open(
2521
"l4_sample",
26-
bbox=wk.BoundingBox((3457, 3323, 1204), (40, 10, 10)),
27-
path="testoutput/l4_sample",
22+
organization_id="scalable_minds",
2823
)
29-
in_layer = dataset.get_segmentation_layer("segmentation")
24+
in_layer = input_dataset.get_segmentation_layer("segmentation")
3025
in_mag1 = in_layer.get_mag("1")
3126

3227
##############################
@@ -52,8 +47,10 @@ def main() -> None:
5247
############################
5348
# Creating an output layer #
5449
############################
55-
56-
out_layer = dataset.add_layer(
50+
output_dataset = wk.Dataset(
51+
"testoutput/l4_sample", voxel_size=input_dataset.voxel_size
52+
)
53+
out_layer = output_dataset.add_layer(
5754
"segmentation_remapped",
5855
wk.SEGMENTATION_CATEGORY,
5956
dtype_per_channel=in_layer.dtype_per_channel,
@@ -84,16 +81,9 @@ def apply_mapping_for_chunk(args: tuple[wk.View, wk.View, int]) -> None:
8481
########################################
8582

8683
out_layer.downsample()
87-
dataset.delete_layer("segmentation")
88-
dataset.upload(
84+
output_dataset.upload(
8985
"l4_sample_remapped",
90-
layers_to_link=[
91-
wk.LayerToLink(
92-
dataset_name="l4_sample",
93-
layer_name="color",
94-
organization_id="scalable_minds",
95-
)
96-
],
86+
layers_to_link=[input_dataset.get_layer("color")],
9787
)
9888

9989

webknossos/examples/create_dataset_from_images.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from pathlib import Path
22

3-
from webknossos import Dataset
4-
from webknossos.dataset import COLOR_CATEGORY
3+
from webknossos import COLOR_CATEGORY, Dataset
54

65
INPUT_DIR = Path(__file__).parent.parent / "testdata" / "tiff"
76
OUTPUT_DIR = Path("testoutput/my_tiff_dataset")

webknossos/examples/dataset_usage.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ def main() -> None:
99
#####################
1010
# Opening a dataset #
1111
#####################
12-
1312
dataset = wk.Dataset.open("testdata/simple_wkw_dataset")
1413
# Assuming that the dataset has a layer "color"
1514
# and the layer has the magnification 1
@@ -67,7 +66,7 @@ def main() -> None:
6766

6867
copy_of_dataset = dataset.copy_dataset(
6968
"testoutput/copy_of_dataset",
70-
chunk_shape=(8, 8, 8),
69+
chunk_shape=(32, 32, 32),
7170
shard_shape=(64, 64, 64),
7271
compress=True,
7372
)

webknossos/examples/download_image_data.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ def main() -> None:
1515
bbox = wk.BoundingBox([50, 50, 50], [50, 50, 50])
1616

1717
# Download the dataset
18-
ds = wk.Dataset.download(
18+
ds = wk.RemoteDataset.open(
1919
dataset_name_or_url=name,
2020
organization_id=organization_id,
21+
webknossos_url="https://webknossos.org",
22+
).download(
2123
bbox=bbox,
2224
layers=layers,
2325
mags=mags,
24-
webknossos_url="https://webknossos.org",
2526
)
2627

2728
# Check that the layer was downloaded

0 commit comments

Comments
 (0)