Commit 676b142
DFlash loader: fail-fast on missing local path instead of silent HF fallback
Surfaces the bug the user hit on Mac mini 2026-06-09:
'failure 原因是默认 DRAFTER_ID=models/dflash-kakeya-baseline 被
当成 HF repo id 去下载,远端返回 404'
User ran:
SKIP_VERIFIER=1 PROPOSER_KV_CAPTURE=1 \
bash scripts/review_pr_k3_feasibility_on_mac.sh
Result: exit_code=25 (fail_at_drafter_load_skip_verifier), JSON
evidence shows HF Hub 404 on 'models/dflash-kakeya-baseline'.
Root cause:
inference_engine.v04.dflash_loader._resolve_local_dir was:
def _resolve_local_dir(repo_or_path, hf_kwargs):
p = Path(repo_or_path)
if p.exists() and p.is_dir():
return p
# NB: silent fallthrough — any non-existent local path
# gets sent to huggingface_hub.snapshot_download and 404s
return Path(snapshot_download(repo_id=repo_or_path, ...))
When the user's Mac mini didn't have 'models/dflash-kakeya-baseline'
on disk (likely because 'git lfs pull' hadn't run, or wrong cwd, or
worktree without the LFS-tracked checkpoint), the resolver silently
treated the path as a HF repo id and got 404 — far from the actual
root cause, which was a missing local file.
Fix:
Add a heuristic _looks_like_local_path() that returns True for inputs
starting with 'models/', './', '../', or '/' — the common project-
relative or absolute-path prefixes that distinguish a local path from
the canonical HF '<user_or_org>/<repo>' format.
In _resolve_local_dir, BEFORE falling through to HF Hub fetch:
1. If the input doesn't exist on disk AND looks like a local path
per the heuristic → raise FileNotFoundError with an actionable
message listing the three common causes (missing 'git lfs pull',
wrong cwd, wrong worktree) and how to confirm each.
2. Otherwise (HF-format input not on disk) → continue to HF Hub
snapshot_download as before. Pure HF repo ids unaffected.
Added regression tests:
TestLooksLikeLocalPath (4 tests)
- models/* prefix matched
- ./ + ../ relative prefixes matched
- /Users/... + /tmp/... absolute prefixes matched
- HF format (org/repo) NOT matched
TestResolveLocalDirFailFast (5 tests)
- existing local dir returned as-is
- missing 'models/...' raises FileNotFoundError with 'git lfs pull'
+ 'current working directory' in the message
- missing './ ...' / '../...' / '/tmp/...' all raise FileNotFoundError
- HF repo id (no local-path prefix) still flows through to
huggingface_hub.snapshot_download (verified via monkeypatch)
9/9 new tests pass. 319/319 v04 suite total.
Reviewer aid script (scripts/review_pr_k3_feasibility_on_mac.sh)
gets a 'pre-flight 0' check that fires BEFORE invoking Python:
case "$DRAFTER_ID" in
models/*|./*|../*|/*)
# if local path doesn't exist on disk → exit 1 with the same
# actionable message as the Python-side fail-fast
# if exists but missing config.json → exit 1 with file listing
esac
This means the next user run with the same misconfiguration:
- Fails at the bash pre-flight, NOT at HF Hub fetch
- Prints the three common causes + recovery commands directly
- Doesn't waste time on a 404 round-trip + Python-side error parse
Net effect:
Two layers of fail-fast (bash pre-flight + Python resolver) catch the
'local path doesn't exist' misconfiguration before it's mis-routed
to HF Hub. The user's exact 2026-06-09 failure mode now produces an
actionable error in <1 second with three concrete recovery paths,
instead of a 404 with 'models/dflash-kakeya-baseline' as a fake repo
id.
Tests: 319 passed (310 pre-existing + 9 new regression).
Stack: same as PR #98 (continuing on the same branch).
Scope: this PR's branch is now PR #98 + this fix. The fix is in
v0.4 K3 prereq 4 territory (the DFlash loader) and rightfully should
backport into PR #95 (K3 Block B prereqs 1+4) when the v04 stack
settles. Carrying it on PR #98's branch is the unblock path so the
user's next Mac mini run isn't blocked on a missing-local-path 404.
Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>1 parent a1263a5 commit 676b142
3 files changed
Lines changed: 183 additions & 1 deletion
File tree
- inference_engine/v04
- scripts
- tests/inference_engine/v04
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
146 | 173 | | |
147 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
148 | 183 | | |
149 | 184 | | |
150 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
151 | 204 | | |
152 | 205 | | |
153 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
127 | 168 | | |
128 | 169 | | |
129 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
368 | 370 | | |
369 | 371 | | |
370 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
0 commit comments