Spaces:
Sleeping
Sleeping
Update app.py (#26)
Browse files- Update app.py (c22eda8dbeff393998ea7a5771fb822cda465ee3)
- Update app.py (0b8a50cce4668cb4992119e0e9fa210d81703402)
app.py
CHANGED
@@ -6,9 +6,9 @@ import shutil
|
|
6 |
from huggingface_hub import HfApi, create_repo
|
7 |
from typing import Union
|
8 |
|
9 |
-
def download_file(digest, image):
|
10 |
url = f"https://registry.ollama.ai/v2/library/{image}/blobs/{digest}"
|
11 |
-
file_name = f"blobs/{
|
12 |
|
13 |
# Create the directory if it doesn't exist
|
14 |
os.makedirs(os.path.dirname(file_name), exist_ok=True)
|
@@ -65,17 +65,18 @@ def process_image_tag(image_tag, repo_id, oauth_token: Union[gr.OAuthToken, None
|
|
65 |
with open(manifest_file_path, 'w') as f:
|
66 |
json.dump(manifest_json, f)
|
67 |
|
68 |
-
# Extract the digest values from the JSON
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
download_file(digest, image)
|
74 |
|
75 |
# Download the config file
|
|
|
76 |
config_digest = manifest_json.get('config', {}).get('digest')
|
77 |
-
if config_digest:
|
78 |
-
download_file(config_digest, image)
|
79 |
|
80 |
# Upload to Hugging Face Hub
|
81 |
upload_result, repo_path = upload_to_huggingface(repo_id, 'blobs', oauth_token)
|
|
|
6 |
from huggingface_hub import HfApi, create_repo
|
7 |
from typing import Union
|
8 |
|
9 |
+
def download_file(media_type, digest, image):
|
10 |
url = f"https://registry.ollama.ai/v2/library/{image}/blobs/{digest}"
|
11 |
+
file_name = f"blobs/{media_type.split(".")[-1]}"
|
12 |
|
13 |
# Create the directory if it doesn't exist
|
14 |
os.makedirs(os.path.dirname(file_name), exist_ok=True)
|
|
|
65 |
with open(manifest_file_path, 'w') as f:
|
66 |
json.dump(manifest_json, f)
|
67 |
|
68 |
+
# Extract the mediaType and digest values from the JSON
|
69 |
+
layers = manifest_json.get('layers', [])
|
70 |
+
for layer in layers:
|
71 |
+
media_type = layer['mediaType']
|
72 |
+
digest = layer['digest']
|
73 |
+
download_file(media_type, digest, image)
|
74 |
|
75 |
# Download the config file
|
76 |
+
config_media_type = manifest_json.get('config', {}).get('mediaType')
|
77 |
config_digest = manifest_json.get('config', {}).get('digest')
|
78 |
+
if config_media_type and config_digest:
|
79 |
+
download_file(config_media_type, config_digest, image)
|
80 |
|
81 |
# Upload to Hugging Face Hub
|
82 |
upload_result, repo_path = upload_to_huggingface(repo_id, 'blobs', oauth_token)
|