File size: 1,834 Bytes
f8cab22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
from pathlib import Path
import json
import re

root = Path(__file__).resolve().parents[1]
readme = (root / "README.md").read_text(encoding="utf-8")
index = (root / "index.html").read_text(encoding="utf-8")

required = [
    root / "README.md",
    root / "index.html",
    root / "LICENSE",
    root / "assets/graph-classifier-map.png",
    root / "data/classification-network.json",
    root / "data/classification-network.graphml",
    root / "data/scenario-summary.json",
]

for path in required:
    if not path.is_file() or path.stat().st_size == 0:
        raise SystemExit(f"FAIL: missing or empty file: {path}")

assert "sdk: static" in readme
assert "app_file: index.html" in readme

short_description = next(
    line.split(":", 1)[1].strip()
    for line in readme.splitlines()
    if line.startswith("short_description:")
)
assert len(short_description) <= 60, (
    f"short_description is {len(short_description)} characters; "
    "maximum is 60"
)
assert "GraphShieldMistral interactive policy-graph explorer" in index
assert '<script src=' not in index
assert 'rel="stylesheet"' not in index

node_count = len(re.findall(r'data-node-id="', index))
scenario_count = len(re.findall(r'data-node-id="DOC[0-9]+"', index))
assert node_count >= 90, node_count
assert scenario_count == 5, scenario_count

payload = json.loads(
    (root / "data/classification-network.json").read_text(
        encoding="utf-8"
    )
)
assert len(payload["nodes"]) >= 90
assert len(payload["edges"]) >= 78

print("PASS: self-contained static HTML")
print(f"PASS: graph nodes in HTML: {node_count}")
print(f"PASS: recorded scenarios: {scenario_count}")
print(f"PASS: exported nodes: {len(payload['nodes'])}")
print(f"PASS: exported edges: {len(payload['edges'])}")
print("PASS: GraphShieldMistral static Space package")