-
Notifications
You must be signed in to change notification settings - Fork 0
New/bizyair cli #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: old/siliconcloud-cli
Are you sure you want to change the base?
Conversation
cmd/cmd.go
Outdated
@@ -2,6 +2,7 @@ package cmd | |||
|
|||
import ( | |||
"fmt" | |||
|
|||
"github.com/cloudwego/hertz/cmd/hz/util/logs" | |||
"github.com/siliconflow/siliconcloud-cli/config" | |||
"github.com/siliconflow/siliconcloud-cli/meta" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
仓库地址变了,这些是不是应该同步更新 https://github.com/siliconflow/bizyair-cli
cmd/upload.go
Outdated
// modelExistResp, err := client.CheckModel(args.Type, args.Name) | ||
// if err != nil { | ||
// return err | ||
// } | ||
|
||
// if modelExistResp.Data.Exists { | ||
// if !args.Overwrite { | ||
// return cli.Exit(fmt.Sprintf("Model already exists, use --overwrite to overwrite it"), meta.LoadError) | ||
// } | ||
// // TODO: overwrite model, | ||
// // api:{BIZYAIR_SERVER_ADDRESS}/bizy_models/{model_id} | ||
// // struct:{"name": name, "type": type_, "versions": versions} | ||
// return cli.Exit("Overwrite is not supported!", meta.LoadError) | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不必要是注释可以删除
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前 go build 得到的工具名称还是 siliconcloud-cli,把这个重新设置下,生成 bizycli
吧
README.md
Outdated
siliconcloud upload -n mymodel -t [Type] \ | ||
-v "v1" -b basemodel1 -p /local/path/file1 -i "file1" -cover "${url1};${url2}" \ | ||
-v "v2" -b basemodel2 -p /local/path/file2 -cover "${url3}" \ | ||
-v "v3" -b basemodel3 -p /local/path/file3 \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的 basemodel 的选项,不知道可否放到命令行工具的 --help
里。
我是翻源码才跑通这个的:
./siliconcloud-cli upload -type bizyair/checkpoint --path /maasjfs/graphs/comfybridges_shared_cache/models/checkpoints/sdxl/Juggernaut-XL_v9_RunDiffusionPhoto_v2.safetensors -name mysdxl --version v1 --base SDXL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i, fileToUpload := range filesToUpload { | ||
// calculate file hash | ||
sha256sum, err := calculateHash(fileToUpload.Path) | ||
sha256sum, md5_hash, err := calculateHash(fileToUpload.Path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 计算文件签名
@@ -138,17 +125,17 @@ func Upload(c *cli.Context) error { | |||
logs.Debugf(fmt.Sprintf("file: %s, signature: %s", fileToUpload.RelPath, fileToUpload.Signature)) | |||
|
|||
// pass sha256sum to the server | |||
sign, err := client.Sign(sha256sum) | |||
ossCert, err := client.OssSign(sha256sum, args.Type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 通过签名换凭证
if fileRecord.Id == 0 { | ||
// upload file | ||
fileStorage := sign.Data.Storage | ||
fileStorage := ossCert.Data.Storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 通过上一步换到的签名,上传 oss 文件
@@ -160,46 +147,49 @@ func Upload(c *cli.Context) error { | |||
} | |||
|
|||
// commit | |||
newFileRecord, err := client.CommitFile(fileToUpload.Signature, fileRecord.ObjectKey) | |||
_, err = client.CommitFileV2(fileToUpload.Signature, fileRecord.ObjectKey, md5_hash, args.Type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- commit file
_, err = client.CommitModel(args.Name, args.Type, args.Overwrite, modelFiles) | ||
} | ||
// upload versions | ||
_, err = client.CommitModelV2(args.Name, args.Type, versionList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 发布 model
|
||
func (c *Client) CommitModelV2(modelName string, modelType string, modelVersion []*ModelVersion) (*Response[ModelCommitResp], error) { | ||
serverUrl := fmt.Sprintf("%s/x/%s/bizy_models", c.Domain, meta.APIv1) | ||
body, statusCode, err := c.doPost(serverUrl, ModelCommitReqV2{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 发布模型
此为新版本的BizyAir-Cli,修改了模型upload协议,支持多版本上传,单个版本中只能包含一个文件。
上传示例:
-b
,-v
,-cover
,-p
的顺序没有要求,支持同时上传多个版本,cli会按照顺序将-b
,-v
,-cover
,-p
关联起来。在windows环境下,可执行文件在
bizyair-cli/execs/windows/bizyair-v0.0.1.exe
,如果有go环境的话,直接在根目录go run main.go
后面接上参数,也可以。
mac环境也类似。