Skip to content

refactor: Declarative calcdocs API — flat node lists replace helper pyramids#1228

Closed
nathan-stender wants to merge 1 commit into
mainfrom
refactor/calcdocs-declarative-api
Closed

refactor: Declarative calcdocs API — flat node lists replace helper pyramids#1228
nathan-stender wants to merge 1 commit into
mainfrom
refactor/calcdocs-declarative-api

Conversation

@nathan-stender

Copy link
Copy Markdown
Collaborator

Summary

  • Introduces a flat, config-based API (CalcDoc, Measurement, build_calc_docs) for defining calculated data dependency graphs
  • Replaces 50+ nested helper functions across 6 parsers with readable node list constants
  • Adds shared generic view classes (FieldView, UuidView, SampleView, TargetView, TargetRoleView) eliminating duplicate implementations
  • Removes 7 redundant parser-specific view/config files; net ~400 lines removed

Motivation

The old API required writing a helper function per calculated document, resulting in deeply nested pyramids (8 levels in relative_standard_curve) that were hard to read, maintain, or extend. The new declarative lists make the dependency graph visible at a glance — adding a new calc doc is one line, not a new function.

What changed

File Change
calcdocs/builder.py NewMeasurement, CalcDoc, Node, build_calc_docs()
calcdocs/views.py New — shared FieldView, UuidView, ViewWithReference, SampleView, TargetView, TargetRoleView
calcdocs/config.py Absorbed CalculatedDataConfigWithOptional, removed dead code
calcdocs/__init__.py Public API exports
appbio_quantstudio 511 → ~130 lines (4 flat node lists)
appbio_quantstudio_designandanalysis 593 → ~136 lines (4 flat node lists)
unchained_labs_lunatic_stunner 314 → ~70 lines
msd_workbench Replaced 4 view classes + 10 configs with node list
cytiva_biacore_t200_control Replaced CalcDocsConfig boilerplate with node list
bmg_labtech_smart_control Inline node list + build_calc_docs
7 deleted files Old parser-specific views.py / config.py

Test plan

  • All 736 parser golden tests pass unchanged (hatch run test_all.py3.10:pytest tests/parsers/ -x -q)
  • Full lint passes (ruff, black, mypy — 0 errors)
  • No testdata JSON files modified — purely internal refactoring

🤖 Generated with Claude Code

…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>
@nathan-stender
nathan-stender requested review from a team and slopez-b as code owners June 11, 2026 19:19
@nathan-stender
nathan-stender deleted the refactor/calcdocs-declarative-api branch June 11, 2026 19:48
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