from __future__ import annotations import importlib import re import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] README = (ROOT / "README.md").read_text() SRC = ROOT / "src" sys.path.insert(0, str(SRC)) inferscale = importlib.import_module("inferscale") __version__ = inferscale.__version__ design_space_search = inferscale.design_space_search run_simulation = inferscale.run_simulation errors: list[str] = [] match = re.search(r"^short_description:\s*(.+)$", README, re.MULTILINE) if not match: errors.append("README metadata is missing short_description") short = "" else: short = match.group(1).strip().strip('"\'') if len(short) > 60: errors.append(f"short_description is {len(short)} chars; HF limit is 60") if "sdk: static" not in README: errors.append("README metadata must use sdk: static") if __version__ != "0.3.0": errors.append(f"package version is {__version__}; expected 0.3.0") src_files = sorted((ROOT / "src" / "inferscale").glob("*.py")) web_files = sorted((ROOT / "py" / "inferscale").glob("*.py")) if [path.name for path in src_files] != [path.name for path in web_files]: errors.append("browser Python mirror is stale; run python scripts/sync_web_python.py") else: for src, web in zip(src_files, web_files, strict=True): if src.read_bytes() != web.read_bytes(): errors.append(f"browser mirror differs for {src.name}; run sync_web_python.py") worker_text = (ROOT / "worker.mjs").read_text() for src in src_files: if f'"{src.name}"' not in worker_text: errors.append(f"worker module list is missing {src.name}") for ui_file in (ROOT / "index.html", ROOT / "app.js"): try: ui_file.read_text().encode("ascii") except UnicodeEncodeError: errors.append(f"{ui_file.name} contains non-ASCII UI glyphs; use text labels for reliable rendering") index = (ROOT / "index.html").read_text() app = (ROOT / "app.js").read_text() if "