-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: unify biomarker data model and bump to v1.0.0 #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ructure
- Replace complex nested structure {"value": X, "unit": "Y"} with simpler {"Y": X}
- Remove unit suffix logic (albumin_g_dl) in favor of direct unit keys
- Update helpers.py: remove format_unit_suffix() and update_biomarker_names()
- Simplify find_biomarker_value() to use direct dict access
- Rewrite add_converted_biomarkers() to add unit keys to existing objects
- Update all 80+ test JSON files to new format
- All tests passing with new structure
This change simplifies data handling for API endpoints and reduces code complexity.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Remove isinstance(biomarker, dict) check in find_biomarker_value() - Remove isinstance(v, dict) check in add_converted_biomarkers() comprehension - Remove isinstance(result[biomarker_name], dict) check in conversion loop Following Python's duck typing philosophy and EAFP principle. The data structure is predictable from our JSON schema, so type checks add noise without value. If data structure is wrong, let it fail with AttributeError. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ension
- Replace verbose loop-based extraction with dictionary comprehension approach
- Remove unnecessary find_biomarker_value() helper function
- Use biomarkers_for_scoring = {field: raw_biomarkers.get(field, {}).get(expected_units_dict[field]) for field in required_fields}
- Maintain same BiomarkerNotFound exception behavior for API consistency
- Reduce extract_biomarkers_from_json from 24 lines to 12 lines of core logic
- All 34 tests passing with cleaner, more readable code
The new approach uses dictionary comprehension for direct access instead of
complex loop-based searching, as originally suggested.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
…turn None instead of exceptions - Rename extract_biomarkers_from_json() to validate_biomarkers_for_algorithm() to better reflect its validation purpose - Change return type from Biomarkers to Biomarkers | None - Return None if any required biomarker is missing instead of raising BiomarkerNotFound - Update all model files (phenoage.py, score2.py, score2_diabetes.py) to use new function - Replace try/except blocks with simple None checks: if biomarkers is None: return None - Update all tests to expect None instead of exceptions for missing biomarkers - Remove unused exceptions import from test_helpers.py and helpers.py - All 34 tests passing with cleaner API flow This creates a better API pattern where algorithms can be conditionally executed based on data availability without exception handling overhead. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Unified SCORE2 and SCORE2-Diabetes schemas into single Markers class with optional diabetes fields - Added DiabetesMarkers factory pattern for type-safe diabetes algorithm validation - Updated compute functions to accept validated biomarker objects instead of file paths - Modified helper function to process raw biomarker dictionaries instead of files - Updated all tests to use new biomarker validation pattern - Removed separate MarkersDiabetes and UnitsDiabetes classes in favor of unified approach - Improved type safety and simplified algorithm interface consistency - Fixed mypy type checking for diabetes algorithm tests 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ss data and compute scores
- API interfaces are now stable with unified biomarker data model - Breaking changes warrant major version bump to signal maturity - Production-ready FastAPI integration with comprehensive test coverage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Claude finished @fbraza's task —— View job PR Code Review Complete ✅This major refactoring PR successfully unifies the biomarker data model and introduces breaking changes for v1.0.0. Here's my comprehensive review: Review Tasks
✅ Strengths1. Excellent Architecture Improvements
2. Strong FastAPI Integration
3. Comprehensive Testing
4. Code Quality Adherence
|
|
Claude finished @fbraza's task —— View job Claude finished PR review ✅ PR Code Review Complete ✅This major refactoring PR successfully unifies the biomarker data model and introduces breaking changes for v1.0.0. Here's my comprehensive review: Review Tasks
✅ Strengths1. Excellent Architecture Improvements
2. Strong FastAPI Integration
3. Comprehensive Testing
4. Code Quality Adherence
|
Summary
This PR represents a major refactoring of the biomarker data model and API interfaces, bumping the project to v1.0.0 to signal API stability.
Key Changes
Markersclass with optional diabetes fieldsDiabetesMarkers.try_from_markers()for safe diabetes algorithm validationcompute()functions now accept validated biomarker objects instead of file pathsBreaking Changes
compute()functions signature changed: now acceptMarkers/DiabetesMarkersobjects instead of file pathsMarkersDiabetesandUnitsDiabetesclassesvalidate_biomarkers_for_algorithm()now processes raw dictionaries instead of filesVersion Bump Justification
Bumping to v1.0.0 because:
Test Plan
🤖 Generated with Claude Code