From dc70f247b57b8bd4b30381c3ba540ce92ec0343e Mon Sep 17 00:00:00 2001 From: Sean <38311363@qq.com> Date: Mon, 29 Jul 2024 16:44:03 +0800 Subject: [PATCH 1/2] update readme --- README.md | 15 ++++++++++++++- README_EN.md | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index adfa77f..00f4d38 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- English | 中文 + English | 中文

# CSGHub SDK @@ -150,6 +150,19 @@ cookies = None http_get(url=url, token=token, local_dir=local_dir, file_name=file_name, headers=headers, cookies=cookies) ``` +### 单文件上传 + +```python +from pycsghub.file_upload import http_upload_file + +token = "3b77c98077b415ca381ded189b86d5df226e3776" + +endpoint = "https://hub.opencsg.com" +repo_type = "model" +repo_id = 'wanghh2000/myprivate1' +result = http_upload_file(repo_id, endpoint=endpoint, token=token, repo_type='model', file_path='test1.txt') +``` + ### 兼容huggingface的模型加载 huggingface的transformers库支持直接输入huggingface上的repo_id以下载并读取相关模型,如下列所示: diff --git a/README_EN.md b/README_EN.md index d72826b..c2cd762 100644 --- a/README_EN.md +++ b/README_EN.md @@ -1,5 +1,5 @@

- English | 中文 + English | 中文

# CSGHub SDK @@ -149,6 +149,19 @@ cache_dir = '/home/test/' result = file_download(repo_id, file_name='README.md', cache_dir=cache_dir, endpoint=endpoint, token=token) ``` +### Upload file + +```python +from pycsghub.file_upload import http_upload_file + +token = "3b77c98077b415ca381ded189b86d5df226e3776" + +endpoint = "https://hub.opencsg.com" +repo_type = "model" +repo_id = 'wanghh2000/myprivate1' +result = http_upload_file(repo_id, endpoint=endpoint, token=token, repo_type='model', file_path='test1.txt') +``` + ### Model loading compatible with huggingface The transformers library supports directly inputting the repo_id from Hugging Face to download and load related models, as shown below: From f4c6f320847dcc748a7777372649bd5756402fef Mon Sep 17 00:00:00 2001 From: Sean <38311363@qq.com> Date: Mon, 29 Jul 2024 21:33:31 +0800 Subject: [PATCH 2/2] Add case of upload mulit-files --- README.md | 16 ++++++++++++++++ README_EN.md | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/README.md b/README.md index 00f4d38..bb4facb 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,22 @@ repo_id = 'wanghh2000/myprivate1' result = http_upload_file(repo_id, endpoint=endpoint, token=token, repo_type='model', file_path='test1.txt') ``` +### 多文件上传 + +```python +from pycsghub.file_upload import http_upload_file + +token = "3b77c98077b415ca381ded189b86d5df226e3776" + +endpoint = "https://hub.opencsg.com" +repo_type = "model" +repo_id = 'wanghh2000/myprivate1' + +repo_files = ["1.txt", "2.txt"] +for item in repo_files: + http_upload_file(repo_id=repo_id, repo_type=repo_type, file_path=item, endpoint=endpoint, token=token) +``` + ### 兼容huggingface的模型加载 huggingface的transformers库支持直接输入huggingface上的repo_id以下载并读取相关模型,如下列所示: diff --git a/README_EN.md b/README_EN.md index c2cd762..9066ee4 100644 --- a/README_EN.md +++ b/README_EN.md @@ -162,6 +162,22 @@ repo_id = 'wanghh2000/myprivate1' result = http_upload_file(repo_id, endpoint=endpoint, token=token, repo_type='model', file_path='test1.txt') ``` +### Upload multi-files + +```python +from pycsghub.file_upload import http_upload_file + +token = "3b77c98077b415ca381ded189b86d5df226e3776" + +endpoint = "https://hub.opencsg.com" +repo_type = "model" +repo_id = 'wanghh2000/myprivate1' + +repo_files = ["1.txt", "2.txt"] +for item in repo_files: + http_upload_file(repo_id=repo_id, repo_type=repo_type, file_path=item, endpoint=endpoint, token=token) +``` + ### Model loading compatible with huggingface The transformers library supports directly inputting the repo_id from Hugging Face to download and load related models, as shown below: