Skip to content

Commit 811ccef

Browse files
authored
Support python 3.8~3.13 (#87)
* fix: update model repo name in README Updated model repo name from 'wanghh2003/model05' to 'wanghh2000/model05' in README files. - Changed repo name in README.md - Changed repo name in README_cn.md - Updated repo_type usage in cli.py - Renamed upload command in cli.py - Adjusted token handling in repo.py - Bumped version to 0.6.2 in setup.py * feat: update README and CLI commands - Added installation instructions for train dependencies - Updated example commands to use new model names - Adjusted roadmap items for clarity - Refactored type hints in CLI and upload modules - Updated package version to 0.7.0 - Modified install_requires for cleaner dependencies - Changed python_requires to support 3.8 to 3.14
1 parent e158245 commit 811ccef

File tree

8 files changed

+43
-61
lines changed

8 files changed

+43
-61
lines changed

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ To get started with the CSGHub SDK, ensure you have Python installed on your sys
3838

3939
```python
4040
pip install csghub-sdk
41+
42+
# install with train dependencies
43+
pip install "csghub-sdk[train]"
4144
```
4245

4346
After installation, you can begin using the SDK to connect to your CSGHub server by importing it into your Python script:
@@ -86,16 +89,16 @@ pip install '.[train]'
8689
export CSGHUB_TOKEN=your_access_token
8790

8891
# download model
89-
csghub-cli download wanghh2000/myprivate1
92+
csghub-cli download OpenCSG/csg-wukong-1B
9093

9194
# download model with allow patterns '*.json' and ignore '*_config.json' pattern of files
92-
csghub-cli download wanghh2000/myprivate1 --allow-patterns "*.json" --ignore-patterns "*_config.json"
95+
csghub-cli download OpenCSG/csg-wukong-1B --allow-patterns "*.json" --ignore-patterns "*_config.json"
9396

9497
# download dataset
95-
csghub-cli download wanghh2000/myds1 -t dataset
98+
csghub-cli download OpenCSG/GitLab-DataSets-V1 -t dataset
9699

97100
# download space
98-
csghub-cli download wanghh2000/space1 -t space
101+
csghub-cli download OpenCSG/csg-wukong-1B -t space
99102

100103
# upload a single file to folder1
101104
csghub-cli upload wanghh2000/myprivate1 abc/3.txt folder1
@@ -130,8 +133,8 @@ csghub-cli finetune start OpenCSG/csg-wukong-1B 326
130133
# stop fine-tuning instance for model repo 'OpenCSG/csg-wukong-1B' with ID '326'
131134
csghub-cli finetune stop OpenCSG/csg-wukong-1B 326
132135

133-
# upload local large folder '/Users/hhwang/temp/abc' to model repo 'wanghh2003/model05'
134-
csghub-cli upload-large-folder wanghh2003/model05 /Users/hhwang/temp/abc
136+
# upload local large folder '/Users/hhwang/temp/abc' to model repo 'wanghh2000/model05'
137+
csghub-cli upload-large-folder wanghh2000/model05 /Users/hhwang/temp/abc
135138
```
136139

137140
Notes: `csghub-cli upload` will create repo and its branch if they do not exist. The default branch is `main`. If you want to upload to a specific branch, you can use the `--revision` option. If the branch does not exist, it will be created. If the branch already exists, the files will be uploaded to that branch.
@@ -310,9 +313,7 @@ This code:
310313

311314
## Roadmap
312315

313-
1. Download repo file by CLI
314-
2. Interacting with CSGHub via command-line tools
315-
3. Management operations such as creation and modification of CSGHub repositories
316-
4. Model deployment locally or online
317-
5. Model fine-tuning locally or online
318-
6. Quick upload large folder to CSGHub
316+
1. Interacting with CSGHub via command-line tools
317+
2. Management operations such as creation and modification of CSGHub repositories
318+
3. Model deployment locally or online
319+
4. Model fine-tuning locally or online

README_cn.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ CSGHub SDK 是一个强大的 Python 客户端,专门设计用于与 CSGHub
3838

3939
```python
4040
pip install csghub-sdk
41+
42+
# 使用pip安装训练相关的依赖
43+
pip install "csghub-sdk[train]"
4144
```
4245

4346
安装后,您可以开始将 SDK 导入到您的 Python 脚本中,以连接到您的 CSGHub 服务器:
@@ -85,16 +88,16 @@ pip install '.[train]'
8588
export CSGHUB_TOKEN=your_access_token
8689

8790
# 模型下载
88-
csghub-cli download wanghh2000/myprivate1
91+
csghub-cli download OpenCSG/csg-wukong-1B
8992

9093
# 模型下载时允许'*.json'模式的文件并忽略'*_config.json'模式的文件
91-
csghub-cli download wanghh2000/myprivate1 --allow-patterns "*.json" --ignore-patterns "*_config.json"
94+
csghub-cli download OpenCSG/csg-wukong-1B --allow-patterns "*.json" --ignore-patterns "*_config.json"
9295

9396
# 数据集下载
94-
csghub-cli download wanghh2000/myds1 -t dataset
97+
csghub-cli download OpenCSG/chinese-fineweb-edu-v2 -t dataset
9598

9699
# 应用下载
97-
csghub-cli download wanghh2000/space1 -t space
100+
csghub-cli download OpenCSG/csg-wukong-1B -t space
98101

99102
# 上传单个文件到仓库目录folder1
100103
csghub-cli upload wanghh2000/myprivate1 abc/3.txt folder1
@@ -129,8 +132,8 @@ csghub-cli finetune start OpenCSG/csg-wukong-1B 326
129132
# 停止ID为326使用模型OpenCSG/csg-wukong-1B的微调实例
130133
csghub-cli finetune stop OpenCSG/csg-wukong-1B 326
131134

132-
# 上传本地目录/Users/hhwang/temp/abc中的所有文件到远程仓库wanghh2003/model05
133-
csghub-cli upload-large-folder wanghh2003/model05 /Users/hhwang/temp/abc
135+
# 上传本地目录/Users/hhwang/temp/abc中的所有文件到远程仓库wanghh2000/model05
136+
csghub-cli upload-large-folder wanghh2000/model05 /Users/hhwang/temp/abc
134137
```
135138

136139
注意:csghub-cli upload 将在仓库和分支不存在时创建它们。默认分支为main。如果您想上传到特定分支,可以使用 --revision 选项。如果该分支不存在,将会被创建。如果分支已存在,文件将上传到该分支。
@@ -312,9 +315,7 @@ model = AutoModelForCausalLM.from_pretrained('model/repoid')
312315

313316
## 功能计划
314317

315-
1. 使用命令行工具下载仓库文件
316-
2. 使用命令行工具的方式与CSGHub交互
317-
3. CSGHub仓库的创建、修改等管理操作
318-
4. 模型本地或在线部署
319-
5. 模型本地或在线微调
320-
6. 快速上传大文件夹到CSGHub仓库
318+
1. 使用命令行工具的方式与CSGHub交互
319+
2. CSGHub仓库的创建、修改等管理操作
320+
3. 模型本地或在线部署
321+
4. 模型本地或在线微调

pycsghub/cli.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import typer
22
import os
33
import logging
4-
from typing import Annotated, List, Optional
4+
from typing import List, Optional
5+
from typing_extensions import Annotated
56
from pycsghub.cmd import repo, inference, finetune
67
from pycsghub.cmd.repo_types import RepoType
78
from importlib.metadata import version
@@ -58,7 +59,7 @@ def download(
5859
):
5960
repo.download(
6061
repo_id=repo_id,
61-
repo_type=repo_type,
62+
repo_type=repo_type.value,
6263
revision=revision,
6364
cache_dir=cache_dir,
6465
endpoint=endpoint,
@@ -67,7 +68,7 @@ def download(
6768
ignore_patterns=ignore_patterns,
6869
)
6970

70-
@app.command(name="upload-files", help="Upload repository files to OpenCSG Hub", no_args_is_help=True)
71+
@app.command(name="upload", help="Upload repository files to OpenCSG Hub", no_args_is_help=True)
7172
def upload(
7273
repo_id: Annotated[str, OPTIONS["repoID"]],
7374
local_path: Annotated[str, OPTIONS["localPath"]],
@@ -82,7 +83,7 @@ def upload(
8283
if os.path.isfile(local_path):
8384
repo.upload_files(
8485
repo_id=repo_id,
85-
repo_type=repo_type,
86+
repo_type=repo_type.value,
8687
repo_file=local_path,
8788
path_in_repo=path_in_repo,
8889
revision=revision,
@@ -93,7 +94,7 @@ def upload(
9394
else:
9495
repo.upload_folder(
9596
repo_id=repo_id,
96-
repo_type=repo_type,
97+
repo_type=repo_type.value,
9798
local_path=local_path,
9899
path_in_repo=path_in_repo,
99100
revision=revision,
@@ -119,7 +120,7 @@ def upload_large_folder(
119120
upload_large_folder_internal(
120121
repo_id=repo_id,
121122
local_path=local_path,
122-
repo_type=repo_type,
123+
repo_type=repo_type.value,
123124
revision=revision,
124125
endpoint=endpoint,
125126
token=token,

pycsghub/cmd/repo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from pathlib import Path
44
from typing import Optional, Union, List
55
from pycsghub.constants import DEFAULT_REVISION
6-
import requests
76
from pycsghub.repository import Repository
7+
from pycsghub.utils import get_token_to_send
88

99
def download(
1010
repo_id: str,
@@ -73,7 +73,7 @@ def upload_folder(
7373
branch_name=revision,
7474
endpoint=endpoint,
7575
user_name=user_name,
76-
token=token,
76+
token=get_token_to_send(token),
7777
auto_create=auto_create,
7878
)
7979
r.upload()

pycsghub/repo_reader/model/huggingface/model_auto.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ def from_pretrained(cls, pretrained_model_name_or_path,
1111
try:
1212
token = get_token_to_send(None)
1313
except Exception:
14-
token = ("f3a7b9c1d6e5f8e2a1b5d4f9e6a2b8d7c3a4e2b1d9f6e7a8d2c5a7b4c1e3f5b8a1d4"
15-
"f9b7d6e2f8a5d3b1e7f9c6a8b2d1e4f7d5b6e9f2a4b3c8e1d7f995hd82hf")
14+
token = None
1615
if os.path.isdir(pretrained_model_name_or_path):
1716
path = Path(pretrained_model_name_or_path)
1817
else:

pycsghub/upload_large_folder/status.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def is_done(self) -> bool:
164164
with self.lock:
165165
return all(metadata.is_committed or metadata.should_ignore for _, metadata in self.items)
166166

167-
def get_lfs_uploaded_slice_ids(self, file_path: str) -> str|None:
167+
def get_lfs_uploaded_slice_ids(self, file_path: str) -> str:
168168
with self.lock:
169169
return self._lfs_uploaded_ids.get(file_path)
170170

@@ -182,7 +182,7 @@ def append_lfs_uploaded_slice_id(self, file_path: str, id: int, etag: str):
182182
new_ids = old_ids
183183
self._lfs_uploaded_ids[file_path] = new_ids
184184

185-
def convert_uploaded_ids_to_map(self, ids: str | None):
185+
def convert_uploaded_ids_to_map(self, ids: str):
186186
id_map = {}
187187
if ids is None or ids == "":
188188
return id_map

pycsghub/upload_large_folder/workers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def _perform_lfs_slice_upload(item: JOB_ITEM_T):
422422
etag = resp_header.get("etag")
423423
if etag is None or etag == "":
424424
raise ValueError(f"invalid slice upload response header: {resp_header}, etag: {etag}")
425-
return etag.removeprefix('"').removesuffix('"')
425+
return etag.strip('"')
426426

427427
def _commit(
428428
items: List[JOB_ITEM_T],

setup.py

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='csghub-sdk',
8-
version='0.6.1',
8+
version='0.7.0',
99
author="opencsg",
1010
author_email="contact@opencsg.com",
1111
long_description=long_description,
@@ -18,29 +18,9 @@
1818
]
1919
},
2020
install_requires=[
21-
"typer>=0.12.3",
22-
"attr>=0.3.2",
23-
"ConfigParser>=7.0.0",
24-
"contextlib2>=21.6.0",
25-
"cryptography>=43.0.1",
26-
"Cython>=3.0.10",
27-
"dl>=0.1.0",
21+
"typer",
22+
"typing_extensions",
2823
"huggingface_hub>=0.22.2",
29-
"ipython>=8.12.3",
30-
"ipywidgets>=8.1.2",
31-
"keyring>=25.2.1",
32-
"lockfile>=0.12.2",
33-
"mock>=5.1.0",
34-
"Pillow>=10.3.0",
35-
"protobuf>=4.25.1",
36-
"pyOpenSSL>=24.1.0",
37-
"railroad>=0.5.0",
38-
"thread>=2.0.3",
39-
"tornado>=6.4.1",
40-
"tqdm>=4.66.3",
41-
"trove_classifiers>=2024.5.22",
42-
"truststore>=0.9.1",
43-
"urllib3_secure_extra>=0.1.0",
4424
],
4525
extras_require={
4626
"train": [
@@ -49,5 +29,5 @@
4929
"datasets>=2.20.0"
5030
],
5131
},
52-
python_requires=">=3.10",
32+
python_requires=">=3.8,<3.14",
5333
)

0 commit comments

Comments
 (0)