]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
minor : fix whitespaces (#1302)
authorGeorgi Gerganov <redacted>
Wed, 3 May 2023 17:09:42 +0000 (20:09 +0300)
committerGitHub <redacted>
Wed, 3 May 2023 17:09:42 +0000 (20:09 +0300)
README.md
scripts/verify-checksum-models.py

index de0a3deef7ca3c0f30e1f1b6e30fd49226c8e74a..0002f8cc1990bfe09904ef0ca396dd2d5bd88084 100644 (file)
--- a/README.md
+++ b/README.md
@@ -388,7 +388,7 @@ python3 .\scripts\verify-checksum-models.py
 ```
 
 - On linux or macOS it is also possible to run the following commands to verify if you have all possible latest files in your self-installed `./models` subdirectory:
-    - On Linux: `sha256sum --ignore-missing -c SHA256SUMS` 
+    - On Linux: `sha256sum --ignore-missing -c SHA256SUMS`
     - on macOS: `shasum -a 256 --ignore-missing -c SHA256SUMS`
 
 ### Seminal papers and background on the models
index 1f1b3d24f67ab196d872008068593a47bf0e3793..2ce57282607d8f5908b6ab0008dea7f5e44287cd 100644 (file)
@@ -1,78 +1,77 @@
-import os\r
-import hashlib\r
-\r
-def sha256sum(file):\r
-    block_size = 16 * 1024 * 1024  # 16 MB block size\r
-    b  = bytearray(block_size)\r
-    file_hash = hashlib.sha256()\r
-    mv = memoryview(b)\r
-    with open(file, 'rb', buffering=0) as f:\r
-        while True:\r
-            n = f.readinto(mv)\r
-            if not n:\r
-                break\r
-            file_hash.update(mv[:n])\r
-\r
-    return file_hash.hexdigest()\r
-\r
-# Define the path to the llama directory (parent folder of script directory)\r
-llama_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))\r
-\r
-# Define the file with the list of hashes and filenames\r
-hash_list_file = os.path.join(llama_path, "SHA256SUMS")\r
-\r
-# Check if the hash list file exists\r
-if not os.path.exists(hash_list_file):\r
-    print(f"Hash list file not found: {hash_list_file}")\r
-    exit(1)\r
-\r
-# Read the hash file content and split it into an array of lines\r
-with open(hash_list_file, "r") as f:\r
-    hash_list = f.read().splitlines()\r
-\r
-# Create an array to store the results\r
-results = []\r
-\r
-# Loop over each line in the hash list\r
-for line in hash_list:\r
-    # Split the line into hash and filename\r
-    hash_value, filename = line.split("  ")\r
-\r
-    # Get the full path of the file by joining the llama path and the filename\r
-    file_path = os.path.join(llama_path, filename)\r
-\r
-    # Informing user of the progress of the integrity check\r
-    print(f"Verifying the checksum of {file_path}")\r
-\r
-    # Check if the file exists\r
-    if os.path.exists(file_path):\r
-        # Calculate the SHA256 checksum of the file using hashlib\r
-        file_hash = sha256sum(file_path)\r
-\r
-        # Compare the file hash with the expected hash\r
-        if file_hash == hash_value:\r
-            valid_checksum = "V"\r
-            file_missing = ""\r
-        else:\r
-            valid_checksum = ""\r
-            file_missing = ""\r
-    else:\r
-        valid_checksum = ""\r
-        file_missing = "X"\r
-\r
-    # Add the results to the array\r
-    results.append({\r
-        "filename": filename,\r
-        "valid checksum": valid_checksum,\r
-        "file missing": file_missing\r
-    })\r
-\r
-\r
-# Print column headers for results table\r
-print("\n" + "filename".ljust(40) + "valid checksum".center(20) + "file missing".center(20))\r
-print("-" * 80)\r
-\r
-# Output the results as a table\r
-for r in results:\r
-    print(f"{r['filename']:40} {r['valid checksum']:^20} {r['file missing']:^20}")\r
-\r
+import os
+import hashlib
+
+def sha256sum(file):
+    block_size = 16 * 1024 * 1024  # 16 MB block size
+    b  = bytearray(block_size)
+    file_hash = hashlib.sha256()
+    mv = memoryview(b)
+    with open(file, 'rb', buffering=0) as f:
+        while True:
+            n = f.readinto(mv)
+            if not n:
+                break
+            file_hash.update(mv[:n])
+
+    return file_hash.hexdigest()
+
+# Define the path to the llama directory (parent folder of script directory)
+llama_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
+
+# Define the file with the list of hashes and filenames
+hash_list_file = os.path.join(llama_path, "SHA256SUMS")
+
+# Check if the hash list file exists
+if not os.path.exists(hash_list_file):
+    print(f"Hash list file not found: {hash_list_file}")
+    exit(1)
+
+# Read the hash file content and split it into an array of lines
+with open(hash_list_file, "r") as f:
+    hash_list = f.read().splitlines()
+
+# Create an array to store the results
+results = []
+
+# Loop over each line in the hash list
+for line in hash_list:
+    # Split the line into hash and filename
+    hash_value, filename = line.split("  ")
+
+    # Get the full path of the file by joining the llama path and the filename
+    file_path = os.path.join(llama_path, filename)
+
+    # Informing user of the progress of the integrity check
+    print(f"Verifying the checksum of {file_path}")
+
+    # Check if the file exists
+    if os.path.exists(file_path):
+        # Calculate the SHA256 checksum of the file using hashlib
+        file_hash = sha256sum(file_path)
+
+        # Compare the file hash with the expected hash
+        if file_hash == hash_value:
+            valid_checksum = "V"
+            file_missing = ""
+        else:
+            valid_checksum = ""
+            file_missing = ""
+    else:
+        valid_checksum = ""
+        file_missing = "X"
+
+    # Add the results to the array
+    results.append({
+        "filename": filename,
+        "valid checksum": valid_checksum,
+        "file missing": file_missing
+    })
+
+
+# Print column headers for results table
+print("\n" + "filename".ljust(40) + "valid checksum".center(20) + "file missing".center(20))
+print("-" * 80)
+
+# Output the results as a table
+for r in results:
+    print(f"{r['filename']:40} {r['valid checksum']:^20} {r['file missing']:^20}")