贡献 / #424
#424 fix(setup): drop an engine archive that fails to unpack
closed · @alphastorm · 0 评论 · 去 GitHub 看
Setup & installServer & APIModels & quantsWindows
说明
Follow-up to #399, which was closed as covered by 0.1.32. 0.1.32's `drop_archive` does cover #397's refused archives. One case from #399 is still open at `aeb35be` (0.1.33): an archive that fails to unpack.
When the downloaded engine archive is not a zip, or is a damaged one, `get_prebuilt` raises `BadZipFile` but keeps `engine/<asset>` and its `.done` mark. `download()` trusts the mark, so every later run prints "Strata engine already downloaded" and fails on the same file. This goes on after the right archive is published, until someone deletes the file by hand. On the update path the caller catches the error ("updating the engine failed (File is not a zip file)") and starts the installed engine, so the engine is never updated.
**Change**
- `setup.py` (`get_prebuilt`): on `zipfile.BadZipFile` from unpacking, the archive and its mark are dropped (`drop_archive`), and the error propagates as before. An `OSError` while unpacking (a full disk, a path that is too long) still keeps the archive, because downloading it again would not help.
**Behavior changes**
- The run that meets the bad archive fails as before (`BadZipFile`). The next run downloads the archive again instead of failing on the same file.
**Tests** (`python -m unittest tools.test_setup_pins`, no network)
- `Engine.test_an_archive_that_does_not_unpack_is_not_kept` runs `get_prebuilt` with the real `download()` over a `--prebuilt` folder. The folder first holds a file that is not a zip, then the right archive. On `aeb35be` the second run raises `BadZipFile` again. With the change, the second run installs the engine.
- I ran every Python test module (`serve/test_*.py`, `tools/test_*.py`: 27 modules, 346 tests, 9 skipped) with and without the change, with `STRATA_GGUF_PY` set for `tools.test_iq_pack`. The results are the same, except for the new test, which errors without the change. `tools.test_setup_golden` fails the same 46 subtests in both runs. The cause is on non-Windows hosts: there `EXE` is `strata`, so the test's path normalization also turns the log name `strata-<quant>.log` into `<EXE>-<quant>.log`. These runs used Python 3.13.15 on macOS arm64. ruff and pyright report nothing new in the changed files.
**Also checked**
- The update path over a local HTTP server standing in for GitHub releases (`PREBUILT_URL` and `PREBUILT_TAG_URL` patched, real `download()`). The release first serves an HTML page, then the right archive. On `aeb35be`, every run after the first sends one `HEAD`, prints "Strata engine already downloaded" and fails with `BadZipFile`. With the change, the next run downloads and installs the engine, and the run after that sends no request.
Not run: Windows, a GPU, or a real release download.
本站相关内容
相关页面的快捷入口。