Fix: strict multi-shard health checks (#27) — backport to 1.x; bump 1.1.1b1

Summary

- Backports the 2.0 strict health policy to 1.x and ships as a pre-release.

Health changes (cache_utils.py)

- Index-aware: validate safetensors and PyTorch indexes; all referenced shards must exist, be >0B, and not be Git LFS
pointers.
- Pattern policy: shard patterns (model-XXXXX-of-YYYYY.*) without an index → unhealthy (parity with 2.0).
- Partial/tmp markers: any “.partial”, “.tmp”, or names containing “partial” anywhere under the snapshot → unhealthy.
- LFS scan: recursive detection of Git LFS pointer files (<200B with LFS header).
- Single-file fallback: non-empty .safetensors/.bin/*.gguf (no pattern shards) remain healthy.
- Ergonomics: is_model_healthy() accepts direct snapshot paths; check_lfs_corruption() scans recursively.

Tests

- Add tests/unit/test_health_multishard.py covering:
    - index complete → healthy; missing/empty shard → unhealthy; LFS pointer → unhealthy
    - pattern shards (no index) → unhealthy
    - partial marker → unhealthy
    - PyTorch index parity (complete → healthy)
    - single-file safetensors/gguf → healthy

Docs

- CHANGELOG.md: add 1.1.1-beta.1 with detailed rules; note GitHub tag vs PyPI mapping (1.1.1-beta.1 ↔ 1.1.1b1).
- README.md: tests badge 160/160; pre-release note for 1.1.1b1.
- TESTING.md: status 160/160; update test structure (add test_health_multishard.py; remove 2.0 note).

Version

- version = 1.1.1b1 (PEP 440 pre-release); VERSION = (1, 1, 1).

Behavioral impact

- Health reporting is stricter (cannot regress functionality): incomplete multi-shard downloads correctly report
unhealthy. No changes to pull/run/server behavior.

Validation

- Python 3.9 local: 160 passed, 36 deselected; warnings eliminated on 3.9/3.10 under project defaults.
- New multishard tests pass; manual spot-checks show expected unhealthy→healthy transitions as downloads complete.

Release

- GitHub: tag v1.1.1-beta.1 (Pre-release).
- PyPI: upload 1.1.1b1 (install via pip install --pre mlx-knife).
This commit is contained in:
Local Test
2025-09-01 01:26:27 +02:00
parent f511dd9c74
commit b9db12ae89
6 changed files with 269 additions and 37 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ A lightweight, ollama-like CLI for managing and running MLX models on Apple Sili
> **Note**: MLX Knife is designed as a command-line interface tool only. While some internal functions are accessible via Python imports, only CLI usage is officially supported.
**Current Version**: 1.1.0 (August 2025) - **STABLE RELEASE** 🚀
- Pre-release: 1.1.1b1 — strict multi-shard health checks (Issue #27). Install with `pip install --pre mlx-knife`.
- **Production Ready**: First stable release since 1.0.4 with comprehensive testing
- **Enhanced Test System**: 150/150 tests passing with real model lifecycle integration tests
- **Python 3.9-3.13**: Full compatibility verified across all Python versions
@@ -21,7 +22,7 @@ A lightweight, ollama-like CLI for managing and running MLX models on Apple Sili
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![Apple Silicon](https://img.shields.io/badge/Apple%20Silicon-M1%2FM2%2FM3-green.svg)](https://support.apple.com/en-us/HT211814)
[![MLX](https://img.shields.io/badge/MLX-Latest-orange.svg)](https://github.com/ml-explore/mlx)
[![Tests](https://img.shields.io/badge/tests-150%2F150%20passing-brightgreen.svg)](#testing)
[![Tests](https://img.shields.io/badge/tests-160%2F160%20passing-brightgreen.svg)](#testing)
## Features