Stability-AI/generative-models · error · FileNotFoundError

Could not find SGM configs in {candidates}

Error message

Could not find SGM configs in {candidates}

What it means

get_configs_path locates the repository's configs/ directory by probing a list of candidate paths relative to the installed package. If none of the candidates exist (e.g. the sgm package was pip-installed without the configs directory, or run from an unexpected working directory) it raises FileNotFoundError listing the checked paths.

Source

Thrown at sgm/util.py:248

    return model


def get_configs_path() -> str:
    """
    Get the `configs` directory.
    For a working copy, this is the one in the root of the repository,
    but for an installed copy, it's in the `sgm` package (see pyproject.toml).
    """
    this_dir = os.path.dirname(__file__)
    candidates = (
        os.path.join(this_dir, "configs"),
        os.path.join(this_dir, "..", "configs"),
    )
    for candidate in candidates:
        candidate = os.path.abspath(candidate)
        if os.path.isdir(candidate):
            return candidate
    raise FileNotFoundError(f"Could not find SGM configs in {candidates}")


def get_nested_attribute(obj, attribute_path, depth=None, return_key=False):
    """
    Will return the result of a recursive get attribute call.
    E.g.:
        a.b.c
        = getattr(getattr(a, "b"), "c")
        = get_nested_attribute(a, "b.c")
    If any part of the attribute call is an integer x with current obj a, will
    try to call a[x] instead of a.x first.
    """
    attributes = attribute_path.split(".")
    if depth is not None and depth > 0:
        attributes = attributes[:depth]
    assert len(attributes) > 0, "At least one attribute should be selected"
    current_attribute = obj
    current_key = None

View on GitHub (pinned to e8cd657656)

Solutions

  1. Run the code from a full clone of the repository that includes the configs/ directory
  2. Copy the configs/ folder next to the sgm package so one of the candidate paths (this_dir/../configs) resolves
  3. Manually pass an explicit config path to whatever consumes get_configs_path instead of relying on auto-discovery

Example fix

// before
configs_root = get_configs_path()  # FileNotFoundError
// after
configs_root = "/path/to/repo/configs"  # or ensure configs/ exists at repo root
Defensive patterns

Strategy: validation

Validate before calling

import os
configs = os.path.abspath(os.path.join(os.path.dirname(sgm.__file__), "..", "configs"))
if not os.path.isdir(configs):
    raise RuntimeError("sgm configs/ missing; run from a full repo clone")

Type guard

def has_configs_dir(root: str) -> bool:
    return os.path.isdir(os.path.join(root, "configs"))

Try / catch

try:
    cfg_root = get_configs_path()
except FileNotFoundError as e:
    cfg_root = os.environ["SGM_CONFIGS_DIR"]  # explicit override

Prevention

When it happens

Trigger: Calling sgm.util.get_configs_path() when the sgm package is installed site-packages-style (configs/ not shipped), when the repo was checked out incompletely, or when relative candidate paths resolve incorrectly due to cwd/symlinks.

Common situations: Running scripts from an installed (pip/conda) copy of the library instead of the repo root; Docker images that copied only the sgm/ source but not the configs/ folder.

Related errors


AI-assisted analysis of Stability-AI/generative-models@e8cd657656 (2026-08-29). Data as JSON: /api/errors/34fe961e8d680fc5. Report an issue: GitHub.