Skip to content

Use the NPZ serialization of Sigima instead of a copy - #6

Draft
PierreRaybaut wants to merge 1 commit into
mainfrom
refactor/sigima-npz-serialization
Draft

PierreRaybaut wants to merge 1 commit into
mainfrom
refactor/sigima-npz-serialization

Conversation

@PierreRaybaut

Copy link
Copy Markdown
Contributor

Closes #5 — depends on DataLab-Platform/Sigima#91.

Important

Draft: do not merge before Sigima 1.4.0 and DataLab 1.4.0 are published on PyPI. The CI of pull requests to main installs DataLab and Sigima from PyPI, where sigima.io.serialize_object_to_npz does not exist yet, so the CI of this PR fails until then.

Summary

  • datalab_kernel/serialization_npz.py becomes a thin re-export of sigima.io.serialize_object_to_npz / deserialize_object_from_npz (−300 lines): one implementation of the Web API NPZ format, shared with DataLab.
  • sigima>=1.4.0 in pyproject.toml, requirements.txt and the README.
  • Fixes, as a consequence, the transfer of objects whose metadata hold NumPy arrays in lists (e.g. images with regions of interest raised TypeError: Object of type ndarray is not JSON serializable): new test_image_rich_metadata_round_trip (fails on main).
  • Release note.

Tests

With Sigima feature/shared-npz-serialization: test_webapi_backend.py and unit/test_persistence.py pass (all existing NPZ tests, including non-uniform coordinates and archives of earlier versions, now exercise the Sigima implementation).

serialization_npz.py was a copy of the NPZ serialization of the DataLab Web
API, which diverged from it: non-uniform image coordinates had to be added
twice, and object metadata holding NumPy arrays nested in lists (e.g. the
regions of interest of an image) raised a TypeError when an object was sent
to DataLab.

Sigima 1.4 provides the implementation shared with DataLab
(sigima.io.serialize_object_to_npz and deserialize_object_from_npz):
datalab_kernel.serialization_npz now re-exports it, and sigima>=1.4.0 is
required. A test checks that an image with regions of interest round-trips.

Closes #5

Assisted-by: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use the NPZ serialization of Sigima instead of a copy

1 participant