Skip to content

simplify complete model runs#620

Open
tomjemmett wants to merge 2 commits into
mainfrom
simplify_complete_model_runs
Open

simplify complete model runs#620
tomjemmett wants to merge 2 commits into
mainfrom
simplify_complete_model_runs

Conversation

@tomjemmett
Copy link
Copy Markdown
Member

the logic for the step counts and aggregations is identical, it makes sense to combine into one single step.

fixes #288 - at least, this doesn't appear to be an issue anymore. rather than just deleting the groupby/sum, added in a check to ensure there are no duplicated rows in the series. if there are then we will raise an assertion error.

this also simplifies the model iteration, instead of returning a tuple of the aggregated results and the step counts, the step counts are added to the results dictionary

the logic for the step counts and aggregations is identical, it makes sense to combine into one single step.

fixes #288 - at least, this doesn't appear to be an issue anymore. rather than just deleting the groupby/sum, added in a check to ensure there are no duplicated rows in the series. if there are then we will raise an assertion error.

this also simplifies the model iteration, instead of returning a tuple of the aggregated results and the step counts, the step counts are added to the results dictionary
@tomjemmett tomjemmett requested a review from a team as a code owner May 28, 2026 09:17
Copilot AI review requested due to automatic review settings May 28, 2026 09:17
@tomjemmett tomjemmett added this to the v5.1.0 milestone May 28, 2026
@tomjemmett tomjemmett added enhancement New feature or request priority: could We could implement this, but it is not vital/is a nice to have labels May 28, 2026
@tomjemmett tomjemmett self-assigned this May 28, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 28, 2026

✅ A new build is available.

You can use the following to use pull the image into your local environment:

docker pull ghcr.io/the-strategy-unit/nhp_model:pr-620

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (65bc79c) to head (7f469b5).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #620   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines         1130      1134    +4     
  Branches        56        58    +2     
=========================================
+ Hits          1130      1134    +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Simplifies result aggregation by merging step counts handling into the standard model results combination flow. Previously, get_aggregate_results returned a tuple of (aggregated_results, step_counts) requiring a separate _combine_step_counts function; now step counts are an entry in the same dictionary, eliminating duplicate logic. As part of this, the historical "duplicate rows" workaround (issue #288) is replaced with a defensive _check_for_duplicates assertion.

Changes:

  • Replace ModelRunResult tuple type with a plain dict[str, pd.Series] and place step_counts into the aggregations dict.
  • Remove _combine_step_counts and route step counts through _combine_model_results, adding a _check_for_duplicates guard.
  • Update unit/integration tests to match the new return shape and add coverage for the duplicate check.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/nhp/model/model_iteration.py Change ModelRunResult to a dict and add step counts into the aggregations dict.
src/nhp/model/results.py Remove _combine_step_counts; add _check_for_duplicates; reroute step counts through unified combine path.
src/nhp/model/run.py Adjust unpacking of get_aggregate_results and read step counts from results dict.
tests/unit/nhp/model/test_results.py Replace _combine_step_counts tests with _check_for_duplicates tests and update combine tests.
tests/unit/nhp/model/test_model_iteration.py Update assertions; add test for None step counts.
tests/unit/nhp/model/test_run.py Update mock side effects to new return shape.
tests/integration/nhp/model/test_single_model_run.py Stop unpacking tuple; remove redundant step_counts assignment.

Comment thread src/nhp/model/results.py Outdated
@tomjemmett tomjemmett modified the milestones: v5.1.0, v5.2.0 May 28, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: could We could implement this, but it is not vital/is a nice to have

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix TODO: handle the case of daycase conversion, it's duplicating values

2 participants