Skip to content

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

Open
wants to merge 8 commits into
base: old/siliconcloud-cli
Choose a base branch
from
Open

Conversation

RogueServitor-495
Copy link
Collaborator

@RogueServitor-495 RogueServitor-495 commented Apr 7, 2025

此为新版本的BizyAir-Cli,修改了模型upload协议,支持多版本上传,单个版本中只能包含一个文件。

上传示例:

bizyair upload -n mymodel -t Checkpoint -b SDXL -v "v1" -i "upload my model"  -cover "https://framerusercontent.com/images/HANbQuA2ieQl0E9kk3SpEkNpDRk.png?scale-down-to=512;https://avatars.githubusercontent.com/u/143005960?s=200&v=4"  -p path/to/file 

-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环境也类似。

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"
Copy link
Collaborator

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
Comment on lines 110 to 123
// 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)
// }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不必要是注释可以删除

Copy link
Collaborator

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 \
Copy link
Collaborator

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按上面方法上传的模型,在 BizyAir 中查看,是不正常的。如下:

image

zheng正常的应该是这样:

image

for i, fileToUpload := range filesToUpload {
// calculate file hash
sha256sum, err := calculateHash(fileToUpload.Path)
sha256sum, md5_hash, err := calculateHash(fileToUpload.Path)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 计算文件签名

@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 通过签名换凭证

if fileRecord.Id == 0 {
// upload file
fileStorage := sign.Data.Storage
fileStorage := ossCert.Data.Storage
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 通过上一步换到的签名,上传 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. commit file

_, err = client.CommitModel(args.Name, args.Type, args.Overwrite, modelFiles)
}
// upload versions
_, err = client.CommitModelV2(args.Name, args.Type, versionList)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 发布 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{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 发布模型

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants