API for hosting nowcasting solar predictions. Will just return 'dummy' numbers until about mid-2022!
We use FastAPI.
Documentation can be viewed at /docs
or /swagger
. This is automatically generated from the code.
This can be done it two different ways: With Python or with Docker.
python3 -m venv ./venv
source venv/bin/activate
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.
If you don't have a local database set up, you can leave the
DB_URL
string empty (default not set) and the API will still run and return routes such ashttp://localhost:8000/
for API info and any other non-DB routes with DB dependencies e.g. session/caching commented out.You will not be able to access any routes using the DB client / database, but for local development of new routes this should work for now, until we reinstate dynamic fake data as a dependable dev tool.
- Make sure docker is installed on your system.
- Use
docker-compose up
in the main directory to start up the application. - You will now be able to access it on
http://localhost:80
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
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:
- Install pre-commit
- Check the install worked via
pre-commit --v
- Install the git hooks script via
pre-commit install
Deployment of this service is now done through terraform cloud.
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 likehttps://XXXXXXXXXX.eu.auth0.com/api/v2/
DB_URL
- The Forecast database URL used to get GSP forecast dataDB_URL_PV
- The PV database URL, used to get PV dataORIGINS
- 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 dataFORECAST_ERROR_HOURS
- using route/v0/system/GBstatus/check_last_forecast_run
we can check if a forecast has been made in the lastFORECAST_ERROR_HOURS
hoursADJUST_MW_LIMIT
- the maximum the api is allowed to adjust the national forecast by
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];
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];
graph TD;
G1(status)-->G2;
G2[Status];
G3(gsp)-->G4
G4[Location]
Thanks goes to these wonderful people (emoji key):
Peter Dudfield 💻 |
Mohammed Faisal 💻 |
Bodale Denis 💻 |
Souhit Dey 💻 |
Flo 💻 |
Shanmukh 💻 |
Sixte de Maupeou 💻 |
rachel tipton 💻 |
braddf 💻 |
Dorin 👀 |
Peter Hull 💻 |
Pedro Garcia Rodriguez 💻 |
Richa 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!