hm_video_ai_qc_tool/config.py
2025-12-31 12:59:50 +02:00

77 lines
2.5 KiB
Python

"""
Environment configuration for HM Video QC system.
Set environment variable HM_VIDEO_QC_ENV to control which environment to use:
- export HM_VIDEO_QC_ENV=dev # Development environment
- export HM_VIDEO_QC_ENV=production # Production environment (default)
Development uses relative paths from the repository root.
Production uses absolute paths at /opt/QC.
"""
import os
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
# Detect environment from environment variable (defaults to production)
ENVIRONMENT = os.getenv('HM_VIDEO_QC_ENV', 'production').lower()
# Get the repository root directory (where this config.py file is located)
REPO_ROOT = os.path.dirname(os.path.abspath(__file__))
# Environment-specific path configuration
if ENVIRONMENT == 'dev':
# Development environment - use relative paths from repo
BASE_DIR = REPO_ROOT
PROFILES_DIR = os.path.join(BASE_DIR, 'profiles')
CHECKS_DIR = os.path.join(BASE_DIR, 'checks')
WORKING_DIR = os.path.join(BASE_DIR, 'tmp', 'HM_video_working')
REPORTS_DIR = os.path.join(BASE_DIR, 'tmp', 'reports')
SUPPORTING_DIR = os.path.join(BASE_DIR, 'supporting')
else:
# Production environment - use absolute paths
BASE_DIR = '/opt/hm_qc_video'
PROFILES_DIR = '/opt/hm_qc_video/profiles'
CHECKS_DIR = '/opt/hm_qc_video/checks'
WORKING_DIR = '/tmp/HM_video_working'
REPORTS_DIR = '/opt/hm_qc_video/reports'
SUPPORTING_DIR = '/opt/hm_qc_video/supporting'
# Profile paths
VIDEO_PROFILE_PATH = os.path.join(PROFILES_DIR, 'HM_video.json')
# Ensure working and reports directories exist in dev mode
if ENVIRONMENT == 'dev':
os.makedirs(WORKING_DIR, exist_ok=True)
os.makedirs(REPORTS_DIR, exist_ok=True)
def get_config():
"""
Returns a dictionary with all configuration values.
Useful for debugging and logging.
"""
return {
'environment': ENVIRONMENT,
'base_dir': BASE_DIR,
'profiles_dir': PROFILES_DIR,
'checks_dir': CHECKS_DIR,
'working_dir': WORKING_DIR,
'reports_dir': REPORTS_DIR,
'supporting_dir': SUPPORTING_DIR,
'video_profile_path': VIDEO_PROFILE_PATH,
}
def print_config():
"""
Prints the current configuration.
Useful for debugging environment setup.
"""
config = get_config()
print(f"\n{'='*60}")
print(f"HM Video QC Environment Configuration")
print(f"{'='*60}")
for key, value in config.items():
print(f"{key:20s}: {value}")
print(f"{'='*60}\n")