Spaces:
Runtime error
Runtime error
| """ | |
| Configuration management module | |
| Load settings from environment variables and config files | |
| """ | |
| import os | |
| from pathlib import Path | |
| from dotenv import load_dotenv | |
| # Project root directory | |
| PROJECT_ROOT = Path(__file__).parent.parent.absolute() | |
| # Load environment variables | |
| load_dotenv(PROJECT_ROOT / ".env") | |
| class Settings: | |
| """Application configuration""" | |
| # OpenAI configuration | |
| OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") | |
| OPENAI_BASE_URL = os.getenv("OPENAI_BASE_URL", "https://api.openai.com/v1") | |
| OPENAI_MODEL = os.getenv("OPENAI_MODEL", "gpt-4o-mini") | |
| # Blender configuration | |
| BLENDER_PATH = os.getenv( | |
| "BLENDER_PATH", | |
| "/Applications/Blender.app/Contents/MacOS/Blender" | |
| ) | |
| # Path configuration | |
| INFINIGEN_ROOT = PROJECT_ROOT | |
| BACKEND_DIR = PROJECT_ROOT / "infinigen_examples" | |
| OUTPUT_DIR = PROJECT_ROOT / "outputs" / "indoors" / "coarse" | |
| CONFIG_OUTPUT = PROJECT_ROOT / "config" / "generated_config.yaml" | |
| BACKEND_CONFIG = PROJECT_ROOT / "infinigen_examples" / "constraints" / "configuration.yaml" | |
| # Generation parameters | |
| DEFAULT_SEED = 0 | |
| SHARE_GRADIO = os.getenv("GRADIO_SHARE", "true").lower() == "true" | |
| def validate(cls): | |
| """Validate required configuration""" | |
| errors = [] | |
| if not cls.OPENAI_API_KEY: | |
| errors.append("OPENAI_API_KEY not set in .env") | |
| if not Path(cls.BLENDER_PATH).exists(): | |
| errors.append(f"Blender not found at {cls.BLENDER_PATH}") | |
| if errors: | |
| raise ValueError(f"Configuration errors:\n" + "\n".join(f" - {e}" for e in errors)) | |
| return True | |
| settings = Settings() | |