Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a national end point, that provides elexon BMRS solar foreacsts from elexonpy package #347

Merged

Conversation

14Richa
Copy link
Contributor

@14Richa 14Richa commented Jul 17, 2024

Description

This PR introduces a new API endpoint /v0/solar/national/bmrs to fetch BMRS solar forecasts from the Elexon API.

Example Response

Below is the screenshot of the data getting from the API:
image

Fixes #346

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have checked my code and corrected any misspellings

@14Richa 14Richa marked this pull request as ready for review July 18, 2024 18:33
Copy link
Collaborator

@peterdudfield peterdudfield left a comment

Choose a reason for hiding this comment

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

Yea looks really good
A few points

  • It would be good, to only get slar forecasts, not wind forecasts
  • Need to add a test
  • We might want to create a pydantic return object, not just a dataframe.

src/main.py Outdated Show resolved Hide resolved
src/national.py Outdated Show resolved Hide resolved
src/national.py Outdated Show resolved Hide resolved
src/national.py Outdated Show resolved Hide resolved
src/national.py Outdated Show resolved Hide resolved
src/national.py Outdated Show resolved Hide resolved
src/national.py Outdated Show resolved Hide resolved
@peterdudfield
Copy link
Collaborator

Can you make sure tge pre commit works

@14Richa
Copy link
Contributor Author

14Richa commented Jul 23, 2024

Can you make sure tge pre commit works

This is solved.

@peterdudfield
Copy link
Collaborator

Can you add a test?

src/main.py Outdated Show resolved Hide resolved
src/national.py Outdated Show resolved Hide resolved
src/national.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@peterdudfield peterdudfield left a comment

Choose a reason for hiding this comment

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

Also do you need to add elexonpy to requirements?

Copy link
Collaborator

@peterdudfield peterdudfield left a comment

Choose a reason for hiding this comment

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

Code is good apart from a small change

Tests need test the actual api. The mocking is good though

src/pydantic_models.py Outdated Show resolved Hide resolved
f"&process_type=Day Ahead"
)

m.get(url, json=empty_mock_data, headers={"Content-Type": "application/json"})
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to set the actual api up and call the route. See other national tests


m.get(url, json=empty_mock_data, headers={"Content-Type": "application/json"})

response = requests.get(url)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead use response = api_client.get("/v0/solar/GB/national/elexon"), this should use the mocked api you have done above

@peterdudfield peterdudfield changed the base branch from main to development July 31, 2024 13:14
@peterdudfield peterdudfield merged commit a6b5e1b into openclimatefix:development Jul 31, 2024
1 check passed
@braddf
Copy link
Contributor

braddf commented Jul 31, 2024

Hmm I know this is merged now, but I'm not sure that the test added here is actually testing anything at all as it is..? 😅

cc. @peterdudfield

@peterdudfield
Copy link
Collaborator

I know i merged it to give it a go myself - https://github.com/openclimatefix/uk-pv-national-gsp-api/pull/350/files

peterdudfield added a commit that referenced this pull request Aug 13, 2024
* Add a national end point, that provides elexon BMRS solar foreacsts from elexonpy package (#347)

* added import statements of elexonpy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added API for solar forecast

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* minor fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* minor fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* changed function name

* added filter functionality

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added API link

* minor fix

* remove try except block

* changed bmrs to elexon

* minor fix

* resolving pre hook

* minor fix in docstring

* removed router

* minor fix in naming

* added elexonpy in requirement.txt file

* resolve hook error

* minor fix

* added response model

* fixed unit test

* remove plevel

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* first try at mocking elexon api

* upadte url for api

* update test, remove try and except

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* isort

* and try and except

* add intergation test

* lint

* PR comments, move elexon to below forecast and pvlive

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* change docker-compose to docker compose

* fix test

* Minor change to mock method on real class

---------

Co-authored-by: Richa <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: braddf <[email protected]>
Co-authored-by: braddf <[email protected]>
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.

Add BMRS national end point
3 participants