Skip to content

user-dataset: gzip uncompressed uploads on store - #141

Merged
aperson30 merged 1 commit into
mainfrom
fix/user-dataset-compress-on-store
Aug 13, 2026
Merged

user-dataset: gzip uncompressed uploads on store#141
aperson30 merged 1 commit into
mainfrom
fix/user-dataset-compress-on-store

Conversation

@aperson30

Copy link
Copy Markdown
Collaborator

What

Follow-up to the merged user-dataset gatekeeper (#139): compress uncompressed uploads on store.

_promote used shutil.copy2(ct_path, ".../ct.nii.gz") — a byte-for-byte copy. If a user uploaded a raw .nii (not .nii.gz), we'd write the uncompressed bytes under a .nii.gz name: wasted space and an unloadable file (nibabel gunzips by extension).

Fix

_store_nifti_gz(src, dst):

  • source already gzip (.nii.gz, the common case) → bytes preserved exactly (no needless re-compress, no data change),
  • raw .niigzipped on the way in.

Applied to both the CT and combined_labels; per-organ sublabels were already gzip (nibabel). So the user dataset is always stored compressed regardless of upload format.

Test

test_uncompressed_upload_stored_as_gzip: feeds a raw .nii, asserts the stored file is genuine gzip (magic 1f 8b) and loads back. 12/12 user-dataset tests pass.

_promote used shutil.copy2 into a .nii.gz name, so a raw .nii upload was stored
uncompressed under a .nii.gz name -- wasting space and unreadable (nibabel gunzips
by extension). Add _store_nifti_gz: preserve bytes when the source is already gzip
(the usual .nii.gz), otherwise gzip it. Applied to both the CT and combined_labels.
Test: a raw .nii upload is stored as genuine gzip and loads back. 12/12 pass.
@aperson30
aperson30 merged commit c8592f5 into main Aug 13, 2026
8 checks passed
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.

1 participant