MCPcopy Index your code
hub / github.com/pythongosssss/ComfyUI-Custom-Scripts / get_metadata

Function get_metadata

py/model_info.py:9–23  ·  view source on GitHub ↗
(filepath)

Source from the content-addressed store, hash-verified

7
8
9def get_metadata(filepath):
10 with open(filepath, "rb") as file:
11 # https://github.com/huggingface/safetensors#format
12 # 8 bytes: N, an unsigned little-endian 64-bit integer, containing the size of the header
13 header_size = int.from_bytes(file.read(8), "little", signed=False)
14
15 if header_size <= 0:
16 raise BufferError("Invalid header size")
17
18 header = file.read(header_size)
19 if header_size <= 0:
20 raise BufferError("Invalid header")
21
22 header_json = json.loads(header)
23 return header_json["__metadata__"] if "__metadata__" in header_json else None
24
25
26@PromptServer.instance.routes.post("/pysssss/metadata/notes/{name}")

Callers 1

load_metadataFunction · 0.85

Calls 1

readMethod · 0.80

Tested by

no test coverage detected