From 9861c51c34331c927d4cf05ab1a9cd675e6cb82f Mon Sep 17 00:00:00 2001 From: Rosheen Naeem Date: Mon, 11 Mar 2024 19:07:08 +0100 Subject: [PATCH 1/2] Remove now_casting Dataset Usage and Adjust GSP Endpoints (#323) * removed nowcasting_dataset * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- requirements.txt | 1 - src/system.py | 48 ------------------------------------------------ 2 files changed, 49 deletions(-) diff --git a/requirements.txt b/requirements.txt index f9cb5ec..2ea7900 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,6 @@ pydantic numpy requests nowcasting_datamodel==1.5.18 -nowcasting_dataset==3.7.12 sqlalchemy psycopg2-binary geopandas diff --git a/src/system.py b/src/system.py index 4e6da2a..8ea4b1b 100644 --- a/src/system.py +++ b/src/system.py @@ -7,7 +7,6 @@ from fastapi import APIRouter, Depends, Request, Security from fastapi_auth0 import Auth0User from nowcasting_datamodel.models import GSPYield, Location -from nowcasting_dataset.data_sources.gsp.eso import get_gsp_metadata_from_eso from sqlalchemy.orm.session import Session from auth_utils import get_auth_implicit_scheme, get_user @@ -23,53 +22,6 @@ NationalYield = GSPYield -def get_gsp_boundaries_from_eso_wgs84() -> gpd.GeoDataFrame: - """Get GSP boundaries in lat/lon format (EPSG:4326)""" - - # get gsp boundaries - boundaries = get_gsp_metadata_from_eso() - - # change to lat/lon - https://epsg.io/4326 - boundaries = boundaries.to_crs(4326) - - # fill nans - boundaries = boundaries.fillna("") - - return boundaries - - -# corresponds to API route /v0/system/GB/gsp/boundaries -@router.get( - "/boundaries", - dependencies=[Depends(get_auth_implicit_scheme())], -) -@cache_response -@limiter.limit(f"{N_CALLS_PER_HOUR}/hour") -def get_gsp_boundaries( - request: Request, - session: Session = Depends(get_session), - user: Auth0User = Security(get_user()), -) -> dict: - """### Get GSP boundaries - - Returns an object with GSP boundaries provided by National Grid ESO. - - [This is a wrapper around the dataset](https://data.nationalgrideso.com/systemgis-boundaries-for-gb-grid-supply-points). - - The return object is in EPSG:4326 (ie. contains latitude & longitude - coordinates). - - """ - - logger.info(f"Getting all GSP boundaries for user {user}") - - json_string = get_gsp_boundaries_from_eso_wgs84().to_json() - - json.loads(json_string) - - return json.loads(json_string) - - # corresponds to API route /v0/system/GB/gsp/, get system details for all GSPs @router.get( "/", From f26d6a9c8d7b455d4b57cbe0520449d170ca808d Mon Sep 17 00:00:00 2001 From: Rosheen Naeem Date: Mon, 11 Mar 2024 20:49:28 +0100 Subject: [PATCH 2/2] Removed now_cast dataset tests (#326) * removed nowcasting_dataset * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * removed realted test * Merge branch 'nowcast_dataset' of https://github.com/roshnaeem/uk-pv-national-gsp-api into nowcast_dataset --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/tests/test_system.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/tests/test_system.py b/src/tests/test_system.py index 9ae9efb..ca3ec26 100644 --- a/src/tests/test_system.py +++ b/src/tests/test_system.py @@ -28,13 +28,3 @@ def test_get_gsp_systems(db_session, api_client): locations = [Location(**location) for location in response.json()] assert len(locations) == 10 assert locations[1].installed_capacity_mw == 1.1 - - -def test_gsp_boundaries(db_session, api_client): - """Check main system/GB/gsp/boundaries""" - - app.dependency_overrides[get_session] = lambda: db_session - - response = api_client.get("/v0/system/GB/gsp/boundaries") - assert response.status_code == 200 - assert len(response.json()) > 0