mirror of
https://github.com/exo-explore/exo.git
synced 2026-06-26 14:45:50 -04:00
18 lines
460 B
Python
18 lines
460 B
Python
import logging
|
|
import os
|
|
from typing import TypeVar
|
|
|
|
from pydantic import BaseModel, ValidationError
|
|
|
|
EnvSchema = TypeVar("EnvSchema", bound=BaseModel)
|
|
|
|
|
|
def get_validated_env(
|
|
environment_schema: type[EnvSchema], logger: logging.Logger
|
|
) -> EnvSchema:
|
|
try:
|
|
return environment_schema.model_validate(os.environ, strict=True)
|
|
except ValidationError as e:
|
|
logger.error("Environment Variables Validation Failed: %s", e)
|
|
raise e
|