File size: 1,462 Bytes
3da88e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import json

import pytest

from h3_mlx.hub import sha256
from scripts.publish_hf_release import publish_component, verify_local


def test_partial_quantized_export_cannot_be_published(tmp_path):
    core = tmp_path / "model/core"
    core.mkdir(parents=True)
    file = core / "quantization.json"
    file.write_text(
        json.dumps(
            {
                "files": [
                    {
                        "file": f"core-{i:03d}.safetensors",
                        "bytes": 1,
                        "sha256": "a" * 64,
                    }
                    for i in range(52)
                ]
            }
        )
    )
    (tmp_path / "files.json").write_text(
        json.dumps(
            {
                "format": "h3-mlx-files-v1",
                "files": {
                    "model/core/quantization.json": {
                        "bytes": file.stat().st_size,
                        "sha256": sha256(file),
                    },
                },
            }
        )
    )
    with pytest.raises(ValueError, match="export/manifest mismatch"):
        verify_local(tmp_path)


def test_partial_packed_export_cannot_create_or_modify_a_repository(tmp_path):
    (tmp_path / "model/core").mkdir(parents=True)
    # No API method exists: an attempted remote mutation would fail this test.
    with pytest.raises(ValueError, match="fifty packed blocks"):
        publish_component(object(), "packed12", tmp_path)