user-dataset: gzip uncompressed uploads on store - #141
Merged
Conversation
_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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Follow-up to the merged user-dataset gatekeeper (#139): compress uncompressed uploads on store.
_promoteusedshutil.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.gzname: wasted space and an unloadable file (nibabel gunzips by extension).Fix
_store_nifti_gz(src, dst):.nii.gz, the common case) → bytes preserved exactly (no needless re-compress, no data change),.nii→ gzipped 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 (magic1f 8b) and loads back. 12/12 user-dataset tests pass.