atomgit 1.0.1__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {atomgit-1.0.1 → atomgit-1.0.2}/PKG-INFO +1 -1
- {atomgit-1.0.1 → atomgit-1.0.2}/__init__.py +1 -1
- {atomgit-1.0.1 → atomgit-1.0.2}/atomgit.egg-info/PKG-INFO +1 -1
- {atomgit-1.0.1 → atomgit-1.0.2}/atomgit_hub.py +14 -2
- {atomgit-1.0.1 → atomgit-1.0.2}/cli.py +1 -1
- {atomgit-1.0.1 → atomgit-1.0.2}/setup.py +1 -1
- {atomgit-1.0.1 → atomgit-1.0.2}/README.md +0 -0
- {atomgit-1.0.1 → atomgit-1.0.2}/__main__.py +0 -0
- {atomgit-1.0.1 → atomgit-1.0.2}/api.py +0 -0
- {atomgit-1.0.1 → atomgit-1.0.2}/atomgit.egg-info/SOURCES.txt +0 -0
- {atomgit-1.0.1 → atomgit-1.0.2}/atomgit.egg-info/dependency_links.txt +0 -0
- {atomgit-1.0.1 → atomgit-1.0.2}/atomgit.egg-info/entry_points.txt +0 -0
- {atomgit-1.0.1 → atomgit-1.0.2}/atomgit.egg-info/requires.txt +0 -0
- {atomgit-1.0.1 → atomgit-1.0.2}/atomgit.egg-info/top_level.txt +0 -0
- {atomgit-1.0.1 → atomgit-1.0.2}/config.py +0 -0
- {atomgit-1.0.1 → atomgit-1.0.2}/setup.cfg +0 -0
- {atomgit-1.0.1 → atomgit-1.0.2}/test.py +0 -0
- {atomgit-1.0.1 → atomgit-1.0.2}/utils.py +0 -0
|
@@ -277,6 +277,7 @@ def upload_folder(
|
|
|
277
277
|
commit_description: Optional[str] = None,
|
|
278
278
|
path_in_repo: str = "./",
|
|
279
279
|
ignore_patterns: Optional[List[str]] = None,
|
|
280
|
+
upload_timeout: float = 300.0,
|
|
280
281
|
) -> str:
|
|
281
282
|
"""
|
|
282
283
|
上传文件夹到AtomGit Hub
|
|
@@ -291,6 +292,8 @@ def upload_folder(
|
|
|
291
292
|
commit_description (str, 可选): 提交描述
|
|
292
293
|
path_in_repo (str, 可选): 在仓库中的路径,默认为根目录
|
|
293
294
|
ignore_patterns (List[str], 可选): 要忽略的文件模式
|
|
295
|
+
upload_timeout (float, 可选): 上传超时时间(秒),默认60秒(1分钟)。
|
|
296
|
+
对于大文件,服务器处理响应可能需要较长时间。
|
|
294
297
|
|
|
295
298
|
返回:
|
|
296
299
|
str: 提交的URL或ID
|
|
@@ -298,6 +301,7 @@ def upload_folder(
|
|
|
298
301
|
示例:
|
|
299
302
|
>>> upload_folder("./my-model/", "username/repo-name")
|
|
300
303
|
>>> upload_folder("./data/", "username/repo", path_in_repo="datasets/")
|
|
304
|
+
>>> upload_folder("./big-files/", "username/repo", upload_timeout=1200.0) # 20分钟超时
|
|
301
305
|
"""
|
|
302
306
|
# 标准化仓库ID
|
|
303
307
|
normalized_repo_id = _normalize_repo_id(repo_id)
|
|
@@ -320,7 +324,7 @@ def upload_folder(
|
|
|
320
324
|
# 直接使用原始目录,或者创建临时目录来重新组织结构
|
|
321
325
|
import tempfile
|
|
322
326
|
import shutil
|
|
323
|
-
|
|
327
|
+
|
|
324
328
|
if path_in_repo == "./" or path_in_repo == "." or path_in_repo == "":
|
|
325
329
|
# 如果要上传到根目录,直接使用源文件夹
|
|
326
330
|
upload_path = str(folder_path)
|
|
@@ -337,6 +341,14 @@ def upload_folder(
|
|
|
337
341
|
shutil.copytree(folder_path, target_path, dirs_exist_ok=True)
|
|
338
342
|
|
|
339
343
|
upload_path = str(temp_path)
|
|
344
|
+
# 使用 Monkey Patch 方式临时修改 huggingface_hub 的默认超时配置
|
|
345
|
+
from huggingface_hub import constants as hf_constants
|
|
346
|
+
|
|
347
|
+
# 保存原始超时配置
|
|
348
|
+
original_timeout = hf_constants.DEFAULT_REQUEST_TIMEOUT
|
|
349
|
+
|
|
350
|
+
# 临时修改超时配置
|
|
351
|
+
hf_constants.DEFAULT_REQUEST_TIMEOUT = upload_timeout
|
|
340
352
|
|
|
341
353
|
try:
|
|
342
354
|
# 使用huggingface_hub的upload_folder上传
|
|
@@ -349,7 +361,7 @@ def upload_folder(
|
|
|
349
361
|
)
|
|
350
362
|
|
|
351
363
|
return result
|
|
352
|
-
|
|
364
|
+
|
|
353
365
|
except Exception as e:
|
|
354
366
|
error_msg = str(e)
|
|
355
367
|
if "401" in error_msg or "403" in error_msg:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|