Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dataset pickling #1218

Merged
merged 5 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion webknossos/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
### Changed

### Fixed
- Fixed pickling issue that has been introduced in 0.15.9. [#1218](https://github.com/scalableminds/webknossos-libs/pull/1218)


## [0.15.9](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.15.9) - 2024-11-25
Expand All @@ -32,7 +33,7 @@ Removed the CZI installation extra from `pip install webknossos[all]` by default
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.15.7...v0.15.8)

### Changed
- Fixes SSL certificate verification for remote datasets by adding CA certificates using `certifi`. [#1211](https://github.com/scalableminds/webknossos-libs/pull/1211)
- Fixed SSL certificate verification for remote datasets by adding CA certificates using `certifi`. [#1211](https://github.com/scalableminds/webknossos-libs/pull/1211)


## [0.15.7](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.15.7) - 2024-10-25
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pickle
from pathlib import Path
from tempfile import TemporaryDirectory
from time import gmtime, strftime
Expand Down Expand Up @@ -73,6 +74,10 @@ def test_url_open_remote(
data,
sample_dataset.get_color_layers()[0].get_finest_mag().read(),
)
assert set(pickle.loads(pickle.dumps(ds)).layers.keys()) == {
"color",
"segmentation",
}, "Dataset instances should be picklable."


def test_remote_dataset(sample_dataset: wk.Dataset) -> None:
Expand Down
10 changes: 10 additions & 0 deletions webknossos/webknossos/dataset/defaults.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copyreg
import os
import ssl

Expand All @@ -6,6 +7,15 @@
from ..geometry import Vec3Int
from .data_format import DataFormat


def _save_sslcontext(
obj: ssl.SSLContext,
) -> tuple[type[ssl.SSLContext], tuple[ssl._SSLMethod]]:
return obj.__class__, (obj.protocol,)


copyreg.pickle(ssl.SSLContext, _save_sslcontext)

DEFAULT_WKW_FILE_LEN = 32
DEFAULT_CHUNK_SHAPE = Vec3Int.full(32)
DEFAULT_DATA_FORMAT = (
Expand Down
Loading