{"record":{"id":"34fe961e8d680fc5","repo":"Stability-AI/generative-models","slug":"could-not-find-sgm-configs-in-candidates","errorCode":null,"errorMessage":"Could not find SGM configs in {candidates}","messagePattern":"Could not find SGM configs in (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"sgm/util.py","lineNumber":248,"sourceCode":"    return model\n\n\ndef get_configs_path() -> str:\n    \"\"\"\n    Get the `configs` directory.\n    For a working copy, this is the one in the root of the repository,\n    but for an installed copy, it's in the `sgm` package (see pyproject.toml).\n    \"\"\"\n    this_dir = os.path.dirname(__file__)\n    candidates = (\n        os.path.join(this_dir, \"configs\"),\n        os.path.join(this_dir, \"..\", \"configs\"),\n    )\n    for candidate in candidates:\n        candidate = os.path.abspath(candidate)\n        if os.path.isdir(candidate):\n            return candidate\n    raise FileNotFoundError(f\"Could not find SGM configs in {candidates}\")\n\n\ndef get_nested_attribute(obj, attribute_path, depth=None, return_key=False):\n    \"\"\"\n    Will return the result of a recursive get attribute call.\n    E.g.:\n        a.b.c\n        = getattr(getattr(a, \"b\"), \"c\")\n        = get_nested_attribute(a, \"b.c\")\n    If any part of the attribute call is an integer x with current obj a, will\n    try to call a[x] instead of a.x first.\n    \"\"\"\n    attributes = attribute_path.split(\".\")\n    if depth is not None and depth > 0:\n        attributes = attributes[:depth]\n    assert len(attributes) > 0, \"At least one attribute should be selected\"\n    current_attribute = obj\n    current_key = None","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/Stability-AI/generative-models/blob/e8cd657656fa5d61688191730d0e03242bf4ed44/sgm/util.py#L230-L266","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the code from a full clone of the repository that includes the configs/ directory","Copy the configs/ folder next to the sgm package so one of the candidate paths (this_dir/../configs) resolves","Manually pass an explicit config path to whatever consumes get_configs_path instead of relying on auto-discovery"],"exampleFix":"// before\nconfigs_root = get_configs_path()  # FileNotFoundError\n// after\nconfigs_root = \"/path/to/repo/configs\"  # or ensure configs/ exists at repo root","handlingStrategy":"validation","validationCode":"import os\nconfigs = os.path.abspath(os.path.join(os.path.dirname(sgm.__file__), \"..\", \"configs\"))\nif not os.path.isdir(configs):\n    raise RuntimeError(\"sgm configs/ missing; run from a full repo clone\")","typeGuard":"def has_configs_dir(root: str) -> bool:\n    return os.path.isdir(os.path.join(root, \"configs\"))","tryCatchPattern":"try:\n    cfg_root = get_configs_path()\nexcept FileNotFoundError as e:\n    cfg_root = os.environ[\"SGM_CONFIGS_DIR\"]  # explicit override","preventionTips":["Ship configs/ in Docker images and packages","Run from the repo root or full clone","Allow an env-var override for the configs location"],"tags":["python","file-not-found","packaging","config"],"backgroundTag":"missing-resource-file","analyzedSha":"e8cd657656fa5d61688191730d0e03242bf4ed44","analyzedAt":"2026-08-29T11:23:43.234Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}