Model/backend/app/config.py
2024-07-22 14:47:24 +01:00

52 lines
1.4 KiB
Python

from functools import lru_cache
from pydantic import BaseSettings
class Settings(BaseSettings):
API_KEY: str
API_KEY_NAME: str = "X-API-KEY"
SECRET_KEY: str
ENVIRONMENT: str
DATA_BUCKET: str
PLAN_TRIGGER_BUCKET: str
# Third parties
EPC_AUTH_TOKEN: str
ORDNANCE_SURVEY_API_KEY: str
GOOGLE_SOLAR_API_KEY: str
FARADAY_API_KEY: str
# Database settings
DB_HOST: str
DB_PASSWORD: str
DB_USERNAME: str
DB_PORT: str
DB_NAME: str
# Prediction buckets
SAP_PREDICTIONS_BUCKET: str
CARBON_PREDICTIONS_BUCKET: str
HEAT_PREDICTIONS_BUCKET: str
LIGHTING_COST_PREDICTIONS_BUCKET: str
HEATING_COST_PREDICTIONS_BUCKET: str
HOT_WATER_COST_PREDICTIONS_BUCKET: str
class Config:
env_file = "backend/.env"
@lru_cache()
def get_settings():
return Settings()
@lru_cache()
def get_prediction_buckets():
return {
"sap_change_predictions": get_settings().SAP_PREDICTIONS_BUCKET,
"heat_demand_predictions": get_settings().HEAT_PREDICTIONS_BUCKET,
"carbon_change_predictions": get_settings().CARBON_PREDICTIONS_BUCKET,
"lighting_cost_predictions": get_settings().LIGHTING_COST_PREDICTIONS_BUCKET,
"heating_cost_predictions": get_settings().HEATING_COST_PREDICTIONS_BUCKET,
"hot_water_cost_predictions": get_settings().HOT_WATER_COST_PREDICTIONS_BUCKET
}