Spaces:
Running
Running
Upload 云端_定时版本检测引擎.py
Browse files- 云端_定时版本检测引擎.py +9 -3
云端_定时版本检测引擎.py
CHANGED
|
@@ -17,7 +17,7 @@ import os
|
|
| 17 |
import tempfile
|
| 18 |
import zipfile
|
| 19 |
import 数据库连接 as db
|
| 20 |
-
from huggingface_hub import
|
| 21 |
|
| 22 |
logger = logging.getLogger("ComfyUI-Ranking.VersionCheck")
|
| 23 |
|
|
@@ -100,6 +100,13 @@ async def fetch_latest_github_hash(repo_url, token):
|
|
| 100 |
return sha[:7] if sha else None
|
| 101 |
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
async def precache_github_zip(repo_url: str, token: Optional[str], item_id: str, version_hash: str):
|
| 104 |
"""按明确commit下载,上传成功后才发布来源匹配的不可变HF缓存。"""
|
| 105 |
temp_path = None
|
|
@@ -159,8 +166,7 @@ async def precache_github_zip(repo_url: str, token: Optional[str], item_id: str,
|
|
| 159 |
stage = "archive_validation"
|
| 160 |
await run_owned_thread(validate_zip_archive, temp_path, size)
|
| 161 |
stage = "hf_upload"
|
| 162 |
-
uploaded = await run_owned_thread(
|
| 163 |
-
repo_id=storage_repo, repo_type="dataset", token=hf_token)
|
| 164 |
stage = "hf_commit"
|
| 165 |
hf_commit = commit_sha(getattr(uploaded, 'oid', None))
|
| 166 |
stage = "source_recheck"
|
|
|
|
| 17 |
import tempfile
|
| 18 |
import zipfile
|
| 19 |
import 数据库连接 as db
|
| 20 |
+
from huggingface_hub import CommitOperationAdd, HfApi
|
| 21 |
|
| 22 |
logger = logging.getLogger("ComfyUI-Ranking.VersionCheck")
|
| 23 |
|
|
|
|
| 100 |
return sha[:7] if sha else None
|
| 101 |
|
| 102 |
|
| 103 |
+
def _upload_precache_archive(temp_path, path_in_repo, storage_repo, hf_token):
|
| 104 |
+
operation = CommitOperationAdd(path_or_fileobj=temp_path, path_in_repo=path_in_repo)
|
| 105 |
+
return HfApi(token=hf_token).create_commit(
|
| 106 |
+
repo_id=storage_repo, repo_type="dataset", operations=[operation],
|
| 107 |
+
commit_message="Cache verified source archive")
|
| 108 |
+
|
| 109 |
+
|
| 110 |
async def precache_github_zip(repo_url: str, token: Optional[str], item_id: str, version_hash: str):
|
| 111 |
"""按明确commit下载,上传成功后才发布来源匹配的不可变HF缓存。"""
|
| 112 |
temp_path = None
|
|
|
|
| 166 |
stage = "archive_validation"
|
| 167 |
await run_owned_thread(validate_zip_archive, temp_path, size)
|
| 168 |
stage = "hf_upload"
|
| 169 |
+
uploaded = await run_owned_thread(_upload_precache_archive, temp_path, path_in_repo, storage_repo, hf_token)
|
|
|
|
| 170 |
stage = "hf_commit"
|
| 171 |
hf_commit = commit_sha(getattr(uploaded, 'oid', None))
|
| 172 |
stage = "source_recheck"
|