algorise's picture
download
raw
1.54 kB
"""Byte-compare live raw published pages against local page.md files.
trackio's URI rewrite can reintroduce CRLF on Windows, which makes a page parse
as zero cells and silently kills every figure. This catches that.
"""
import hashlib
import json
import os
import urllib.request
import huggingface_hub
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PAGES = os.path.join(ROOT, ".trackio", "logbook", "pages")
SPACE = ("algorise/repro-ddsvm-a-differentiable-framework-for-deep-support-"
"vector-machines-with-iterative-geometry")
TOK = huggingface_hub.get_token()
lb = json.load(open(os.path.join(ROOT, ".trackio", "logbook", "logbook.json")))
files = ["pages/index.md"] + [c["file"] for c in lb["root"]["children"]]
ok = True
for rel in files:
url = f"https://huggingface.co/spaces/{SPACE}/raw/main/{rel}"
req = urllib.request.Request(url, headers={"Authorization": f"Bearer {TOK}"})
live = urllib.request.urlopen(req).read()
local = open(os.path.join(ROOT, ".trackio", "logbook", rel), "rb").read()
same = live == local
crlf = b"\r\n" in live
ncells = live.count(b"<!-- trackio-cell")
ok &= same and not crlf
print(f"{'OK ' if (same and not crlf) else 'FAIL'} {rel}")
print(f" live {len(live)}B sha1={hashlib.sha1(live).hexdigest()[:12]} | "
f"local {len(local)}B sha1={hashlib.sha1(local).hexdigest()[:12]} | "
f"identical={same} CRLF={crlf} cells={ncells}")
print("\nALL PAGES BYTE-IDENTICAL AND LF-CLEAN" if ok else "\nMISMATCH DETECTED")

Xet Storage Details

Size:
1.54 kB
·
Xet hash:
6b330dfc1c4d98b0d85fbb700dc3ccabe570472ed93d73b0cb73583e9a0a440d

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.