Skip to content

Conversation

braddf
Copy link
Contributor

@braddf braddf commented Apr 4, 2025

Pull Request

Description

Add forecast horizon params to CSV route to allow for latest and forecast_horizon as well as day_ahead.

N.B. This will change the default behaviour of the route to be latest, in line with other API routes unless specified in the query parameters, so we'll need to update the existing Day Ahead email before this is merged.

Fixes #

How Has This Been Tested?

  • Test to follow next week.
  • If your changes affect data processing, have you plotted any changes? i.e. have you done a quick sanity check?

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

@braddf braddf requested a review from peterdudfield April 4, 2025 15:09
case ForecastHorizon.horizon:
forecast_type = f"horizon_{forecast_horizon_minutes}"
case _:
# this shouldn't happen but will handle if class is changed
Copy link
Contributor

@peterdudfield peterdudfield Apr 4, 2025

Choose a reason for hiding this comment

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

raise 404 instead? or other appropriate error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should raise a 400 at the top of this route handler if it's not one of the defined options – this was more to keep the inferred Python types happy because I don't think they can quite work out this should always hit one of these cases? 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

if we remove above - we should be using ForecastHorizon.horizon and this should raise a 400 then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have stripped out the horizon option and doubled up on the 400 exception; feels like duplication, but can't see how else the inferred types could want this if we still want to validate at the start and return early if the param isn't valid (which we do)

@braddf braddf merged commit adb9657 into main Apr 4, 2025
8 checks passed
@braddf braddf deleted the feat/csv-forecast-horizon branch April 4, 2025 16:04
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.

2 participants