Files
aigc-home/docs/hel-892/rtx-document-evidence/fetch_metadata.py
T

46 lines
2.0 KiB
Python

"""Re-fetch bounded exact metadata and tiny source package; no runtime/models/media."""
import hashlib
import io
import json
import urllib.request
import zipfile
from pathlib import Path
REF = Path(__file__).resolve().parent.parent / "rtx-reference"
URLS = {
"rtx-version": "https://api.comfy.org/nodes/comfyui_nvidia_rtx_nodes/versions/0.1.0",
"rtx-tags": "https://api.github.com/repos/Comfy-Org/Nvidia_RTX_Nodes_ComfyUI/tags",
"core-tag": "https://api.github.com/repos/Comfy-Org/ComfyUI/git/ref/tags/v0.16.4",
"frontend-tag": "https://api.github.com/repos/Comfy-Org/ComfyUI_frontend/git/ref/tags/v1.39.19",
"core-tree": "https://api.github.com/repos/Comfy-Org/ComfyUI/git/trees/a7a6335be538f55faa2abf7404c9b8e970847d1f?recursive=1",
"frontend-tree": "https://api.github.com/repos/Comfy-Org/ComfyUI_frontend/git/trees/d91c283b7b758787b4d29126c1a9ac39dc14d6a7?recursive=1",
"rgthree-tree": "https://api.github.com/repos/rgthree/rgthree-comfy/git/trees/449c58fcdd612f7733e54c51f6758ead63fa180b?recursive=1",
}
def main():
for name, url in URLS.items():
with urllib.request.urlopen(url, timeout=30) as r:
raw = r.read(3000001)
assert len(raw) < 3000000
(REF / (name + ".json")).write_bytes(raw)
meta = json.loads((REF / "rtx-version.json").read_bytes())
assert meta["version"] == "0.1.0" and meta["node_id"] == "comfyui_nvidia_rtx_nodes"
with urllib.request.urlopen(meta["downloadUrl"], timeout=30) as r:
raw = r.read(2000001)
assert (
len(raw) < 2000000
and hashlib.sha256(raw).hexdigest()
== "90563d63d95bc6c5893f9107e048549b158223f1c4ab5615921db32e423ad8ba"
)
(REF / "rtx-0.1.0-source.zip").write_bytes(raw)
with zipfile.ZipFile(io.BytesIO(raw)) as z:
for name in ["__init__.py", "pyproject.toml", "README.md", "LICENSE"]:
(REF / ("rtx__" + name)).write_bytes(z.read(name))
print("PASS bounded metadata/source package; no runtime library downloaded")
if __name__ == "__main__":
main()