Skip to content

Settings

Every GRAPHIDS_* environment variable is typed on GraphIDSSettings and read once via get_settings(). Adding a new env var means adding a field here — no scattered os.environ.get().

graphids.config.settings

settings

Centralized environment settings via pydantic-settings.

Single source of truth for all GRAPHIDS_* environment variables. Typed, validated, read once at first access via get_settings().

GraphIDSSettings

Bases: BaseSettings

All GRAPHIDS_* env vars — typed, with defaults.

LakeWriteError

Bases: PermissionError

Raised when a lake-writing operation runs without GRAPHIDS_LAKE_WRITE=1. Gate against accidental writes from login-node smoke runs or from interactive sessions.

get_settings cached

get_settings() -> GraphIDSSettings

Lazy singleton — reads environment on first call, caches thereafter.

Source code in graphids/config/settings.py
@lru_cache(maxsize=1)
def get_settings() -> GraphIDSSettings:
    """Lazy singleton — reads environment on first call, caches thereafter."""
    return GraphIDSSettings()

require_lake_write

require_lake_write() -> None

Guard called by lake-writing code paths. Raises :class:LakeWriteError unless GRAPHIDS_LAKE_WRITE=1 is set — SLURM jobs get this from .env via scripts/slurm/_preamble.sh.

Source code in graphids/config/settings.py
def require_lake_write() -> None:
    """Guard called by lake-writing code paths. Raises
    :class:`LakeWriteError` unless ``GRAPHIDS_LAKE_WRITE=1`` is set —
    SLURM jobs get this from ``.env`` via ``scripts/slurm/_preamble.sh``.
    """
    if not get_settings().lake_write:
        raise LakeWriteError(
            "Lake write blocked: set GRAPHIDS_LAKE_WRITE=1 "
            "(SLURM jobs get this from .env via _preamble.sh)"
        )