Commit 84f93e11 authored by wangkx1's avatar wangkx1
Browse files

init

parent fbaa7b4c
......@@ -8,7 +8,7 @@ import argparse
BASE_URL = "http://10.20.100.5:4997"
TOKEN = "a2683e780fee4aa4b16cbedee0f75a45"
def upload(local_path, repo_id, repo_type="model"):
def upload(local_path, repo_id, repo_type="model", force=False):
csg_api = CsgHubApi()
use_full_repo_id = f"root/{repo_id}"
......@@ -17,8 +17,11 @@ def upload(local_path, repo_id, repo_type="model"):
endpoint=BASE_URL, token=TOKEN)
if repoExist:
print(f"{repo_id} has exists.")
return
if not force:
print(f"{repo_id} has exists. Use --force to update it.")
return
else:
print(f"{repo_id} has exists. Updating it because --force is set.")
else:
create_repo(
api=csg_api,
......@@ -55,9 +58,16 @@ if __name__ == "__main__":
help="本地模型文件夹的路径"
)
# 添加强制更新参数
parser.add_argument(
"--force",
action="store_true",
help="强制更新远程仓库,即使仓库已存在"
)
# 解析命令行参数
args = parser.parse_args()
# 获取本地模型路径
local_path = args.local_path
......@@ -77,4 +87,4 @@ if __name__ == "__main__":
print(f"目标仓库: {repo_id}")
# 执行上传
upload(local_path, repo_id)
\ No newline at end of file
upload(local_path, repo_id, force=args.force)
\ 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