refactor: Consolidate calculated data documents into shared mapping#1223
Open
nathan-stender wants to merge 4 commits into
Open
refactor: Consolidate calculated data documents into shared mapping#1223nathan-stender wants to merge 4 commits into
nathan-stender wants to merge 4 commits into
Conversation
Replace 12 independent _get_calculated_data_aggregate_document() implementations and 7 local CalculatedDataItem/DataSource type definitions with a single shared mapping function and the universal CalculatedDocument intermediate type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…node lists Introduce a flat, config-based API (CalcDoc, Measurement, build_calc_docs) for defining calculated data dependency graphs. This replaces 50+ nested helper functions across parsers with readable node list constants, making it clear how to add/edit calc docs without understanding the internal resolution engine. - New: calcdocs/builder.py (Measurement, CalcDoc, build_calc_docs) - New: calcdocs/views.py (shared FieldView, UuidView, SampleView, TargetView, etc.) - Migrated: appbio_quantstudio, designandanalysis, unchained_labs, msd_workbench, cytiva_biacore, bmg_labtech parsers - Removed: 7 redundant parser-specific view/config files - Moved CalculatedDataConfigWithOptional to core config.py - Net reduction: ~400 lines Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- CalcDoc.sources now takes list[Measurement | CalcDoc] instead of list[str] - Removes output_name field — node identity is the Python object, not the name - Removes _find_node linear scan — direct references eliminate name lookup - Adds _validate_graph() for eager error checking at build time - Adds describe_graph() utility for debugging node lists - Removes internal config exports from __init__.py (public API only) - Updates example to use new FieldView + build_calc_docs pattern - Each experiment type's nodes defined in a function for clear object scoping Benefits: typos in source names are now impossible (caught by Python itself), duplicate name disambiguation is explicit (separate objects), and IDE support (jump-to-definition, autocomplete) works on source references. Co-Authored-By: Claude Opus 4.6 <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
map_calculated_data_documents()function inparsers/utils/calculated_data_documents/mapping.pythat replaces 12 independent_get_calculated_data_aggregate_document()implementations across schema mappersCalculatedDataItem/DataSourcetype definitions from schema mappers, standardizing onCalculatedDocumentfromdefinition.pyas the universal intermediate typeCalculatedDocument→CalculatedDataItemand back)Details
New file:
src/allotropy/parsers/utils/calculated_data_documents/mapping.pymap_calculated_data_documents()— generic mapping for all schema versionsmap_calculated_data_documents_for_dpcr()— thin wrapper for dPCR'scalculated_datumfieldSchema mappers updated (12):
Parsers updated (7):
Test plan
🤖 Generated with Claude Code