Git Product home page Git Product logo

uk-pv-national-gsp-api's Introduction

Nowcasting API

All Contributors

codecov

API for hosting nowcasting solar predictions. Will just return 'dummy' numbers until about mid-2022!

We use FastAPI.

Documentation

Documentation can be viewed at /docs or /swagger. This is automatically generated from the code.

Setup and Run

This can be done it two different ways: With Python or with Docker.

Python

Create a virtual env

python3 -m venv ./venv
source venv/bin/activate

Install Requirements and Run

pip install -r requirements.txt
cd src && uvicorn main:app --reload

You may need to run the following additional installation pip install git+https://github.com/SheffieldSolar/PV_Live-API#pvlive_api for pvlive-api, as in the Dockerfile.

Docker

  1. Make sure docker is installed on your system.
  2. Use docker-compose up in the main directory to start up the application.
  3. You will now be able to access it on http://localhost:80

Tests

TO run tests use the following command

docker stop $(docker ps -a -q)
docker-compose -f test-docker-compose.yml build
docker-compose -f test-docker-compose.yml run api

Development

We use pre-commit to manage various pre-commit hooks. All hooks are also run as Actions when code is pushed to GitHub.

You can run the formatters and linters locally. To do that:

  1. Install pre-commit
  2. Check the install worked via pre-commit --version
  3. Install the git hooks script via pre-commit install

Deployment

Deployment of this service is now done through terraform cloud.

Environmental Variables

  • AUTH0_DOMAIN - The Auth0 domain which can be collected from the Applications/Applications tab. It should be something like 'XXXXXXX.eu.auth0.com'
  • AUTH0_API_AUDIENCE - THE Auth0 api audience, this can be collected from the Applications/APIs tab. It should be something like https://XXXXXXXXXX.eu.auth0.com/api/v2/
  • DB_URL- The Forecast database URL used to get GSP forecast data
  • DB_URL_PV - The PV database URL, used to get PV data
  • ORIGINS - Endpoints that are valid CORS origins. See FastAPI documentation.
  • N_HISTORY_DAYS - Default is just to load data from today and yesterday, but we can set this to 5, if we want the api always to return 5 days of data
  • FORECAST_ERROR_HOURS - using route /v0/system/GBstatus/check_last_forecast_run we can check if a forecast has been made in the last FORECAST_ERROR_HOURS hours
  • ADJUST_MW_LIMIT - the maximum the api is allowed to adjust the national forecast by

Routes to SQL tables

National

  graph TD;
      N1(national/forecast) --> Q1;
      Q1{Include metadata?>} -->|no| Q2;
      Q1 --> |yes| N2[NationalForecast];
      N4[ForecastValueLatest];
      Q2{forecast horizon <br> minutes not None}
      Q2-->|yes| N5[ForecastValueSevenDays];
      Q2-->|no| N4;

      NP1(national/pvlive)-->NP2;
      NP2[GSPYield];
Loading

GSP

  graph TD;
      G1(gsp/forecast/all);
      G1--> N3[ManyForecasts];

      G3(gsp/gsp_id/forecast) -->Q4;
      Q4{forecast horizon <br> minutes not None}
      Q4-->|yes| G7[ForecastValueSevenDays];
      Q4-->|no| G6[ForecastValueLatest];

      GP1(gsp/pvlive/all)-->GP2;
      GP2[LocationWithGSPYields];

      GP3(gsp/gsp_id/pvlive)-->GP4;
      GP4[GSPYield];
Loading

Extras

  graph TD;
      G1(status)-->G2;
      G2[Status];

      G3(gsp)-->G4
      G4[Location]

Loading

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

Peter Dudfield
Peter Dudfield

๐Ÿ’ป
Mohammed Faisal
Mohammed Faisal

๐Ÿ’ป
Bodale Denis
Bodale Denis

๐Ÿ’ป
Souhit Dey
Souhit Dey

๐Ÿ’ป
Flo
Flo

๐Ÿ’ป
Shanmukh
Shanmukh

๐Ÿ’ป
Sixte de Maupeou
Sixte de Maupeou

๐Ÿ’ป
rachel tipton
rachel tipton

๐Ÿ’ป
braddf
braddf

๐Ÿ’ป
Dorin
Dorin

๐Ÿ‘€
Peter Hull
Peter Hull

๐Ÿ’ป
Pedro Garcia Rodriguez
Pedro Garcia Rodriguez

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

uk-pv-national-gsp-api's People

Contributors

peterdudfield avatar pre-commit-ci[bot] avatar flowirtz avatar allcontributors[bot] avatar rachel-labri-tipton avatar braddf avatar jacobbieker avatar dctanner avatar devsjc avatar obitorasu avatar bodaledenis avatar breakingpitt avatar mdfaisal98 avatar vnshanmukh avatar jackkelly avatar petermnhull avatar sixtedemaupeou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.