From ee8b0ecac288a8a074fb435afa74a5dde4f31b36 Mon Sep 17 00:00:00 2001 From: Daniel Werner Date: Thu, 21 Nov 2024 16:32:30 +0100 Subject: [PATCH 1/4] Add regression test for dataset picklability --- .../tests/dataset/test_dataset_download_upload_remote.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webknossos/tests/dataset/test_dataset_download_upload_remote.py b/webknossos/tests/dataset/test_dataset_download_upload_remote.py index 56c7e8a2a..01199537c 100644 --- a/webknossos/tests/dataset/test_dataset_download_upload_remote.py +++ b/webknossos/tests/dataset/test_dataset_download_upload_remote.py @@ -1,3 +1,4 @@ +import pickle from pathlib import Path from tempfile import TemporaryDirectory from time import gmtime, strftime @@ -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: From 397b3504b13c706192d8c6ad69b8e1cf1c19706b Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Mon, 25 Nov 2024 11:29:51 +0000 Subject: [PATCH 2/4] try just string? --- webknossos/webknossos/dataset/defaults.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/webknossos/webknossos/dataset/defaults.py b/webknossos/webknossos/dataset/defaults.py index c4312c05b..ba836e92b 100644 --- a/webknossos/webknossos/dataset/defaults.py +++ b/webknossos/webknossos/dataset/defaults.py @@ -1,5 +1,4 @@ import os -import ssl import certifi @@ -25,4 +24,4 @@ ZGROUP_FILE_NAME = ".zgroup" ZATTRS_FILE_NAME = ".zattrs" ZARR_JSON_FILE_NAME = "zarr.json" -SSL_CONTEXT = ssl.create_default_context(cafile=certifi.where()) +SSL_CONTEXT = certifi.where() From 9fa7b32633e2d7108346d5fb6c9fdd8220ef5c39 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Mon, 25 Nov 2024 11:55:12 +0000 Subject: [PATCH 3/4] try copyreg --- webknossos/webknossos/dataset/defaults.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/webknossos/webknossos/dataset/defaults.py b/webknossos/webknossos/dataset/defaults.py index ba836e92b..b2a558a22 100644 --- a/webknossos/webknossos/dataset/defaults.py +++ b/webknossos/webknossos/dataset/defaults.py @@ -1,10 +1,21 @@ +import copyreg import os +import ssl import certifi 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 = ( @@ -24,4 +35,4 @@ ZGROUP_FILE_NAME = ".zgroup" ZATTRS_FILE_NAME = ".zattrs" ZARR_JSON_FILE_NAME = "zarr.json" -SSL_CONTEXT = certifi.where() +SSL_CONTEXT = ssl.create_default_context(cafile=certifi.where()) From ebdace9fc4753978c6161d991361d92af8da322b Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Mon, 25 Nov 2024 14:12:25 +0000 Subject: [PATCH 4/4] changelog --- webknossos/Changelog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webknossos/Changelog.md b/webknossos/Changelog.md index 8880702a7..cf6b3ded7 100644 --- a/webknossos/Changelog.md +++ b/webknossos/Changelog.md @@ -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 @@ -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