feat: add typed event data pipeline with loader registry#801
Open
feat: add typed event data pipeline with loader registry#801
Conversation
Contributor
Author
|
Hi @EdwardMoyse ,This PR replaces the 290-line if/else chain in PhoenixLoader with a registry-based approach. Much easier to extend now - experiments can add custom object types without overriding the entire load method. Also fixed a bug in Edm4hepJsonLoader where getRunNumber() and getEventNumber() were returning the wrong values (inverted null checks). All tests pass and I manually verified with Phoenix JSON, EDM4hep, and CMS .ig files.would appreciate a review whenever you have time! |
Signed-off-by: remo-lab <remopanda7@gmail.com>
4da6609 to
901707a
Compare
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
PhoenixLoader.loadObjectTypes() was 290 lines of if/else chains. Adding a new object type meant editing core code, and experiment loaders had to override the entire method just to add one custom type. Replaced it with a declarative registry. Also added proper TypeScript interfaces for event data and fixed a bug in Edm4hepJsonLoader where getRunNumber() and getEventNumber() had inverted logic.
Changes
src/lib/types/event-data.ts(new) - TypeScript interfaces for TrackParams, JetParams, CaloClusterParams, etc.src/loaders/object-type-registry.ts(new) - ObjectTypeConfig registry and default configssrc/loaders/phoenix-loader.ts- Replaced 290-line if/else with 60-line registry loopsrc/loaders/event-data-loader.ts- Added types to interface methodssrc/loaders/cms-loader.ts- Uses getObjectTypeConfigs() override instead of overriding loadObjectTypes()src/loaders/edm4hep-json-loader.ts- Fixed inverted logic in getRunNumber() / getEventNumber()src/event-display.ts- Typed eventsData and related methodssrc/index.ts- Export new types and registryTesting
yarn tsc:build --noEmitpasses with zero errorsNotes
Skipped decorator-based registration - adds complexity for minimal benefit. The explicit registry is simpler and easier to debug.