refactor(open): extract OpenRequest + decompose Dataset.open (PR4)#187
Merged
Conversation
Dataset.open was a 155-line method mixing argument unpacking, path validation, metadata loading, indexer construction, source assembly (seqs/tracks), reference-bounds sanity-check, dataset assembly, and post-construction settings. Pull all of that into a new `_dataset/_open.py` module housing an `OpenRequest` dataclass. `OpenRequest.resolve()` orchestrates the stages, each a small named method (`_load_metadata`, `_build_indexer`, `_resolve_reference`, `_build_seqs`, `_build_tracks`, `_initial_seqs_kind`, `_check_reference_bounds`, `_assemble_dataset`, `_apply_post_settings`). Each stage reads in one sitting and can be exercised independently when we want stage-level unit tests later. `Dataset.open` is now a thin facade (~20 lines including docstring delimiters) that packs its arguments into an OpenRequest and calls `.resolve()`. Public API surface unchanged. `_impl.py`: 2156 -> 2015 (-141 lines). Behavior preserving; full test suite (488 pytest + cargo) green; pyrefly + ruff clean. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Dataset.openwas a 155-line method mixing arg unpacking, path validation, metadata loading, indexer build, source assembly (Haps/Ref+Tracks), reference-bounds check, dataset assembly, and post-construction settings application.python/genvarloader/_dataset/_open.pydefines anOpenRequestfrozen dataclass holding the parsed args plus a.resolve()method that orchestrates the stages, each as its own small method:_validate_path_load_metadata_build_indexer_resolve_reference_build_seqs_build_tracks_initial_seqs_kind_check_reference_bounds_assemble_dataset_apply_post_settingsDataset.openis now a thin facade (~20 lines) that constructs anOpenRequestand calls.resolve(). Public API unchanged; both@overloaddeclarations onDataset.openare preserved._impl.py: 2156 → 2015 (−141 lines). New_open.py: 262 lines. Net: stages are now small enough to unit-test individually if/when desired.Test plan
pixi run -e dev test(488 pytest + cargo) — all passpixi run -e dev ruff check python/— cleanpixi run -e dev pyrefly check— 0 errors (baseline unchanged)Part of the refactor campaign tracked in
docs/superpowers/specs/2026-05-23-refactor-campaign-design.md.🤖 Generated with Claude Code