Spaces:
Paused
Paused
Download shared/config.py from VAH6002/ai_data_scientist: direct link, hf CLI and curl.
- Browser
- Download file 3.38 kB
-
https://huggingface.co/spaces/VAH6002/ai_data_scientist/resolve/main/shared/config.py
- Command line
-
hf download hf://spaces/VAH6002/ai_data_scientist/shared/config.py
-
curl -L -o config.py https://huggingface.co/spaces/VAH6002/ai_data_scientist/resolve/main/shared/config.py
3.38 kB
| """ | |
| Configuration management for the MCP AI Data Scientist system. | |
| Handles environment variables and application settings. | |
| """ | |
| import os | |
| from typing import Optional | |
| from pydantic import Field | |
| from pydantic_settings import BaseSettings | |
| from dotenv import load_dotenv | |
| # Load environment variables from .env file | |
| load_dotenv() | |
| class Settings(BaseSettings): | |
| """Application settings loaded from environment variables.""" | |
| # Gemini API Configuration | |
| gemini_api_key: str = Field("", env="GEMINI_API_KEY") | |
| # Clerk Authentication | |
| clerk_secret_key: str = Field("", env="CLERK_SECRET_KEY") | |
| clerk_publishable_key: str = Field("", env="CLERK_PUBLISHABLE_KEY") | |
| # Supabase Configuration | |
| supabase_url: str = Field("", env="SUPABASE_URL") | |
| supabase_anon_key: str = Field("", env="SUPABASE_ANON_KEY") | |
| supabase_service_role_key: str = Field("", env="SUPABASE_SERVICE_ROLE_KEY") | |
| # Database Configuration | |
| database_url: str = Field("", env="DATABASE_URL") | |
| # MCP Server Ports | |
| data_cleaning_mcp_port: int = Field(3001, env="DATA_CLEANING_MCP_PORT") | |
| hypothesis_testing_mcp_port: int = Field(3002, env="HYPOTHESIS_TESTING_MCP_PORT") | |
| preprocessing_mcp_port: int = Field(3003, env="PREPROCESSING_MCP_PORT") | |
| feature_engineering_mcp_port: int = Field(3004, env="FEATURE_ENGINEERING_MCP_PORT") | |
| model_training_mcp_port: int = Field(3005, env="MODEL_TRAINING_MCP_PORT") | |
| action_generation_mcp_port: int = Field(3006, env="ACTION_GENERATION_MCP_PORT") | |
| # FastAPI Configuration | |
| fastapi_host: str = Field("0.0.0.0", env="FASTAPI_HOST") | |
| fastapi_port: int = Field(8000, env="FASTAPI_PORT") | |
| fastapi_debug: bool = Field(False, env="FASTAPI_DEBUG") | |
| # Streamlit Configuration | |
| streamlit_host: str = Field("0.0.0.0", env="STREAMLIT_HOST") | |
| streamlit_port: int = Field(8501, env="STREAMLIT_PORT") | |
| # File Storage | |
| upload_dir: str = Field("./uploads", env="UPLOAD_DIR") | |
| max_file_size_mb: int = Field(100, env="MAX_FILE_SIZE_MB") | |
| # Logging | |
| log_level: str = Field("INFO", env="LOG_LEVEL") | |
| log_file: str = Field("./logs/app.log", env="LOG_FILE") | |
| class Config: | |
| env_file = ".env" | |
| case_sensitive = False | |
| # Global settings instance | |
| settings = Settings() | |
| def get_mcp_server_url(server_name: str) -> str: | |
| """Get the URL for a specific MCP server.""" | |
| port_mapping = { | |
| "data_cleaning": settings.data_cleaning_mcp_port, | |
| "hypothesis_testing": settings.hypothesis_testing_mcp_port, | |
| "preprocessing": settings.preprocessing_mcp_port, | |
| "feature_engineering": settings.feature_engineering_mcp_port, | |
| "model_training": settings.model_training_mcp_port, | |
| "action_generation": settings.action_generation_mcp_port, | |
| } | |
| port = port_mapping.get(server_name) | |
| if not port: | |
| raise ValueError(f"Unknown MCP server: {server_name}") | |
| return f"http://localhost:{port}" | |
| def ensure_directories(): | |
| """Ensure required directories exist.""" | |
| directories = [ | |
| settings.upload_dir, | |
| os.path.dirname(settings.log_file), | |
| ] | |
| for directory in directories: | |
| if directory and not os.path.exists(directory): | |
| os.makedirs(directory, exist_ok=True) |