atomgit 1.0.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atomgit
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: AtomGit模型文件上传下载CLI工具
5
5
  Home-page: https://atomgit.com/gitcode-ai/atomgit_cli
6
6
  Author: AtomGit CLI Team
@@ -8,7 +8,7 @@ AtomGit CLI - 基于Transformers和Hugging Face Hub的模型文件上传下载
8
8
  支持模型和数据集的上传、下载等操作。
9
9
  """
10
10
 
11
- __version__ = '1.0.0'
11
+ __version__ = '1.0.2'
12
12
  __author__ = 'AtomGit CLI Team'
13
13
  __description__ = 'AtomGit模型文件上传下载CLI工具'
14
14
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atomgit
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: AtomGit模型文件上传下载CLI工具
5
5
  Home-page: https://atomgit.com/gitcode-ai/atomgit_cli
6
6
  Author: AtomGit CLI Team
@@ -6,6 +6,7 @@ atomgit_hub.py
6
6
  cli.py
7
7
  config.py
8
8
  setup.py
9
+ test.py
9
10
  utils.py
10
11
  ./__init__.py
11
12
  ./__main__.py
@@ -13,6 +14,7 @@ utils.py
13
14
  ./atomgit_hub.py
14
15
  ./cli.py
15
16
  ./config.py
17
+ ./test.py
16
18
  ./utils.py
17
19
  atomgit.egg-info/PKG-INFO
18
20
  atomgit.egg-info/SOURCES.txt
@@ -35,7 +35,10 @@ except ImportError:
35
35
  try:
36
36
  from .config import config
37
37
  except ImportError:
38
- from config import config
38
+ try:
39
+ from config import config
40
+ except ImportError:
41
+ from atomgit.config import config
39
42
 
40
43
 
41
44
  def _normalize_repo_id(repo_id: str) -> str:
@@ -274,6 +277,7 @@ def upload_folder(
274
277
  commit_description: Optional[str] = None,
275
278
  path_in_repo: str = "./",
276
279
  ignore_patterns: Optional[List[str]] = None,
280
+ upload_timeout: float = 300.0,
277
281
  ) -> str:
278
282
  """
279
283
  上传文件夹到AtomGit Hub
@@ -288,6 +292,8 @@ def upload_folder(
288
292
  commit_description (str, 可选): 提交描述
289
293
  path_in_repo (str, 可选): 在仓库中的路径,默认为根目录
290
294
  ignore_patterns (List[str], 可选): 要忽略的文件模式
295
+ upload_timeout (float, 可选): 上传超时时间(秒),默认60秒(1分钟)。
296
+ 对于大文件,服务器处理响应可能需要较长时间。
291
297
 
292
298
  返回:
293
299
  str: 提交的URL或ID
@@ -295,6 +301,7 @@ def upload_folder(
295
301
  示例:
296
302
  >>> upload_folder("./my-model/", "username/repo-name")
297
303
  >>> upload_folder("./data/", "username/repo", path_in_repo="datasets/")
304
+ >>> upload_folder("./big-files/", "username/repo", upload_timeout=1200.0) # 20分钟超时
298
305
  """
299
306
  # 标准化仓库ID
300
307
  normalized_repo_id = _normalize_repo_id(repo_id)
@@ -317,7 +324,7 @@ def upload_folder(
317
324
  # 直接使用原始目录,或者创建临时目录来重新组织结构
318
325
  import tempfile
319
326
  import shutil
320
-
327
+
321
328
  if path_in_repo == "./" or path_in_repo == "." or path_in_repo == "":
322
329
  # 如果要上传到根目录,直接使用源文件夹
323
330
  upload_path = str(folder_path)
@@ -334,6 +341,14 @@ def upload_folder(
334
341
  shutil.copytree(folder_path, target_path, dirs_exist_ok=True)
335
342
 
336
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
337
352
 
338
353
  try:
339
354
  # 使用huggingface_hub的upload_folder上传
@@ -346,7 +361,7 @@ def upload_folder(
346
361
  )
347
362
 
348
363
  return result
349
-
364
+
350
365
  except Exception as e:
351
366
  error_msg = str(e)
352
367
  if "401" in error_msg or "403" in error_msg:
@@ -37,7 +37,7 @@ except ImportError:
37
37
 
38
38
 
39
39
  @click.group()
40
- @click.version_option(version='1.0.0')
40
+ @click.version_option(version='1.0.2')
41
41
  def cli():
42
42
  """AtomGit CLI - 基于Transformers和Hugging Face Hub的AtomGit平台模型文件上传下载工具"""
43
43
  pass
@@ -24,12 +24,14 @@ def read_requirements():
24
24
  'tqdm>=4.66.1',
25
25
  'pathlib>=1.0.1',
26
26
  'colorama>=0.4.6',
27
- 'tabulate>=0.9.0'
27
+ 'tabulate>=0.9.0',
28
+ 'huggingface-hub>=0.20.0',
29
+ 'datasets>=2.16.0'
28
30
  ]
29
31
 
30
32
  setup(
31
33
  name='atomgit',
32
- version='1.0.0',
34
+ version='1.0.2',
33
35
  author='AtomGit CLI Team',
34
36
  author_email='sa@atomgit.com',
35
37
  description='AtomGit模型文件上传下载CLI工具',
atomgit-1.0.2/test.py ADDED
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ AtomGit Hub 功能测试
5
+ """
6
+
7
+ from atomgit_hub import (
8
+ create_repository,
9
+ upload_folder,
10
+ snapshot_download,
11
+ hub_download_url,
12
+ download_file,
13
+ load_dataset
14
+ )
15
+ from pathlib import Path
16
+
17
+
18
+ def test_create_model(repo_id: str, repo_type: str):
19
+ print("\n=== 测试 create_repository ===")
20
+ try:
21
+ result = create_repository(
22
+ repo_id=repo_id,
23
+ token=None, # 使用保存的token
24
+ private=True,
25
+ repo_type=repo_type,
26
+ exist_ok=True,
27
+ space_sdk=None,
28
+ space_hardware=None,
29
+ space_storage=None,
30
+ space_sleep_time=None,
31
+ space_secrets=None,
32
+ space_variables=None
33
+ )
34
+ print(f"✅ 创建仓库成功: {result}")
35
+ except Exception as e:
36
+ print(f"❌ 创建仓库失败: {e}")
37
+
38
+ def test_upload_folder(repo_id: str, folder_path: str):
39
+ print("\n=== 测试 upload_folder ===")
40
+
41
+ try:
42
+ result = upload_folder(
43
+ folder_path=folder_path,
44
+ repo_id=repo_id,
45
+ token=None, # 使用保存的token
46
+ commit_message="Test upload with all parameters",
47
+ commit_description="Full parameter test for upload_folder function"
48
+ )
49
+ print(f"✅ 上传文件夹成功: {result}")
50
+ except Exception as e:
51
+ print(f"❌ 上传文件夹失败: {e}")
52
+
53
+ def test_snapshot_download(repo_id: str, local_dir: str):
54
+ print("\n=== 测试 snapshot_download ===")
55
+ try:
56
+ local_path = snapshot_download(
57
+ repo_id=repo_id,
58
+ local_dir=local_dir,
59
+ proxies=None,
60
+ etag_timeout=10,
61
+ resume_download=False,
62
+ force_download=True,
63
+ token=None, # 使用保存的token
64
+ local_files_only=False,
65
+ max_workers=8,
66
+ tqdm_class=None
67
+ )
68
+ print(f"✅ 下载快照成功: {local_path}")
69
+ except Exception as e:
70
+ print(f"❌ 下载快照失败: {e}")
71
+
72
+ def test_download_file(repo_id: str, filename: str, local_dir: str):
73
+ print("\n=== 测试 download_file ===")
74
+ try:
75
+ file_path = download_file(
76
+ repo_id=repo_id,
77
+ filename=filename,
78
+ local_dir=local_dir,
79
+ token=None, # 使用保存的token
80
+ force_download=True
81
+ )
82
+ print(f"✅ 下载文件成功: {file_path}")
83
+ except Exception as e:
84
+ print(f"❌ 下载文件失败: {e}")
85
+
86
+
87
+ def test_hub_download_url(repo_id: str, filename: str, repo_type: str):
88
+ print("\n=== 测试 hub_download_url ===")
89
+ try:
90
+ url = hub_download_url(
91
+ repo_id=repo_id,
92
+ filename=filename,
93
+ repo_type=repo_type
94
+ )
95
+ print(f"✅ 获取URL成功: {url}")
96
+ except Exception as e:
97
+ print(f"❌ 获取URL失败: {e}")
98
+
99
+ def test_load_dataset(repo_id: str, local_dir: str):
100
+ print("\n=== 测试 load_dataset ===")
101
+ try:
102
+ dataset = load_dataset(
103
+ path=repo_id,
104
+ cache_dir=local_dir,
105
+ token=None
106
+ )
107
+ print(f"✅ 加载数据集成功: {dataset}")
108
+ except Exception as e:
109
+ print(f"❌ 加载数据集失败: {e}")
110
+
111
+
112
+ def run_all_tests():
113
+ """运行所有测试"""
114
+ print("=" * 60)
115
+ print("开始运行 AtomGit Hub 完整参数测试")
116
+ print("=" * 60)
117
+ model = "ai-test/atomgit-cli-test-model-full"
118
+ dataset = "ai-test/atomgit-cli-test-dataset-full"
119
+
120
+ model_folder_path="/Users/yanlp/csdn/aipython/gitcode_cli/site/yanlp-model-1"
121
+ dataset_folder_path="/Users/yanlp/csdn/aipython/gitcode_cli/site/yanlp-model-1"
122
+
123
+ test_dataset = "yanlp/glaive_toolcall_zh"
124
+ # 注意:按照依赖顺序执行测试
125
+ # 1. 先创建仓库
126
+ # test_create_model(repo_id=model, repo_type="model")
127
+ # test_create_model(repo_id=dataset, repo_type="dataset")
128
+
129
+ # 2. 测试upload
130
+ # test_upload_folder(repo_id=model, folder_path=model_folder_path)
131
+ # test_upload_folder(repo_id=dataset, folder_path=dataset_folder_path)
132
+
133
+ # 3. 测试下载
134
+ test_snapshot_download(repo_id=model, local_dir="./test_downloads/model/snapshot_full")
135
+ # test_snapshot_download(repo_id="hf_mirrors/Qwen/Qwen3-0.6B", local_dir="./test_downloads/dataset/snapshot_full2")
136
+
137
+ # 4. 测试下载文件
138
+ # test_download_file(repo_id=model, filename="README.md", local_dir="./test_downloads/model/single_file")
139
+
140
+ # 5. 测试URL获取
141
+ # test_hub_download_url(repo_id=model, filename="model.safetensors", repo_type="model")
142
+
143
+ # 6. 测试数据集加载
144
+ # test_load_dataset(repo_id=test_dataset, local_dir="./test_downloads/dataset/load_dataset")
145
+
146
+ print("\n" + "=" * 60)
147
+ print("所有测试完成")
148
+ print("=" * 60)
149
+
150
+
151
+ if __name__ == "__main__":
152
+ run_all_tests()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes