Skip to content

Config

Pydantic schemas and constants that gate every configs/ablations/*.jsonnet render before it reaches build_run. See also Config system for the runtime flow.

graphids.config.schemas

schemas

Pydantic schemas for structural validation of rendered jsonnet configs.

CallbacksSection

Bases: BaseModel

Forced-callback block. Cross-field validator keeps checkpoint and early_stopping tracking the same (monitor, mode) so a best-epoch ckpt matches the stop trigger.

ConfigValidationError

Bases: ValueError

Raised by :func:validate_config when the rendered dict fails any Pydantic check. Wraps Pydantic's ValidationError so callers can catch one exception type regardless of which rule fired.

ValidatedConfig

Bases: BaseModel

The rendered-config contract. extra="forbid" at the top level catches typos in configs/ablations/*.jsonnet; nested TrainerSection stays permissive so Lightning trainer kwargs pass through unchecked.

validate_config

validate_config(rendered: dict[str, Any]) -> ValidatedConfig

Validate a rendered jsonnet dict before any torch import.

Called by ResolvedConfig.from_rendered immediately after :func:graphids.config.jsonnet.render. Fails fast on null list fields, monitor/mode mismatches, un-namespaced class_path strings, and LearningRateMonitor without a logger.

Raises:

Type Description
ConfigValidationError

any validation failure, with the Pydantic error text preserved as the message.

Source code in graphids/config/schemas.py
def validate_config(rendered: dict[str, Any]) -> ValidatedConfig:
    """Validate a rendered jsonnet dict before any torch import.

    Called by ``ResolvedConfig.from_rendered`` immediately after
    :func:`graphids.config.jsonnet.render`. Fails fast on null list
    fields, monitor/mode mismatches, un-namespaced ``class_path`` strings,
    and ``LearningRateMonitor`` without a logger.

    Raises:
        ConfigValidationError: any validation failure, with the Pydantic
            error text preserved as the message.
    """
    try:
        return ValidatedConfig.model_validate(rendered)
    except Exception as e:
        raise ConfigValidationError(str(e)) from e