You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🟡 Changes recommended
The new shared null-check/extract helper has correctness and reliability gaps (assert-based enforcement, NA/NaN handling, and avoidable repeated Spark recomputation) that should be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
This PR refactors the model-data extract scripts to centralize the common “write parquet + partitioning” logic into a shared decorator, and adds extract-time validation to catch missing values (related to #145).
Changes:
Introduces a shared @extract(...) decorator and check_extract_for_nulls(...) helper to standardize extraction and (optionally) null-check outputs.
Updates multiple extract scripts to return DataFrames and delegate writing/partitioning to the decorator.
Adds a row-count log message during extracts and per-extract column-exclusion lists for null checks.
File
Description
src/nhp/data/model_data/helpers.py
Adds shared extraction decorator and null-check helper.
src/nhp/data/model_data/op.py
Migrates OP extract to decorator-based pattern and returns DF.
src/nhp/data/model_data/ip.py
Migrates IP extract to decorator-based pattern and returns DF.
src/nhp/data/model_data/aae.py
Migrates A&E extract to decorator-based pattern and returns DF.
src/nhp/data/model_data/ip_tpmas.py
Splits TPMA extracts into two decorated extract functions.
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🟡 Changes recommended
The new extract decorator can leak persisted DataFrames on exceptions and includes a misleading null-check error message, which should be corrected before merging.
Get a fresh assessment by requesting another Copilot review.
DataFrame is imported from pyspark.sql.dataframe while SparkSession is imported from pyspark.sql; this is inconsistent with the other model_data extract modules and can be simplified to a single import statement.
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🔵 Needs a closer look
A few issues in the new shared helper (misleading error/doc text and missing wrapper metadata preservation) should be addressed to avoid confusion and improve maintainability.
Decorator drops function metadata without functools.wraps
src/nhp/data/model_data/helpers.py:132
The extract decorator wraps the original function but does not preserve its metadata (name/docstring/qualname), making stack traces and CLI help output less informative. Consider using functools.wraps (without copying annotations) so the decorated extract functions remain identifiable.
Docstring incorrectly describes null-value checks as null columns
src/nhp/data/model_data/helpers.py:93
Docstring says "null columns" but the function checks for null values within columns, which is misleading for anyone relying on this helper. Update the wording (and the exclude_cols type in the doc) to match the actual behavior.
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
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.
fixes #145