Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangkx1
prj_csghub
Commits
d5901a68
Commit
d5901a68
authored
Apr 28, 2026
by
wangkx1
Browse files
init
parents
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
0 deletions
+98
-0
auto_uoload.py
auto_uoload.py
+81
-0
change_private.patch
change_private.patch
+11
-0
run.sh
run.sh
+6
-0
No files found.
auto_uoload.py
0 → 100644
View file @
d5901a68
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
change_private.patch
0 → 100644
View file @
d5901a68
--- /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
run.sh
0 → 100644
View file @
d5901a68
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment