129 lines
4.8 KiB
Python
129 lines
4.8 KiB
Python
"Only original typed API values, declared references and explicit implementation gaps."
|
|
|
|
import hashlib
|
|
import json
|
|
from collections import Counter
|
|
|
|
from build_definition import EXPECTED, OUT, PATHS, REPO, build
|
|
|
|
|
|
def string_record(nid, field, value):
|
|
return dict(
|
|
node_id=nid,
|
|
field=field,
|
|
characters=len(value),
|
|
LF=value.count("\n"),
|
|
CR=value.count("\r"),
|
|
tail_LF=value.endswith("\n"),
|
|
tail_space=value.endswith(" "),
|
|
sha256=hashlib.sha256(value.encode()).hexdigest(),
|
|
)
|
|
|
|
|
|
def main():
|
|
raw = (REPO / PATHS[0]).read_bytes()
|
|
assert hashlib.sha256(raw).hexdigest() == EXPECTED
|
|
graph, block = json.loads(raw), build()
|
|
assert all(nid.isdecimal() for nid in graph)
|
|
assert len(graph) == len(block["node_bindings"]) == 25
|
|
assert all(set(n) == {"inputs", "class_type", "_meta"} for n in graph.values())
|
|
assert Counter(f["json_type"] for f in block["fields"]) == dict(str=24, int=12, bool=5, float=1)
|
|
assert block["sources"] == block["comments"] == []
|
|
assert all(
|
|
n["scope"] == "root" and not n["implementation_verified"] for n in block["node_bindings"]
|
|
)
|
|
assert set(graph["178"]["inputs"]) == {
|
|
"prompt",
|
|
"width",
|
|
"height",
|
|
"length",
|
|
"ref_image_size",
|
|
"clip",
|
|
"vae",
|
|
"audio_vae",
|
|
"ref_images.ref_image_0",
|
|
"ref_images.ref_image_1",
|
|
"ref_images.ref_image_2",
|
|
}
|
|
assert graph["178"]["inputs"]["ref_images.ref_image_0"] == ["148", 0]
|
|
assert graph["178"]["inputs"]["ref_images.ref_image_1"] == ["149", 0]
|
|
assert graph["178"]["inputs"]["ref_images.ref_image_2"] == ["155", 0]
|
|
assert graph["155"]["inputs"] == {"image": "CharSheet_00008_.png"}
|
|
assert graph["149"]["inputs"] == {"image": "CharSheet_00005_.png"}
|
|
assert graph["178"]["inputs"]["audio_vae"] == ["165", 0]
|
|
assert graph["173"]["inputs"]["latent_image"] == ["178", 1]
|
|
assert graph["176"]["inputs"]["save_output"] is False
|
|
strings = []
|
|
for nid, key, length, digest in [
|
|
("148", "image", 20, "d820b5bc6349af18515abbe4dc64184f8e532c66618991e3c61871eee9d0e224"),
|
|
("160", "string_a", 48, "bf5ba370d12ea62c641ec32f034a5dd0c719fa6a9075d4cde917b4b7290d109b"),
|
|
(
|
|
"131",
|
|
"expression",
|
|
63,
|
|
"3624220e274fac45b4d3e93c698d632d0aa4e9abd949450f18e6aec63904acd9",
|
|
),
|
|
("149", "image", 20, "de0c3451769a834d6cd82fc09c183a34efb2502127c7ff002800e54a78e20c60"),
|
|
("155", "image", 20, "5409cb9778e0233e1c0f2b1e3d5967bc50b83b6b0ba415f74fe7faff57766667"),
|
|
]:
|
|
value = graph[nid]["inputs"][key]
|
|
assert len(value) == length and hashlib.sha256(value.encode()).hexdigest() == digest
|
|
assert value.count("\n") == 0
|
|
strings.append(string_record(nid, key, value))
|
|
assert graph["160"]["inputs"]["string_a"].endswith(" ")
|
|
assert graph["160"]["inputs"]["delimiter"] == " "
|
|
assert graph["138"]["inputs"]["value"] == ""
|
|
strings += [string_record("160", "delimiter", " "), string_record("138", "value", "")]
|
|
model_strings = [
|
|
string_record(f["node_id"], f["field"], f["value"])
|
|
for f in block["fields"]
|
|
if f["field"] in {"unet_name", "lora_name", "clip_name", "vae_name", "filename_prefix"}
|
|
]
|
|
audit = dict(
|
|
path=PATHS[0],
|
|
sha256=EXPECTED,
|
|
original_bytes=len(raw),
|
|
source_nodes=25,
|
|
saved_inputs=42,
|
|
scalar_inputs=42,
|
|
complete_objects=0,
|
|
json_types=dict(Counter(f["json_type"] for f in block["fields"])),
|
|
references=block["api_references"],
|
|
node_identity_gaps=block["node_bindings"],
|
|
exact_implementation_sources=0,
|
|
original_fetch_time="unknown:未保留可证精确取得时刻",
|
|
strings=strings,
|
|
model_strings=model_strings,
|
|
missing_inputs=[
|
|
dict(
|
|
node_id="178",
|
|
state="原未保存ref_image_3及其它ref_image口、first_frame/last_frame或参考视频音频键,不补值/聚合/默认容量",
|
|
)
|
|
],
|
|
media_histories=0,
|
|
sampler_nodes=[
|
|
nid for nid, n in graph.items() if n["class_type"] == "SamplerCustomAdvanced"
|
|
],
|
|
)
|
|
audit["expressions"] = [
|
|
dict(
|
|
node_id="131",
|
|
field="expression",
|
|
value=graph["131"]["inputs"]["expression"],
|
|
sha256=hashlib.sha256(graph["131"]["inputs"]["expression"].encode()).hexdigest(),
|
|
)
|
|
]
|
|
assert audit["sampler_nodes"] == ["173"]
|
|
(OUT / "original-audit.json").write_text(json.dumps(audit, ensure_ascii=False, indent=2) + "\n")
|
|
print(
|
|
(
|
|
"PASS original25 / typed42 scalars / reference"
|
|
"s30 / implementation0; original spaces, file/"
|
|
"model strings"
|
|
)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|