Files
OpenMontage/lib/env_loader.py
calesthio a3e735cc7a Initial release — OpenMontage: the first open-source agentic video production system
11 production pipelines, 47 tools, 124 agent skills.
Supports cloud APIs (fal.ai, OpenAI, ElevenLabs, Suno, HeyGen, Runway) and
free local providers (diffusers, Piper TTS, WAN 2.1, Hunyuan, CogVideo).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 08:25:17 -07:00

35 lines
977 B
Python

"""Environment variable loader for OpenMontage.
Loads .env file and provides typed access to environment configuration.
"""
from __future__ import annotations
import os
from pathlib import Path
from typing import Optional
from dotenv import load_dotenv
def load_env(project_root: Optional[Path] = None) -> None:
"""Load .env file from project root."""
if project_root is None:
project_root = Path(__file__).resolve().parent.parent
env_path = project_root / ".env"
if env_path.exists():
load_dotenv(env_path)
def get_env(key: str, default: Optional[str] = None) -> Optional[str]:
"""Get an environment variable with optional default."""
return os.environ.get(key, default)
def require_env(key: str) -> str:
"""Get a required environment variable. Raises if missing."""
value = os.environ.get(key)
if value is None:
raise EnvironmentError(f"Required environment variable {key!r} is not set")
return value