MCPcopy Create free account
hub / github.com/HumeAI/hume-api-examples / validate_env_vars

Function validate_env_vars

tts/tts-python-livekit/src/utils.py:9–26  ·  view source on GitHub ↗

Load environment variables from .env, then ensure all required variables are set. If any are missing, raise a RuntimeError with a helpful message pointing to .env.example.

(env_vars: list[str])

Source from the content-addressed store, hash-verified

7from dotenv import load_dotenv
8
9def validate_env_vars(env_vars: list[str]) -> None:
10 """
11 Load environment variables from .env, then ensure all required variables are set.
12 If any are missing, raise a RuntimeError with a helpful message pointing to .env.example.
13 """
14 # Load from .env into environment
15 load_dotenv(override=True)
16
17 # Check which vars are missing
18 missing = [var for var in env_vars if os.getenv(var) is None]
19 if missing:
20 raise RuntimeError(
21 "Missing required environment variables: "
22 + ", ".join(missing)
23 + "\n\nPlease create a .env file in the project root "
24 + "based on .env.example and fill in the values:\n\n"
25 + "\n".join(f" {var}=" for var in missing)
26 )

Callers 2

main.pyFile · 0.90
main.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected