atomgit 1.0.11__tar.gz → 1.0.12__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.
Files changed (24) hide show
  1. {atomgit-1.0.11 → atomgit-1.0.12}/PKG-INFO +1 -1
  2. {atomgit-1.0.11 → atomgit-1.0.12}/api.py +6 -1
  3. {atomgit-1.0.11 → atomgit-1.0.12}/atomgit.egg-info/PKG-INFO +1 -1
  4. {atomgit-1.0.11 → atomgit-1.0.12}/atomgit_hub.py +39 -1
  5. {atomgit-1.0.11 → atomgit-1.0.12}/setup.py +1 -1
  6. {atomgit-1.0.11 → atomgit-1.0.12}/MANIFEST.in +0 -0
  7. {atomgit-1.0.11 → atomgit-1.0.12}/README.md +0 -0
  8. {atomgit-1.0.11 → atomgit-1.0.12}/__init__.py +0 -0
  9. {atomgit-1.0.11 → atomgit-1.0.12}/__main__.py +0 -0
  10. {atomgit-1.0.11 → atomgit-1.0.12}/atomgit.egg-info/SOURCES.txt +0 -0
  11. {atomgit-1.0.11 → atomgit-1.0.12}/atomgit.egg-info/dependency_links.txt +0 -0
  12. {atomgit-1.0.11 → atomgit-1.0.12}/atomgit.egg-info/entry_points.txt +0 -0
  13. {atomgit-1.0.11 → atomgit-1.0.12}/atomgit.egg-info/requires.txt +0 -0
  14. {atomgit-1.0.11 → atomgit-1.0.12}/atomgit.egg-info/top_level.txt +0 -0
  15. {atomgit-1.0.11 → atomgit-1.0.12}/cli.py +0 -0
  16. {atomgit-1.0.11 → atomgit-1.0.12}/config.py +0 -0
  17. {atomgit-1.0.11 → atomgit-1.0.12}/rate_limiter.py +0 -0
  18. {atomgit-1.0.11 → atomgit-1.0.12}/requirements.txt +0 -0
  19. {atomgit-1.0.11 → atomgit-1.0.12}/setup.cfg +0 -0
  20. {atomgit-1.0.11 → atomgit-1.0.12}/tests/test_download_real.py +0 -0
  21. {atomgit-1.0.11 → atomgit-1.0.12}/tests/test_endpoint_config.py +0 -0
  22. {atomgit-1.0.11 → atomgit-1.0.12}/tests/test_repo_id_normalize.py +0 -0
  23. {atomgit-1.0.11 → atomgit-1.0.12}/tests/test_repo_name_validation.py +0 -0
  24. {atomgit-1.0.11 → atomgit-1.0.12}/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atomgit
3
- Version: 1.0.11
3
+ Version: 1.0.12
4
4
  Summary: AtomGit模型文件上传下载CLI工具
5
5
  Home-page: https://atomgit.com/gitcode-ai/atomgit_cli
6
6
  Author: AtomGit CLI Team
@@ -262,7 +262,12 @@ class HuggingFaceAPI:
262
262
 
263
263
  # 创建本地目录
264
264
  local_path.mkdir(parents=True, exist_ok=True)
265
-
265
+
266
+ # 先探测文件是否存在,给出准确提示(避免把 404 报成网络/缓存故障)
267
+ if atomgit_hub._file_http_status(normalized_repo_id, filename) == 404:
268
+ print(f"文件不存在:{repo_id}/{filename}(revision: main,HTTP 404)。请检查文件路径或版本。")
269
+ return False
270
+
266
271
  # 首先尝试不使用token下载(适用于公开仓库)
267
272
  try:
268
273
  hf_hub_download(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atomgit
3
- Version: 1.0.11
3
+ Version: 1.0.12
4
4
  Summary: AtomGit模型文件上传下载CLI工具
5
5
  Home-page: https://atomgit.com/gitcode-ai/atomgit_cli
6
6
  Author: AtomGit CLI Team
@@ -161,6 +161,29 @@ def _probe_repo(repo_id: str, token: Optional[str] = None) -> Optional[str]:
161
161
  return None
162
162
 
163
163
 
164
+ def _file_http_status(repo_id: str, filename: str, revision: Optional[str] = None,
165
+ token: Optional[str] = None) -> Optional[int]:
166
+ """探测单个文件的可访问性,返回 HTTP 状态码;网络异常返回 None。"""
167
+ endpoint = os.environ.get("HF_ENDPOINT", "https://hub.atomgit.com").rstrip("/")
168
+ rev = revision or "main"
169
+ headers = {"User-Agent": "atomgit-cli"}
170
+ if token:
171
+ headers["Authorization"] = f"Bearer {token}"
172
+ # 注意:HF 兼容的 resolve 路由是 /{namespace}/{repo}/resolve/...,不带 /api/models 前缀
173
+ request = urllib.request.Request(
174
+ f"{endpoint}/{repo_id}/resolve/{rev}/{urllib.parse.quote(filename, safe='/')}",
175
+ headers=headers,
176
+ method="HEAD",
177
+ )
178
+ try:
179
+ with urllib.request.urlopen(request, timeout=15):
180
+ return 200
181
+ except urllib.error.HTTPError as e:
182
+ return e.code
183
+ except Exception:
184
+ return None
185
+
186
+
164
187
  def snapshot_download(
165
188
  repo_id: str,
166
189
  revision: Optional[str] = None,
@@ -360,10 +383,25 @@ def download_file(
360
383
  return result
361
384
  except Exception as e:
362
385
  error_msg = str(e)
386
+ rev = revision or "main"
387
+ # huggingface_hub 常把“文件不存在”报成缓存/网络故障(LocalEntryNotFoundError),
388
+ # 这里用一次 HEAD 请求还原真实状态码,给出准确提示
389
+ status = _file_http_status(normalized_repo_id, filename, revision, token)
390
+ if status == 404:
391
+ raise Exception(
392
+ f"文件不存在:{repo_id}/{filename}(revision: {rev},HTTP 404)。请检查文件路径或版本。"
393
+ )
394
+ if status in (401, 403):
395
+ raise Exception(
396
+ f"认证失败:{repo_id}/{filename}(revision: {rev},HTTP {status})。"
397
+ "请检查 token 是否有效,或是否拥有该仓库权限。"
398
+ )
363
399
  if "401" in error_msg or "403" in error_msg:
364
400
  raise Exception(f"认证失败:{error_msg}")
365
401
  elif "404" in error_msg:
366
- raise Exception(f"文件不存在:{repo_id}/{filename}")
402
+ raise Exception(
403
+ f"文件不存在:{repo_id}/{filename}(revision: {rev},HTTP 404)。请检查文件路径或版本。"
404
+ )
367
405
  else:
368
406
  raise Exception(f"下载失败:{error_msg}")
369
407
 
@@ -31,7 +31,7 @@ def read_requirements():
31
31
 
32
32
  setup(
33
33
  name='atomgit',
34
- version='1.0.11',
34
+ version='1.0.12',
35
35
  author='AtomGit CLI Team',
36
36
  author_email='sa@atomgit.com',
37
37
  description='AtomGit模型文件上传下载CLI工具',
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