Skip to content

Conversation

@SamuelBrand1
Copy link
Collaborator

Summary

This PR adds an extensible interface for processing location forecasts to support multiple model types and make easier to do future expansion, which unblocks #783 .

Details

I've added a new model_name argument to process_loc_forecast function, if this is not NA then it lowers to process_forecast function and if it is NA (as default) then current logic is untouched.

process_forecast function can either be supplied a model_type to dispatch on a process_model_samples method or it detects from model name with the detect_model_type helper func. The functions then gathers the same data as process_loc_forecast and then dispatches the appropriate processing on the raw model output.

  • Added process_model_samples methods for "pyrenew" and "timeseries" model types, so this should work with eg model_name = "pyrenew_e" but I've also kept legacy interface for backwards compat.

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

❌ Patch coverage is 39.62264% with 64 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.71%. Comparing base (06c3a48) to head (7a6a426).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
hewr/R/process_loc_forecast.R 39.62% 64 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #790      +/-   ##
==========================================
+ Coverage   39.43%   41.71%   +2.27%     
==========================================
  Files          30       30              
  Lines        2713     2817     +104     
==========================================
+ Hits         1070     1175     +105     
+ Misses       1643     1642       -1     
Flag Coverage Δ
hewr 37.97% <39.62%> (+8.03%) ⬆️
pipelines 35.87% <ø> (ø)
pyrenew_hew 62.29% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

SamuelBrand1 and others added 7 commits December 15, 2025 23:36
Updates `process_loc_forecast` to delegate to the new interface when `model_name` is provided, and adds comprehensive tests for model type detection, S3 dispatch, and interface validation.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@damonbayer damonbayer requested a review from Copilot December 16, 2025 21:35
Copy link
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

This PR introduces an extensible S3 dispatch system for processing location forecasts, enabling support for multiple model types and simplifying future model additions. The implementation adds a new model_name parameter to process_loc_forecast that leverages S3 method dispatch via process_model_samples, while maintaining backward compatibility with the existing interface.

Key changes:

  • Added S3 generic process_model_samples with methods for "pyrenew" and "timeseries" model types
  • Implemented detect_model_type helper to auto-detect model type from naming conventions
  • Created new process_forecast function as simplified interface using the S3 dispatch system

Reviewed changes

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

Show a summary per file
File Description
hewr/R/process_loc_forecast.R Core implementation of S3 dispatch system, including process_model_samples generic/methods, detect_model_type helper, and new process_forecast function with updated process_loc_forecast routing logic
hewr/tests/testthat/test_process_loc_forecast.R Tests for S3 dispatch functionality, model type detection, and validation of both new and legacy interfaces
hewr/tests/testthat/test_timeseries_utils.R Comprehensive test suite for timeseries utility functions including formatting, aggregation, and proportion calculations
hewr/man/*.Rd Documentation files for new exported functions and S3 methods
hewr/NAMESPACE Updated exports to include new S3 methods and functions
hewr/DESCRIPTION RoxygenNote version bump from 7.3.2 to 7.3.3

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@damonbayer damonbayer left a comment

Choose a reason for hiding this comment

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

I think there is probably room to make some better abstractions, but I'm in favor of unblocking #783, so I have approved this PR and will work on some parallel changes in another PR.

@SamuelBrand1 SamuelBrand1 merged commit f69b358 into main Dec 17, 2025
11 checks passed
@SamuelBrand1 SamuelBrand1 deleted the 788-inflexible-logic branch December 17, 2025 14:31
damonbayer added a commit that referenced this pull request Dec 17, 2025
@damonbayer
Copy link
Collaborator

This broke the pipeline. Missed it due to insufficient testing (#791)

@damonbayer damonbayer restored the 788-inflexible-logic branch December 17, 2025 20:52
@SamuelBrand1 SamuelBrand1 mentioned this pull request Dec 17, 2025
SamuelBrand1 added a commit that referenced this pull request Dec 17, 2025
* Add S3 dispatch for model sample processing and new interface

Updates `process_loc_forecast` to delegate to the new interface when `model_name` is provided, and adds comprehensive tests for model type detection, S3 dispatch, and interface validation.

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Add S3 method export and refresh roxygen

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix linting

* applied air formatting

* shorten line for reasons

* Avoid method warning

* up coverage to pass CI

* add method smoke tests

* refactor tests

* trigger ci

* Revert "trigger ci"

This reverts commit 8b5cfd4.

* Update plot_and_save_loc_forecast.R

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

Binary Model Name Parameters in process_loc_forecast.R

3 participants