Skip to content

Conversation

@peterdudfield
Copy link
Contributor

@peterdudfield peterdudfield commented Dec 17, 2025

Pull Request

Description

Move uk-national over to this quartz-api

  • National routes
  • GSP routes
  • status routes - this loads from the old database for the moment. This will change in the future
  • system routes

Currently

  • forecast/all takes about ~13 seconds, which is to slow (benchmark from old app was). We currently looping over ForecastAtTimestamp
  • pvlive/all takes about ~10 seconds

#147

How Has This Been Tested?

  • CI tests
  • ran locally, and UAT from airflow run against the API
  • deployed and ran on aws,
  • and UAT from airflow run against the API
  • deploy UI to use this API - link

dont do in this PR: add end to end test for uk-national with the app #179
dont do in this PR: add seperate UAT in airflow that tests it

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

…nal-and-gsp-locations

# Conflicts:
#	src/quartz_api/cmd/main.py
#	src/quartz_api/internal/backends/dataplatform/client.py
#	src/quartz_api/internal/models.py
…nal-and-gsp-framework

# Conflicts:
#	src/quartz_api/cmd/main.py
…-locations

# Conflicts:
#	src/quartz_api/cmd/main.py
#	src/quartz_api/internal/service/uk_national/gsp.py
#	src/quartz_api/internal/service/uk_national/national.py
#	src/quartz_api/internal/service/uk_national/system.py
# Conflicts:
#	src/quartz_api/internal/service/uk_national/national.py
# Conflicts:
#	src/quartz_api/internal/service/uk_national/national.py
# Conflicts:
#	src/quartz_api/internal/service/uk_national/gsp.py
#	src/quartz_api/internal/service/uk_national/national.py
#	src/quartz_api/internal/service/uk_national/system.py
# Conflicts:
#	src/quartz_api/internal/backends/dataplatform/client.py
return forecasts_one_timestamp

@override
async def get_forecast_for_multiple_locations(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could also move this into the gsp.py route, and just use the route for get forecast at one timestamp. But we do need to make sure we only call ListForecastersRequest request once

Copy link
Contributor

@devsjc devsjc left a comment

Choose a reason for hiding this comment

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

Lots of notes to do with changing where default values are managed and removing a bunch of optional ones. I think this makes the logic path much easier to follow.

Comment on lines 41 to 44
forecaster_name: str | None = None,
start_datetime: dt.datetime | None = None,
end_datetime: dt.datetime | None = None,
created_before_datetime: dt.datetime | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think these should be optional at this level; it should be the job of the HTTP route calling these interface functions to put suitable defaults onto them.

Suggested change
forecaster_name: str | None = None,
start_datetime: dt.datetime | None = None,
end_datetime: dt.datetime | None = None,
created_before_datetime: dt.datetime | None = None,
forecaster_name: str,
start_datetime: dt.datetime,
end_datetime: dt.datetime,
created_before_datetime: dt.datetime,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with datetimes, but the forecaster_name sometimes we just want to pull a forecast, and API doesnt need to know which model to pull this for.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

Most of this can go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this needs to stay. We need to have a function somewhere that floor the start time to the nearest 6 hours, and then minuses it. I think this is the right place for the tests

Copy link
Contributor

Choose a reason for hiding this comment

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

Not if they live in the defaults though? It would be odd to test the pandas 'floor' or subtract timedelta functions, as you trust pandas to have tested that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Its not pandas
  2. the logic of floor 6 and minus 2 days I think is worth its own function
  3. linting didnt let me put datetime.now() in the defaults
    B008 Do not perform function call `dt.datetime.now` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, most of this can go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this needs to stay. We need to have a function somewhere that floor the start time to the nearest 6 hours, and then minuses it. I think this is the right place for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

See my above comment.

peterdudfield and others added 9 commits January 21, 2026 11:59
Co-authored-by: devsjc <47188100+devsjc@users.noreply.github.com>
Co-authored-by: devsjc <47188100+devsjc@users.noreply.github.com>
Co-authored-by: devsjc <47188100+devsjc@users.noreply.github.com>
@peterdudfield
Copy link
Contributor Author

BTW, i got a linting error

B008 Do not perform function call `dt.datetime.now` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

you ok with this @devsjc ?

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.

4 participants