Spaces:
Paused
Paused
Download config.py from igardner/StockAnalysis: direct link, hf CLI and curl.
- Browser
- Download file 4.42 kB
-
https://huggingface.co/spaces/igardner/StockAnalysis/resolve/main/config.py
- Command line
-
hf download hf://spaces/igardner/StockAnalysis/config.py
-
curl -L -o config.py https://huggingface.co/spaces/igardner/StockAnalysis/resolve/main/config.py
4.42 kB
| import os | |
| import logging | |
| import json | |
| class Config: | |
| SECRET_KEY = os.environ.get("SECRET_KEY", "dev-secret-key-change-me") | |
| BASE_DIR = os.path.abspath(os.path.dirname(__file__)) | |
| # HF Spaces mounts its persistent volume at /data. Keep local development | |
| # usable when that mount is absent or not writable. | |
| _hf_data_dir = "/data" | |
| if not os.path.isdir(_hf_data_dir) or not os.access(_hf_data_dir, os.W_OK): | |
| _hf_data_dir = os.path.join(BASE_DIR, "data") | |
| DATA_DIR = os.environ.get("DATA_DIR", _hf_data_dir) | |
| LEGACY_DATABASE_PATH = os.path.join(BASE_DIR, "instance", "app.db") | |
| SQLALCHEMY_DATABASE_URI = os.environ.get( | |
| "DATABASE_URL", | |
| "sqlite:///" + os.path.join(DATA_DIR, "app.db"), | |
| ) | |
| SQLALCHEMY_TRACK_MODIFICATIONS = False | |
| SQLALCHEMY_ECHO = False | |
| SQLALCHEMY_ENGINE_OPTIONS = ( | |
| {"connect_args": {"timeout": 30}} | |
| if SQLALCHEMY_DATABASE_URI.startswith("sqlite:") else {} | |
| ) | |
| MAX_CONTENT_LENGTH = 16 * 1024 * 1024 | |
| AUTO_CREATE_MIN_PLAYERS = 5 | |
| MAX_PLAYERS_DEFAULT = 15 | |
| MIN_PLAYERS_DEFAULT = 5 | |
| DEFAULT_GAME_TYPE = os.environ.get("DEFAULT_GAME_TYPE", "parlor_mystery") | |
| try: | |
| GAME_SETTINGS = json.loads(os.environ.get("GAME_SETTINGS_JSON", "{}")) | |
| if not isinstance(GAME_SETTINGS, dict): | |
| GAME_SETTINGS = {} | |
| except ValueError: | |
| GAME_SETTINGS = {} | |
| # The current shared Space intentionally has a small simulated guest pool. | |
| # Set TEST_MODE=false to disable it; account creation is hard-capped below. | |
| TEST_MODE = os.environ.get("TEST_MODE", "true").lower() in ("true", "1", "yes") | |
| TEST_BOT_MAX_ACCOUNTS = 10 | |
| TEST_BOT_COUNT = TEST_BOT_MAX_ACCOUNTS | |
| TEST_BOT_CHAT_INTERVAL = max(30, int(os.environ.get("TEST_BOT_CHAT_INTERVAL", "60"))) | |
| MATCHMAKING_MIN_WORDS = max(1, int(os.environ.get("MATCHMAKING_MIN_WORDS", "3"))) | |
| MATCHMAKING_MIN_PLAYERS = int(os.environ.get("MATCHMAKING_MIN_PLAYERS", "5")) | |
| LOBBY_ROUND_SECONDS = int(os.environ.get("LOBBY_ROUND_SECONDS", "35")) | |
| LOBBY_CHAT_GENERATION_TOKEN = os.environ.get("LOBBY_CHAT_GENERATION_TOKEN", "") | |
| LOBBY_CHAT_API_URL = os.environ.get("LOBBY_CHAT_API_URL", "") | |
| LOBBY_CHAT_MODEL = os.environ.get("LOBBY_CHAT_MODEL", "") | |
| LOBBY_CHAT_API_KEY = os.environ.get("LOBBY_CHAT_API_KEY", "") | |
| AVATAR_STYLES_CC0 = [ | |
| "adventurer", | |
| "adventurer-neutral", | |
| "avataaars", | |
| "avataaars-neutral", | |
| "big-ears", | |
| "big-ears-neutral", | |
| "big-smile", | |
| "bottts", | |
| "bottts-neutral", | |
| "croodles", | |
| "croodles-neutral", | |
| "fun-emoji", | |
| "icons", | |
| "identicon", | |
| "initials", | |
| "lorelei", | |
| "lorelei-neutral", | |
| "micah", | |
| "miniavs", | |
| "open-peeps", | |
| "personas", | |
| "pixel-art", | |
| "pixel-art-neutral", | |
| "rings", | |
| "shapes", | |
| "thumbs", | |
| ] | |
| AVATAR_BACKGROUNDS = ["transparent", "b6e3f4", "c0aede", "d1d4f9", "ffd5dc", "ffdfbf"] | |
| TELEMETRY_ENABLED = True | |
| PUBLIC_LOBBY_ENABLED = True | |
| INSTANCE_PATH = os.path.join(BASE_DIR, "instance") | |
| RESULTS_DIR = "/data/hf-inference-smoke" | |
| def ensure_data_dir(): | |
| os.makedirs(Config.INSTANCE_PATH, exist_ok=True) | |
| os.makedirs(Config.DATA_DIR, exist_ok=True) | |
| target = os.path.join(Config.DATA_DIR, "app.db") | |
| # Never silently import a different historical dataset. If the active | |
| # target is absent, SQLAlchemy creates a new empty database at startup. | |
| if not os.environ.get("DATABASE_URL") and not os.path.exists(target): | |
| logging.getLogger(__name__).warning( | |
| "DATABASE_NEW_FILE path=%s legacy_ignored=%s", | |
| target, | |
| os.path.isfile(Config.LEGACY_DATABASE_PATH), | |
| ) | |
| elif ( | |
| not os.environ.get("DATABASE_URL") | |
| and os.path.isfile(target) | |
| and os.path.isfile(Config.LEGACY_DATABASE_PATH) | |
| and os.path.abspath(target) != os.path.abspath(Config.LEGACY_DATABASE_PATH) | |
| ): | |
| logging.getLogger(__name__).warning( | |
| "DATABASE_MULTIPLE_FILES active=%s active_bytes=%s legacy_ignored=%s legacy_bytes=%s", | |
| target, | |
| os.path.getsize(target), | |
| Config.LEGACY_DATABASE_PATH, | |
| os.path.getsize(Config.LEGACY_DATABASE_PATH), | |
| ) | |