Skip to content

Move zip/folder I/O behind a storage-backend seam (no behaviour change) - #152

Open
francopestilli wants to merge 1 commit into
tee-ar-ex:mainfrom
francopestilli:refactor/storage-backends
Open

francopestilli wants to merge 1 commit into
tee-ar-ex:mainfrom
francopestilli:refactor/storage-backends

Conversation

@francopestilli

Copy link
Copy Markdown
Member

Introduce trx/backends/ with a small TrxBackend protocol and a registry,
and move the code that walks a .trx zip or folder, memory-maps each
array and assembles a TrxFile (load_from_zip, load_from_directory,
_create_trx_from_pointer, zip_from_folder, and the bodies of load and
save) into trx.backends.memmap.MemmapBackend. The logic is unchanged;
it has only moved.

trx.trx_file_memmap keeps every public name: load() and save() now
pick the backend from the path through the registry, and
load_from_zip, load_from_directory, zip_from_folder and
TrxFile._create_trx_from_pointer delegate to the memmap module, so
DIPY, scilpy and existing scripts import exactly what they did before.

This is the first step toward letting a TrxFile open and save other
containers (a Zarr Vectors store is the motivating case) without
touching the TRX specification or the TrxFile API.

Adds trx/tests/test_backends.py covering the registry, extension
dispatch, a save/load round trip, the legacy names, and registering a
custom backend. Existing suite: 205 passed before and after.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01AfVKrdLrUh3AEnK2A5Ez2L

Introduce trx/backends/ with a small TrxBackend protocol and a registry,
and move the code that walks a .trx zip or folder, memory-maps each
array and assembles a TrxFile (load_from_zip, load_from_directory,
_create_trx_from_pointer, zip_from_folder, and the bodies of load and
save) into trx.backends.memmap.MemmapBackend. The logic is unchanged;
it has only moved.

trx.trx_file_memmap keeps every public name: load() and save() now
pick the backend from the path through the registry, and
load_from_zip, load_from_directory, zip_from_folder and
TrxFile._create_trx_from_pointer delegate to the memmap module, so
DIPY, scilpy and existing scripts import exactly what they did before.

This is the first step toward letting a TrxFile open and save other
containers (a Zarr Vectors store is the motivating case) without
touching the TRX specification or the TrxFile API.

Adds trx/tests/test_backends.py covering the registry, extension
dispatch, a save/load round trip, the legacy names, and registering a
custom backend. Existing suite: 205 passed before and after.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AfVKrdLrUh3AEnK2A5Ez2L
@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.21407% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.90%. Comparing base (ae3f6bd) to head (3927589).

Files with missing lines Patch % Lines
trx/backends/memmap.py 86.27% 28 Missing ⚠️
trx/tests/test_backends.py 97.46% 2 Missing ⚠️
trx/trx_file_memmap.py 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #152      +/-   ##
==========================================
+ Coverage   86.40%   86.90%   +0.50%     
==========================================
  Files          15       19       +4     
  Lines        3031     3193     +162     
==========================================
+ Hits         2619     2775     +156     
- Misses        412      418       +6     
Flag Coverage Δ
unittests 86.90% <90.21%> (+0.50%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@francopestilli

francopestilli commented Nov 10, 2026 •

Copy link
Copy Markdown
Member Author

First step of #153: the backend seam alone, no behaviour change.

This branch has not been deployed

No deployments
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