Improve base config
This commit is contained in:
@@ -1,32 +1,59 @@
|
||||
# ================================================================
|
||||
# FORECASTING SERVICE CONFIGURATION
|
||||
# services/forecasting/app/core/config.py
|
||||
# ================================================================
|
||||
|
||||
"""
|
||||
uLuforecasting service configuration
|
||||
Forecasting service configuration
|
||||
Demand prediction and forecasting
|
||||
"""
|
||||
|
||||
from shared.config.base import BaseServiceSettings
|
||||
import os
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Application settings"""
|
||||
class ForecastingSettings(BaseServiceSettings):
|
||||
"""Forecasting service specific settings"""
|
||||
|
||||
# Basic settings
|
||||
APP_NAME: str = "uLuforecasting Service"
|
||||
VERSION: str = "1.0.0"
|
||||
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
|
||||
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
|
||||
# Service Identity
|
||||
APP_NAME: str = "Forecasting Service"
|
||||
SERVICE_NAME: str = "forecasting-service"
|
||||
DESCRIPTION: str = "Demand prediction and forecasting service"
|
||||
|
||||
# Database settings
|
||||
DATABASE_URL: str = os.getenv("DATABASE_URL", "postgresql+asyncpg://forecasting_user:forecasting_pass123@forecasting-db:5432/forecasting_db")
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("FORECASTING_DATABASE_URL",
|
||||
"postgresql+asyncpg://forecasting_user:forecasting_pass123@forecasting-db:5432/forecasting_db")
|
||||
|
||||
# Redis settings
|
||||
REDIS_URL: str = os.getenv("REDIS_URL", "redis://redis:6379/0")
|
||||
# Redis Database (dedicated for prediction cache)
|
||||
REDIS_DB: int = 2
|
||||
|
||||
# RabbitMQ settings
|
||||
RABBITMQ_URL: str = os.getenv("RABBITMQ_URL", "amqp://bakery:forecast123@rabbitmq:5672/")
|
||||
# Prediction Configuration
|
||||
MAX_FORECAST_DAYS: int = int(os.getenv("MAX_FORECAST_DAYS", "30"))
|
||||
MIN_HISTORICAL_DAYS: int = int(os.getenv("MIN_HISTORICAL_DAYS", "60"))
|
||||
PREDICTION_CONFIDENCE_THRESHOLD: float = float(os.getenv("PREDICTION_CONFIDENCE_THRESHOLD", "0.8"))
|
||||
|
||||
# Service URLs
|
||||
AUTH_SERVICE_URL: str = os.getenv("AUTH_SERVICE_URL", "http://auth-service:8000")
|
||||
# Caching Configuration
|
||||
PREDICTION_CACHE_TTL_HOURS: int = int(os.getenv("PREDICTION_CACHE_TTL_HOURS", "6"))
|
||||
FORECAST_BATCH_SIZE: int = int(os.getenv("FORECAST_BATCH_SIZE", "100"))
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
# Real-time Forecasting
|
||||
REALTIME_FORECASTING_ENABLED: bool = os.getenv("REALTIME_FORECASTING_ENABLED", "true").lower() == "true"
|
||||
FORECAST_UPDATE_INTERVAL_HOURS: int = int(os.getenv("FORECAST_UPDATE_INTERVAL_HOURS", "6"))
|
||||
|
||||
# Business Rules for Spanish Bakeries
|
||||
BUSINESS_HOUR_START: int = 7 # 7 AM
|
||||
BUSINESS_HOUR_END: int = 20 # 8 PM
|
||||
WEEKEND_ADJUSTMENT_FACTOR: float = float(os.getenv("WEEKEND_ADJUSTMENT_FACTOR", "0.8"))
|
||||
HOLIDAY_ADJUSTMENT_FACTOR: float = float(os.getenv("HOLIDAY_ADJUSTMENT_FACTOR", "0.5"))
|
||||
|
||||
# Weather Impact Modeling
|
||||
WEATHER_IMPACT_ENABLED: bool = os.getenv("WEATHER_IMPACT_ENABLED", "true").lower() == "true"
|
||||
TEMPERATURE_THRESHOLD_COLD: float = float(os.getenv("TEMPERATURE_THRESHOLD_COLD", "10.0"))
|
||||
TEMPERATURE_THRESHOLD_HOT: float = float(os.getenv("TEMPERATURE_THRESHOLD_HOT", "30.0"))
|
||||
RAIN_IMPACT_FACTOR: float = float(os.getenv("RAIN_IMPACT_FACTOR", "0.7"))
|
||||
|
||||
# Alert Thresholds
|
||||
HIGH_DEMAND_THRESHOLD: float = float(os.getenv("HIGH_DEMAND_THRESHOLD", "1.5"))
|
||||
LOW_DEMAND_THRESHOLD: float = float(os.getenv("LOW_DEMAND_THRESHOLD", "0.5"))
|
||||
STOCKOUT_RISK_THRESHOLD: float = float(os.getenv("STOCKOUT_RISK_THRESHOLD", "0.9"))
|
||||
|
||||
settings = Settings()
|
||||
settings = ForecastingSettings()
|
||||
|
||||
Reference in New Issue
Block a user