Closed justin13601 closed 3 weeks ago
The changes in this pull request involve enhancements to the get_predicates_df
function in src/aces/predicates.py
, improving the handling of static variables in derived predicates and refining error messaging. Additionally, several GitHub Actions workflow files have been updated to use newer versions of actions and to include additional steps for installing development packages. The .pre-commit-config.yaml
has been updated to a newer version of pre-commit-hooks
, while the pyproject.toml
file restricts the pre-commit
dependency to versions less than 4. The README.md
and docs/source/configuration.md
files have also been updated to improve documentation clarity and usability.
File | Change Summary |
---|---|
src/aces/predicates.py |
Enhanced get_predicates_df to handle static variables in derived predicates; improved error handling; added example usages in docstring. |
.github/workflows/code-quality-main.yaml |
Updated actions/checkout and actions/setup-python to versions 4 and 5; added step to install dev packages; updated pre-commit/action . |
.github/workflows/code-quality-pr.yaml |
Similar updates as code-quality-main.yaml , including action version upgrades and new dev package installation step. |
.github/workflows/tests.yml |
Upgraded actions/checkout and actions/setup-python ; changed package installation command. |
.pre-commit-config.yaml |
Updated pre-commit-hooks repository version from v4.4.0 to v5.0.0 . |
pyproject.toml |
Updated pre-commit dependency constraint from "pre-commit" to "pre-commit<4" . |
README.md |
Enhanced documentation for ACES, added details on new features, predicates configuration, and installation instructions. |
docs/source/configuration.md |
Clarified configuration language specification, added notes on memory optimization, and detailed field explanations. |
src/aces/config.py |
Improved error handling in TaskExtractorConfig for predicate definitions; updated docstring examples. |
src/aces/query.py |
Enhanced logging and error handling in query function for label extraction. |
sequenceDiagram
participant User
participant Predicates
participant DataFrame
User->>Predicates: Call get_predicates_df()
Predicates->>DataFrame: Retrieve static variables
DataFrame-->>Predicates: Return static variable values
Predicates->>DataFrame: Process derived predicates
DataFrame-->>User: Return updated DataFrame
🐇 "In code we hop and play,
With predicates bright as day,
Static values now align,
In our DataFrame, they shine!
With workflows fresh and neat,
Our coding journey's sweet!" 🐇
src/aces/config.py
[warning] 1378-1378: src/aces/config.py#L1378 Added line #L1378 was not covered by tests
src/aces/config.py (5)
`1077-1077`: **LGTM! Improved error message clarity.** The error message now clearly indicates the number of missing relationships and provides better context. --- `1169-1169`: **Excellent documentation improvements!** The added examples effectively demonstrate: 1. Configuration loading with predicates 2. Static and plain predicate joining 3. Complex nested derived predicates This significantly improves the understanding of the configuration system. Also applies to: 1199-1258 --- `1399-1404`: **LGTM! Enhanced input validation.** The added validation properly catches incorrect string-based predicate definitions and provides clear guidance on the correct format. --- `1454-1454`: **LGTM! Consistent error message formatting.** The error message formatting maintains consistency with the codebase style and improves readability. --- `1339-1339`: **LGTM! Robust predicate handling implementation.** The changes effectively: 1. Merge predicates from multiple sources 2. Recursively validate nested derived predicates 3. Build a comprehensive set of referenced predicates However, there's an uncovered code path. Let's verify the test coverage: Also applies to: 1353-1391
Attention: Patch coverage is 95.00000%
with 1 line
in your changes missing coverage. Please review.
Files with missing lines | Patch % | Lines |
---|---|---|
src/aces/config.py | 93.75% | 1 Missing :warning: |
Files with missing lines | Coverage Δ | |
---|---|---|
src/aces/predicates.py | 83.59% <100.00%> (-0.41%) |
:arrow_down: |
src/aces/query.py | 72.09% <ø> (-23.66%) |
:arrow_down: |
src/aces/config.py | 97.22% <93.75%> (-0.41%) |
:arrow_down: |
@mmcdermott I tried to implement a way to allow for derived predicates joining static and plain predicates - basically I just copy over the static predicate values from the null timestamp rows throughout the same subject_id if they exist since these are static and do not change. Then the logic for the evaluation of the derived predicates shouldn't need to change. Does this seem reasonable?
Might be a bit difficult to properly test the new error/warning messages in query.py
...
@justin13601, can you add tests to get the codecov up to the desired target?
Also closes #94
@mmcdermott I realized nested derived predicates will most likely be needed for creating these different reference ranges so I tried to enable that. Let me know if the following seems reasonable:
To create different reference ranges (for illustration purposes, not following actual clinical guidelines):
Different normal ranges:
normal_spo2_male_range:
code: lab_name//O2 saturation pulseoxymetry (%)
value_min: 90
value_max: 120
value_min_inclusive: True
value_max_inclusive: True
normal_spo2_female_range:
code: lab_name//O2 saturation pulseoxymetry (%)
value_min: 80
value_max: 110
value_min_inclusive: True
value_max_inclusive: True
normal_spo2_male:
expr: and(normal_spo2_male_range, male)
normal_spo2_female:
expr: and(normal_spo2_female_range, female)
Different abnormal ranges (may be worth looking into not()
logic...:
abnormally_low_spo2_male:
code: lab_name//O2 saturation pulseoxymetry (%)
value_max: 90
value_max_inclusive: False
abnormally_low_spo2_female:
code: lab_name//O2 saturation pulseoxymetry (%)
value_max: 80
value_max_inclusive: False
abnormally_high_spo2:
code: lab_name//O2 saturation pulseoxymetry (%)
value_min: 120
value_min_inclusive: False
abnormal_spo2_male_range:
expr: or(abnormally_low_spo2_male, abnormally_high_spo2)
abnormal_spo2_male:
expr: and(abnormal_spo2_male_range, male)
abnormal_spo2_female_range:
expr: or(abnormally_low_spo2_female, abnormally_high_spo2)
abnormal_spo2_female:
expr: and(abnormal_spo2_female_range, female)
abnormal_spo2:
expr: or(abnormal_spo2_male, abnormal_spo2_female)
@justin13601 this LGTM, so merge at your leisure.
For #144
Summary by CodeRabbit
New Features
Documentation
Chores