Skip to content

Cookbook: custom modelDirs with HF hub layout (models--) are not listed by /api/model/cached #5507

Description

@kydno

Prerequisites

  • I searched open issues and discussions and did not find an existing report of this bug.
  • This is not a security vulnerability. (Vulnerabilities go to GitHub Security Advisories — see SECURITY.md.)
  • I am running the latest code from the dev branch (the default branch you get on clone, where fixes land first) and the bug still reproduces there. Please git pull the latest dev before filing.

Install Method

Manual Python install (pip / venv)

Operating System

Linux

Steps to Reproduce

  1. Configure a Cookbook custom model directory that contains a HuggingFace hub cache layout, e.g. <modelDir>/models--Org--Name/... or <modelDir>/hub/models--Org--Name/... (the layout produced when downloads use HF_HOME / HUGGINGFACE_HUB_CACHE against a custom dir).
  2. Call GET /api/model/cached?model_dir=<that path> (or refresh Cached Models in the Serve/Launch UI for that server).
  3. Observe the returned model list.

Deterministic unit-level repro against _cached_model_scan_script:

  • Point model_dir at a folder whose children are models--*0 models.
  • Point model_dir at a parent that contains hub/models--* → one entry with repo_id: hub (unusable).
  • Pass the same hub path via add_hf_cache= → correctly lists Org/Name.
  • Flat folders (MyModel/config.json) still work.

Expected Behaviour

HF hub-layout caches under configured modelDirs should be discovered as org/name models, same as ~/.cache/huggingface/hub.

Actual Behaviour

scan_dir in routes/cookbook_helpers.py explicitly skips top-level models--* entries. /api/model/cached only calls _cached_model_scan_script(model_dirs) and never passes add_hf_cache, so custom dirs with standard HF layout are missed or mislabeled.

Logs / Screenshots

Reproduced on dev with a temp hub layout: hub-as-model_dir → count=0; parent-with-hub → repo_id='hub'; add_hf_cacheQwen/Qwen3-8B.

Model / Backend (if relevant)

Cookbook / HuggingFace hub cache

Are you willing to submit a fix?

Yes

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready for reviewDescription complete — ready for maintainer review

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions