Files
aigc-home/docs/hel-892/ace-qwen-document-evidence/verify_sources.py
T

106 lines
4.4 KiB
Python

"Independently verify pinned text/Git objects/package members and raw inventory."
import hashlib
import json
import zipfile
from build_definition import OUT, REF, REPO, build, canonical
from inventory import inventory
def main():
block = build()
rows = json.loads((REF / "sources.json").read_bytes())["sources"]
for e in rows:
raw = (REF / e["local_file"]).read_bytes()
assert hashlib.sha256(raw).hexdigest() == e["sha256"]
if e["id"] == "showtext":
p = REF / e["package_file"]
assert hashlib.sha256(p.read_bytes()).hexdigest() == e["package_sha256"]
with zipfile.ZipFile(p) as z:
assert z.read(e["package_member"]) == raw
assert e["commit"] is None
continue
blob = hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest()
assert blob == e["git_blob_sha1"]
t = json.loads((REF / (e["id"] + "-tree.json")).read_bytes())
assert not t["truncated"]
assert next(x["sha"] for x in t["tree"] if x["path"] == e["file"]) == blob
if e["id"] == "core":
c = json.loads((REF / "core-commit.json").read_bytes())
assert c["sha"] == e["commit"] and c["tree"]["sha"] == e["tree"]
else:
c = (REF / (e["id"] + "-commit.txt")).read_bytes()
assert (
hashlib.sha1(b"commit " + str(len(c)).encode() + b"\0" + c).hexdigest()
== e["commit"]
)
assert c.decode().splitlines()[0] == "tree " + e["tree"] == "tree " + t["sha"]
inv = inventory()
assert len(inv["fields"]) == 77 and len(inv["notes"]) == 1
for a, f in zip(inv["fields"], block["fields"], strict=True):
assert (a["pointer"], a["scope"], a["json_type"], canonical(a["value"])) == (
f["pointer"],
f["scope"],
f["json_type"],
canonical(f["value"]),
)
assert inv["notes"][0]["value"] == block["comments"][0]["text"]
for e in block["sources"]:
raw = (OUT / e["local_file"]).read_bytes()
assert hashlib.sha256(raw).hexdigest() == e["sha256"]
assert 1 <= e["lines"][0] <= e["lines"][1] <= len(raw.decode().splitlines())
g = json.loads((REPO / block["source_path"]).read_bytes())
ns = {n["id"]: n for n in g["nodes"]}
assert g["extra"]["frontendVersion"] == "1.38.0"
assert not g.get("definitions") and all("widgets_values_named" not in n for n in ns.values())
assert len(ns) == 22 and all(n["mode"] == 0 for n in ns.values()) and len(g["links"]) == 24
for eid, src, slot, dst, inp, _ in g["links"]:
assert eid in ns[src]["outputs"][slot]["links"] and ns[dst]["inputs"][inp]["link"] == eid
ace = (REF / "core__comfy_extras__nodes_ace.py").read_text()
assert "TextEncodeAceStepAudio1.5" not in ace and "EmptyAceStep1.5LatentAudio" not in ace
loader = (
(REF / "core__nodes.py")
.read_text()
.split("class DualCLIPLoader:")[1]
.split("class CLIPVisionLoader:")[0]
)
assert '"ace"' not in loader.split("def load_clip")[0]
assert {n["id"] for n in ns.values() if n.get("widgets_values") == []} == {47, 18}
assert ns[116]["widgets_values"][2] == "false" and isinstance(ns[116]["widgets_values"][2], str)
unavailable = json.loads((REF / "llama-unavailable.json").read_bytes())
assert unavailable["requested_commit"] == ns[109]["properties"]["ver"]
assert not any(e["id"] == "llama" for e in rows)
(OUT / "source-check.json").write_text(
json.dumps(
dict(
all_pass=True,
source_files=len(rows),
citations=len(block["sources"]),
counts=block["counts"],
source_frontend="1.38.0",
llama_exact_commit_unavailable=unavailable,
ace15_missing_and_dual_clip_enum_conflict_preserved=True,
license_gaps=[
"llama accurate tree unavailable",
"various/cr no license file in exact trees",
],
upstream_executed=False,
),
ensure_ascii=False,
indent=2,
)
+ "\n"
)
print(
(
"PASS exact text/Git/package identiti"
"es; independent 77 positions, Note, "
"24 edges; unknowns preserved"
)
)
if __name__ == "__main__":
main()