import os import json from pathlib import Path APP_ENV = os.getenv("APP_ENV", "dev").lower() DEV_PARQUET_URI = os.getenv( "DEV_PARQUET_URI", "/Users/wlt/Downloads/slow-query/1.parquet", ) # Optional endpoint/url_style if needed in prod; empty by default # Prefer template form to avoid hardcoding region S3_ENDPOINT_TEMPLATE = os.getenv("S3_ENDPOINT_TEMPLATE", "") S3_URL_STYLE = os.getenv("S3_URL_STYLE", "") LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO") LOG_CRED_DEBUG = os.getenv("LOG_CRED_DEBUG", "true").lower() in ("true", "1", "yes") # Load service-side config.json (auth_url, github_token, optional endpoint/url_style) CONFIG_PATH = Path(__file__).resolve().parents[2] / "config.json" _RAW_CONFIG = {} if CONFIG_PATH.exists(): try: _RAW_CONFIG = json.loads(CONFIG_PATH.read_text()) except Exception: _RAW_CONFIG = {} S3_AUTH_URL = _RAW_CONFIG.get("s3", {}).get("auth_url", "") GITHUB_TOKEN = _RAW_CONFIG.get("s3", {}).get("github_token", "") # Prefer endpoint_template; fallback: if legacy 'endpoint' contains '{region}', treat it as template if not S3_ENDPOINT_TEMPLATE: tpl = _RAW_CONFIG.get("s3", {}).get("endpoint_template", "") if tpl: S3_ENDPOINT_TEMPLATE = tpl else: legacy = _RAW_CONFIG.get("s3", {}).get("endpoint", "") if legacy and "{region}" in legacy: S3_ENDPOINT_TEMPLATE = legacy if not S3_URL_STYLE: S3_URL_STYLE = _RAW_CONFIG.get("s3", {}).get("url_style", "") # Alicloud static credentials (prefer env, fallback to config.json) ALICLOUD_ACCESS_KEY = os.getenv("ALICLOUD_ACCESS_KEY") or _RAW_CONFIG.get("alicloud", {}).get("access_key", "") ALICLOUD_SECRET_KEY = os.getenv("ALICLOUD_SECRET_KEY") or _RAW_CONFIG.get("alicloud", {}).get("secret_key", "") ALICLOUD_ENDPOINT_TEMPLATE = os.getenv("ALICLOUD_ENDPOINT_TEMPLATE") or _RAW_CONFIG.get("alicloud", {}).get("endpoint_template", "") ALICLOUD_URL_STYLE = os.getenv("ALICLOUD_URL_STYLE") or _RAW_CONFIG.get("alicloud", {}).get("url_style", "")