Skip to content

Commit 72863d5

Browse files
committed
gguf-hash: flake8 lint fixes
1 parent 7e8640a commit 72863d5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

gguf-py/scripts/gguf-hash.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python3
22
from __future__ import annotations
33

4-
import sys
54
import uuid
65
import hashlib
76

@@ -17,13 +16,15 @@
1716
if "NO_LOCAL_GGUF" not in os.environ and (Path(__file__).parent.parent.parent / 'gguf-py').exists():
1817
sys.path.insert(0, str(Path(__file__).parent.parent))
1918

20-
from gguf import GGUFReader, GGUFValueType # noqa: E402
19+
from gguf import GGUFReader # noqa: E402
20+
2121

22-
logger = logging.getLogger("gguf-dump")
22+
logger = logging.getLogger("gguf-hash")
2323

2424
# UUID_NAMESPACE_LLAMA_CPP = uuid.uuid5(uuid.NAMESPACE_URL, 'en.wikipedia.org/wiki/Llama.cpp')
2525
UUID_NAMESPACE_LLAMA_CPP = uuid.UUID('ef001206-dadc-5f6d-a15f-3359e577d4e5')
2626

27+
2728
# For more information about what field.parts and field.data represent,
2829
# please see the comments in the modify_gguf.py example.
2930
def gguf_hash(reader: GGUFReader, filename: str, disable_progress_bar) -> None:
@@ -50,7 +51,6 @@ def gguf_hash(reader: GGUFReader, filename: str, disable_progress_bar) -> None:
5051

5152
# Hashing Process
5253
for n, tensor in enumerate(reader.tensors, 1):
53-
prettydims = ', '.join('{0:5}'.format(d) for d in list(tensor.shape) + [1] * (4 - len(tensor.shape)))
5454

5555
# We don't need these
5656
if tensor.name.endswith((".attention.masked_bias", ".attention.bias", ".rotary_emb.inv_freq")):
@@ -66,14 +66,15 @@ def gguf_hash(reader: GGUFReader, filename: str, disable_progress_bar) -> None:
6666
sha1_layer.update(tensor.data)
6767
sha1.update(tensor.data)
6868
uuidv5_sha1.update(tensor.data)
69-
print("sha1 {0} {1}:{2}".format(sha1_layer.hexdigest(), filename, tensor.name))
69+
print("sha1 {0} {1}:{2}".format(sha1_layer.hexdigest(), filename, tensor.name)) # noqa: NP100
7070

7171
# Flush Hash Progress Bar
7272
bar.close()
7373

7474
# Display Hash Output
75-
print("sha1 {0} {1}".format(sha1.hexdigest(), filename))
76-
print("UUIDv5 {0} {1}".format(uuid.UUID(bytes=uuidv5_sha1.digest()[:16], version=5), filename))
75+
print("sha1 {0} {1}".format(sha1.hexdigest(), filename)) # noqa: NP100
76+
print("UUIDv5 {0} {1}".format(uuid.UUID(bytes=uuidv5_sha1.digest()[:16], version=5), filename)) # noqa: NP100
77+
7778

7879
def main() -> None:
7980
parser = argparse.ArgumentParser(description="Dump GGUF file metadata")
@@ -85,5 +86,6 @@ def main() -> None:
8586
reader = GGUFReader(args.model, 'r')
8687
gguf_hash(reader, args.model, not args.progressbar)
8788

89+
8890
if __name__ == '__main__':
8991
main()

0 commit comments

Comments
 (0)