-
Notifications
You must be signed in to change notification settings - Fork 13
[feat][meta] Modelscope download and access #106
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
Conversation
| } | ||
|
|
||
| // NewModelscopeHandler 创建模型代理处理器实例 | ||
| func NewModelscopeHandler(ModelscopeService *service.ModelscopeService) *ModelscopeHandler { |
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.
小写变量名
config/config.yaml
Outdated
| chunkSize: 8388608 # 8MB分块,16*1024*1024的数值结果 | ||
| maxRetry: 5 # 超时重试次数 | ||
| retryDelay: 3 # 重试间隔,单位秒(S)(原配置为5*time.Second,YAML中简化为数值+注释) | ||
| minFileSize: 1 # 最小缓存文件大小,单位字节(B) |
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.
参数去掉
config/config.yaml
Outdated
| webhook: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=73662ac1-1055-48a7-8c89-37964b5f4fdc111 # 企业微信机器人Webhook地址 | ||
|
|
||
| modelscope: | ||
| modelCacheRoot: ./repos/modelscope/models # 模型缓存根目录 |
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.
写到常量
| func (h *ModelscopeHandler) ModelInfoHandler(c echo.Context) error { | ||
| parts := strings.Split(strings.Trim(c.Request().URL.Path, "/"), "/") | ||
|
|
||
| org, repo, repoType := parts[3], parts[4], parts[2] |
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.
判断长度
pkg/util/modelscope_util.go
Outdated
| } | ||
|
|
||
| // createHTTPClient 创建宽松超时的HTTP客户端 | ||
| func CreateHTTPClient() *http.Client { |
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.
共用一个client实例
| readSize = int64(len(buf)) | ||
| } | ||
|
|
||
| n, err := cacheFile.Read(buf[:readSize]) |
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.
经过测试同时读取8个本地10GB缓存文件数据,占用内存只有95.7MB
Modelscope download and access