atomgit 1.0.6__tar.gz → 1.0.7__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.6 → atomgit-1.0.7}/PKG-INFO +1 -1
- {atomgit-1.0.6 → atomgit-1.0.7}/__init__.py +1 -1
- {atomgit-1.0.6 → atomgit-1.0.7}/atomgit.egg-info/PKG-INFO +1 -1
- {atomgit-1.0.6 → atomgit-1.0.7}/atomgit_hub.py +17 -4
- {atomgit-1.0.6 → atomgit-1.0.7}/cli.py +1 -1
- {atomgit-1.0.6 → atomgit-1.0.7}/setup.py +1 -1
- {atomgit-1.0.6 → atomgit-1.0.7}/MANIFEST.in +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/README.md +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/__main__.py +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/api.py +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/atomgit.egg-info/SOURCES.txt +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/atomgit.egg-info/dependency_links.txt +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/atomgit.egg-info/entry_points.txt +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/atomgit.egg-info/requires.txt +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/atomgit.egg-info/top_level.txt +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/config.py +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/rate_limiter.py +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/requirements.txt +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/setup.cfg +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/test.py +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/tests/test_rate_limiter.py +0 -0
- {atomgit-1.0.6 → atomgit-1.0.7}/utils.py +0 -0
|
@@ -26,7 +26,10 @@ from huggingface_hub import hf_hub_download, upload_folder as hf_upload_folder,
|
|
|
26
26
|
try:
|
|
27
27
|
from .rate_limiter import install_hf_rate_limiter
|
|
28
28
|
except ImportError:
|
|
29
|
-
|
|
29
|
+
try:
|
|
30
|
+
from rate_limiter import install_hf_rate_limiter
|
|
31
|
+
except ImportError:
|
|
32
|
+
from atomgit.rate_limiter import install_hf_rate_limiter
|
|
30
33
|
|
|
31
34
|
install_hf_rate_limiter()
|
|
32
35
|
|
|
@@ -337,8 +340,10 @@ def upload_folder(
|
|
|
337
340
|
# 如果要上传到根目录,直接使用源文件夹
|
|
338
341
|
upload_path = str(folder_path)
|
|
339
342
|
else:
|
|
340
|
-
#
|
|
341
|
-
with
|
|
343
|
+
# 如果要上传到特定路径,需要重新组织目录结构。
|
|
344
|
+
# 注意:不能提前退出 with TemporaryDirectory(),否则上传时临时目录已被删除。
|
|
345
|
+
temp_dir = tempfile.mkdtemp(prefix="atomgit_upload_")
|
|
346
|
+
try:
|
|
342
347
|
temp_path = Path(temp_dir)
|
|
343
348
|
|
|
344
349
|
# 创建目标路径
|
|
@@ -348,7 +353,11 @@ def upload_folder(
|
|
|
348
353
|
# 复制整个目录树
|
|
349
354
|
shutil.copytree(folder_path, target_path, dirs_exist_ok=True)
|
|
350
355
|
|
|
351
|
-
|
|
356
|
+
except Exception:
|
|
357
|
+
shutil.rmtree(temp_dir, ignore_errors=True)
|
|
358
|
+
raise
|
|
359
|
+
|
|
360
|
+
upload_path = str(temp_path)
|
|
352
361
|
# 使用 Monkey Patch 方式临时修改 huggingface_hub 的默认超时配置
|
|
353
362
|
from huggingface_hub import constants as hf_constants
|
|
354
363
|
|
|
@@ -378,6 +387,10 @@ def upload_folder(
|
|
|
378
387
|
raise Exception(f"仓库不存在:{repo_id}")
|
|
379
388
|
else:
|
|
380
389
|
raise Exception(f"上传失败:{error_msg}")
|
|
390
|
+
finally:
|
|
391
|
+
# 清理临时目录(仅重新组织目录结构时创建)
|
|
392
|
+
if path_in_repo not in ("./", ".", ""):
|
|
393
|
+
shutil.rmtree(temp_dir, ignore_errors=True)
|
|
381
394
|
|
|
382
395
|
|
|
383
396
|
def create_repository(
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|