Repository navigation
Refactor(io): simplify format dispatch and reader/writer APIs - #357
Merged
Merged
Conversation
…ader-writer # Conflicts: # src/brainhops/io/base/_save.py # src/brainhops/io/base/parsers.py # src/brainhops/io/transformations/freesurfer/lta/_parser.py
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.
The I/O hierarchy mixed format selection with parsing and duplicated capabilities through file-based object wrappers. This change separates the contracts and removes redundant bases.
Formatis the dispatcher and root registry for generic loading/saving.ImageFormatandTransformationFormatscope it to their domains. Dispatchersniff*returns a selected class orNone; it does not inherit the reader contract.FileReaderprovides confidence-scoringsniff*andload/from_*;FileWriterindependently providessave/to_*. Readers and dispatchers share private input adapters. Text and binary variants supply their adapters.*Readerfor reading,*ReaderWriterfor both. Examples:MincReader,TfmTransformReader,NiftiReaderWriter,LtaReaderWriter. Their imports, exports, and documentation are updated without aliases.from_any, conversions, coordinate defaults, and constructor contracts.TransformationFormatalso supplies the former hint marker's role.@format_registry(isolated=True)to stop registration at their boundary. Nested registries still work, while their formats stay outside generic loading/saving. Export-only formats are excluded from reading candidates.Breaking changes: remove all
FileBased*/WritableFileBased*public wrappers and compatibility aliases. UseFormat,ImageFormat, orTransformationFormat, with reader/writer composition. Generic*FileParser/*FileParserWriterand standalone sniffer bases are removed. Format-specific*Parsernames are replaced by*Reader/*ReaderWriter. Migration guidance is documented.Validation: 2,502 I/O, CLI, and constructor-signature tests passed (37 skipped). Tests cover dispatch versus reader sniff contracts, independent read/write inheritance, field-free domain dispatchers, export-only filtering, isolated/nested registries, coordinate defaults, and constructor contracts. Verified the capability-based names of all 31 format-specific classes. Ruff, formatting, codespell, and diff checks pass.