Commit d5901a68 authored by wangkx1's avatar wangkx1
Browse files

init

parents
from pycsghub.upload_large_folder.main import upload_large_folder_internal
from pycsghub.upload_large_folder.main import create_repo
from pycsghub.csghub_api import CsgHubApi
import os
import argparse
BASE_URL = "http://10.20.100.5:4997"
TOKEN = "a2683e780fee4aa4b16cbedee0f75a45"
def upload(local_path, repo_id, repo_type="model"):
csg_api = CsgHubApi()
use_full_repo_id = f"root/{repo_id}"
repoExist, branchExist = csg_api.repo_branch_exists(
repo_id=use_full_repo_id, repo_type=repo_type, revision="v1",
endpoint=BASE_URL, token=TOKEN)
if repoExist:
print(f"{repo_id} has exists.")
return
else:
create_repo(
api=csg_api,
repo_id=use_full_repo_id,
repo_type=repo_type,
revision="v1",
endpoint=BASE_URL,
token=TOKEN
)
upload_large_folder_internal(
repo_id=use_full_repo_id,
local_path=local_path,
repo_type=repo_type,
revision="v1",
endpoint=BASE_URL,
token=TOKEN,
allow_patterns=None,
ignore_patterns=None,
num_workers=1,
print_report=False,
print_report_every=1,
)
if __name__ == "__main__":
# 创建命令行参数解析器
parser = argparse.ArgumentParser(description="自动上传模型到CSGHUB")
# 添加本地模型路径参数
parser.add_argument(
"local_path",
type=str,
help="本地模型文件夹的路径"
)
# 解析命令行参数
args = parser.parse_args()
# 获取本地模型路径
local_path = args.local_path
# 判断本地模型路径是否存在
if not os.path.exists(local_path):
print(f"错误: 本地模型路径 '{local_path}' 不存在")
exit(1)
if not os.path.isdir(local_path):
print(f"错误: 本地模型路径 '{local_path}' 不是一个文件夹")
exit(1)
# 从本地路径中提取仓库名称(使用文件夹名)
repo_id = os.path.basename(local_path)
print(f"开始上传本地模型: {local_path}")
print(f"目标仓库: {repo_id}")
# 执行上传
upload(local_path, repo_id)
\ No newline at end of file
--- /usr/local/lib/python3.10/dist-packages/pycsghub/csghub_api.py 2026-04-12 00:00:00.000000000 +0000
+++ /usr/local/lib/python3.10/dist-packages/pycsghub/csghub_api.py 2026-04-12 00:00:00.000000000 +0000
@@ -178,7 +178,7 @@
"name": name,
"nickname": name,
"default_branch": DEFAULT_REVISION,
- "private": True,
+ "private": False,
"license": DEFAULT_LICENCE,
}
\ No newline at end of file
pip install csghub-sdk==0.7.10
patch /usr/local/lib/python3.10/dist-packages/pycsghub/csghub_api.py < change_private.patch
sed -n '178,182p' /usr/local/lib/python3.10/dist-packages/pycsghub/csghub_api.py
python3 auto_upload.py <model-file>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment