54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
from pathlib import Path
|
|
|
|
import yaml
|
|
from pydantic import BaseModel
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class SmardConfig(BaseModel):
|
|
region: str = "DE-LU"
|
|
price_filter: int = 4169
|
|
load_forecast_filter: int = 4382
|
|
generation_total_filter: int = 122
|
|
wind_onshore_filter: int = 4069
|
|
wind_offshore_filter: int = 4068
|
|
pv_filter: int = 4070
|
|
base_url: str = "https://www.smard.de/app/chart_data"
|
|
|
|
|
|
class BrightSkyConfig(BaseModel):
|
|
lat: float = 52.52
|
|
lon: float = 13.41
|
|
base_url: str = "https://api.brightsky.dev/weather"
|
|
|
|
|
|
class DatabaseConfig(BaseModel):
|
|
path: str = "output/pipeline.duckdb"
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_nested_delimiter="__",
|
|
env_prefix="STROM_",
|
|
extra="ignore"
|
|
)
|
|
|
|
smard: SmardConfig = SmardConfig()
|
|
brightsky: BrightSkyConfig = BrightSkyConfig()
|
|
database: DatabaseConfig = DatabaseConfig()
|
|
|
|
|
|
def load_config(config_path: str = "config/config.yaml") -> Settings:
|
|
path = Path(config_path)
|
|
if not path.exists():
|
|
return Settings()
|
|
|
|
with open(path, "r") as f:
|
|
config_data = yaml.safe_load(f) or {}
|
|
|
|
return Settings(**config_data)
|
|
|
|
|
|
# Global settings instance
|
|
settings = load_config()
|