Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/india_api/internal/service/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class GetSourcesResponse(BaseModel):
@router.get(
"/sources",
status_code=status.HTTP_200_OK,
include_in_schema=False,
)
def get_sources_route(auth: dict = Depends(auth)) -> GetSourcesResponse:
"""Function for the sources route."""
Expand Down Expand Up @@ -60,6 +61,7 @@ def validate_source(source: str) -> str:
@router.get(
"/{source}/regions",
status_code=status.HTTP_200_OK,
include_in_schema=False,
)
def get_regions_route(
source: ValidSourceDependency,
Expand All @@ -85,6 +87,7 @@ class GetHistoricGenerationResponse(BaseModel):
@router.get(
"/{source}/{region}/generation",
status_code=status.HTTP_200_OK,
include_in_schema=False,
)
def get_historic_timeseries_route(
source: ValidSourceDependency,
Expand Down Expand Up @@ -126,6 +129,7 @@ class GetForecastGenerationResponse(BaseModel):
@router.get(
"/{source}/{region}/forecast",
status_code=status.HTTP_200_OK,
include_in_schema=False,
)
def get_forecast_timeseries_route(
source: ValidSourceDependency,
Expand Down Expand Up @@ -178,7 +182,9 @@ def get_forecast_timeseries_route(


@router.get(
"/{source}/{region}/forecast/csv", response_class=FileResponse
"/{source}/{region}/forecast/csv",
response_class=FileResponse,
include_in_schema=False,
)
def get_forecast_da_csv(
source: ValidSourceDependency,
Expand All @@ -191,7 +197,12 @@ def get_forecast_da_csv(
"""

forcasts: GetForecastGenerationResponse = get_forecast_timeseries_route(
source=source, region=region, db=db, auth=auth, forecast_horizon=ForecastHorizon.day_ahead, smooth_flag=False
source=source,
region=region,
db=db,
auth=auth,
forecast_horizon=ForecastHorizon.day_ahead,
smooth_flag=False,
)

# format to dataframe
Expand All @@ -202,8 +213,10 @@ def get_forecast_da_csv(
tomorrow_ist = df["Date [IST]"].iloc[0]
csv_file_path = f"{region}_{source}_da_{tomorrow_ist}.csv"

description = f"Forecast for {region} for {source} for {tomorrow_ist}. " \
f"The Forecast was created at {created_time} and downloaded at {now_ist}"
description = (
f"Forecast for {region} for {source} for {tomorrow_ist}. "
f"The Forecast was created at {created_time} and downloaded at {now_ist}"
)

output = df.to_csv(index=False)
return StreamingResponse(
Expand Down
13 changes: 7 additions & 6 deletions src/india_api/internal/service/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
"Each site will have one source of energy "
"and there is forecast and generation data for each site. ",
},
{
"name": "Regions",
"description": "A region is an area of land e.g. Alaska in the USA. "
"There is forecast and generation data for each region "
"and there may be different sources of energy in one region.",
},
# I want to keep this here, as we might add this back in the future
# {
# "name": "Regions",
# "description": "A region is an area of land e.g. Alaska in the USA. "
# "There is forecast and generation data for each region "
# "and there may be different sources of energy in one region.",
# },
]

title = "India API"
Expand Down
Loading