forked from JointCloud/pcm-coordinator
Compare commits
88 Commits
Author | SHA1 | Date |
---|---|---|
|
1d51c0bcbd | |
|
a7599f67e2 | |
|
3080046eb7 | |
|
5b8465ca65 | |
|
fb4fc498ca | |
|
ae411caf7a | |
|
078ffecc6a | |
|
a8f2b46f1c | |
|
d777cb359c | |
|
87c4555d04 | |
|
c45af4d037 | |
|
52bab362ac | |
|
e3e9a46352 | |
|
eebb983c4b | |
|
3dde5aa691 | |
|
1e9ce8a151 | |
|
84df5c7572 | |
|
796f5afe07 | |
|
f4093deb9a | |
|
1bb4a47ac9 | |
|
f31284ff45 | |
|
7c4b471eb2 | |
|
7f31f95651 | |
|
e3b83f6535 | |
|
8f2ac755f3 | |
|
580ae56220 | |
|
64f183b77e | |
|
d907a498a2 | |
|
71b7accd46 | |
|
8645e4ce15 | |
|
7cbaf50ad4 | |
|
b7838d8f6b | |
|
2a7eeec140 | |
|
86418e14ba | |
|
0f5f34d616 | |
|
437d3a36b7 | |
|
7e7eb6bcb9 | |
|
2d48dac755 | |
|
9660ea2405 | |
|
3bbf914d39 | |
|
b026e33352 | |
|
c4c2ab8fdd | |
|
600999adbc | |
|
9fc7692cf7 | |
|
21fd8cf886 | |
|
4866e1679f | |
|
630ed73490 | |
|
63fbff1b56 | |
|
6d4d430ac2 | |
|
db824e8f2e | |
|
40c695048f | |
|
fb95b3126f | |
|
2095c8baee | |
|
4c64c4781c | |
|
51bb301987 | |
|
4f7e622c54 | |
|
5c9609b143 | |
|
dfb16c919d | |
|
3191dd67ee | |
|
50c594f817 | |
|
12ca4d7bdd | |
|
a3f4540e8d | |
|
2d1a34712b | |
|
b2d525b2fd | |
|
ae4c26cce8 | |
|
7c7beeb5e2 | |
|
28d49b1a13 | |
|
a02581d9d1 | |
|
a9b5c42c5f | |
|
b23d85fa84 | |
|
dddbe7cd18 | |
|
3dd4eb610f | |
|
c6ea68e62c | |
|
8e34db7011 | |
|
c566f49ac2 | |
|
c7b10f2aec | |
|
2c8cec00c3 | |
|
b858434acd | |
|
a7f859e30d | |
|
0f4117443e | |
|
3448a8c4e0 | |
|
d40b46439c | |
|
62bf3561fa | |
|
867e75c75e | |
|
c797cc12a5 | |
|
27c660d415 | |
|
1df20b161a | |
|
2a5268e3ca |
|
@ -25,3 +25,4 @@ configs/tenanter.yaml
|
|||
|
||||
log/
|
||||
/cache/
|
||||
/vendor/
|
||||
|
|
|
@ -1827,8 +1827,8 @@ service AICore-api {
|
|||
|
||||
type (
|
||||
ChatReq{
|
||||
ApiUrl string `json:"apiUrl"`
|
||||
Method string `json:"method,optional"`
|
||||
id uint `json:"id,string"`
|
||||
Method string `json:"method,optional"`
|
||||
ReqData map[string]interface{} `json:"reqData"`
|
||||
}
|
||||
ChatResult{
|
||||
|
|
|
@ -790,7 +790,14 @@ type (
|
|||
CreateTime string `json:"createTime,omitempty" db:"create_time" gorm:"autoCreateTime"`
|
||||
}
|
||||
AdapterResp {
|
||||
Data AdapterInfo `json:"data,omitempty"`
|
||||
Id string `json:"id,omitempty" db:"id"`
|
||||
Name string `json:"name,omitempty" db:"name"`
|
||||
Type string `json:"type,omitempty" db:"type"`
|
||||
ResourceType string `json:"resourceType,omitempty" db:"resource_type"`
|
||||
Nickname string `json:"nickname,omitempty" db:"nickname"`
|
||||
Version string `json:"version,omitempty" db:"version"`
|
||||
Server string `json:"server,omitempty" db:"server"`
|
||||
CreateTime string `json:"createTime,omitempty" db:"create_time" gorm:"autoCreateTime"`
|
||||
}
|
||||
AdapterListResp {
|
||||
List []AdapterInfo `json:"list,omitempty"`
|
||||
|
|
|
@ -1,6 +1,25 @@
|
|||
syntax = "v1"
|
||||
|
||||
type (
|
||||
/******************image inference*************************/
|
||||
DeployInstance {
|
||||
Id string `json:"id"`
|
||||
DeployTaskId string `json:"deployTaskId"`
|
||||
InstanceId string `json:"instanceId"`
|
||||
InstanceName string `json:"instanceName"`
|
||||
AdapterId string `json:"adapterId"`
|
||||
AdapterName string `json:"adapterName"`
|
||||
ClusterId string `json:"clusterId"`
|
||||
ClusterName string `json:"clusterName"`
|
||||
ModelName string `json:"modelName"`
|
||||
ModelType string `json:"modelType"`
|
||||
InferCard string `json:"inferCard"`
|
||||
Status string `json:"status"`
|
||||
CreateTime string `json:"createTime"`
|
||||
UpdateTime string `json:"updateTime"`
|
||||
ClusterType string `json:"clusterType"`
|
||||
}
|
||||
|
||||
/******************image inference*************************/
|
||||
ModelTypesResp {
|
||||
ModelTypes []string `json:"types"`
|
||||
|
@ -18,17 +37,10 @@ type (
|
|||
ImageInferenceReq {
|
||||
TaskName string `form:"taskName"`
|
||||
TaskDesc string `form:"taskDesc"`
|
||||
ModelName string `form:"modelName"`
|
||||
ModelType string `form:"modelType"`
|
||||
AdapterId string `form:"adapterId"`
|
||||
AiClusterIds []string `form:"aiClusterIds,optional"`
|
||||
ResourceType string `form:"resourceType,optional"`
|
||||
ComputeCard string `form:"card,optional"`
|
||||
Strategy string `form:"strategy"`
|
||||
StaticWeightMap map[string]int32 `form:"staticWeightMap,optional"`
|
||||
Params []string `form:"params,optional"`
|
||||
Envs []string `form:"envs,optional"`
|
||||
Cmd string `form:"cmd,optional"`
|
||||
InstanceIds []int64 `form:"instanceIds"`
|
||||
Strategy string `form:"strategy,,optional"`
|
||||
StaticWeightMap map[string]map[string]int32 `form:"staticWeightMap,optional"`
|
||||
Replica int32 `form:"replicas,optional"`
|
||||
}
|
||||
|
||||
|
@ -76,6 +88,18 @@ type (
|
|||
|
||||
}
|
||||
|
||||
/******************TextToImage inference*************************/
|
||||
TextToImageInferenceReq{
|
||||
TaskName string `form:"taskName"`
|
||||
TaskDesc string `form:"taskDesc"`
|
||||
ModelName string `form:"modelName"`
|
||||
ModelType string `form:"modelType"`
|
||||
AiClusterIds []string `form:"aiClusterIds"`
|
||||
}
|
||||
TextToImageInferenceResp{
|
||||
Result []byte `json:"result"`
|
||||
}
|
||||
|
||||
/******************Deploy instance*************************/
|
||||
DeployInstanceListReq{
|
||||
PageInfo
|
||||
|
@ -120,4 +144,70 @@ type (
|
|||
Running int32 `json:"running"`
|
||||
Total int32 `json:"total"`
|
||||
}
|
||||
|
||||
StartAllByDeployTaskIdReq {
|
||||
Id string `json:"deployTaskId"`
|
||||
}
|
||||
|
||||
StartAllByDeployTaskIdResp {
|
||||
|
||||
}
|
||||
|
||||
StopAllByDeployTaskIdReq {
|
||||
Id string `json:"deployTaskId"`
|
||||
}
|
||||
|
||||
StopAllByDeployTaskIdResp {
|
||||
|
||||
}
|
||||
|
||||
GetRunningInstanceReq {
|
||||
Id string `form:"deployTaskId"`
|
||||
AdapterId string `form:"adapterId"`
|
||||
}
|
||||
GetRunningInstanceResp {
|
||||
List interface{} `json:"list"`
|
||||
}
|
||||
|
||||
GetDeployTasksByTypeReq {
|
||||
ModelType string `form:"modelType"`
|
||||
}
|
||||
|
||||
GetDeployTasksByTypeResp {
|
||||
List interface{} `json:"list"`
|
||||
}
|
||||
|
||||
CreateDeployTaskReq {
|
||||
TaskName string `form:"taskName"`
|
||||
TaskDesc string `form:"taskDesc"`
|
||||
ModelName string `form:"modelName"`
|
||||
ModelType string `form:"modelType"`
|
||||
AdapterClusterMap map[string][]string `form:"adapterClusterMap"`
|
||||
}
|
||||
|
||||
CreateDeployTaskResp {
|
||||
|
||||
}
|
||||
|
||||
GetAdaptersByModelReq {
|
||||
ModelName string `form:"modelName"`
|
||||
ModelType string `form:"modelType"`
|
||||
}
|
||||
|
||||
GetAdaptersByModelResp {
|
||||
Adapters []*AdapterAvail `json:"adapters"`
|
||||
}
|
||||
|
||||
AdapterAvail {
|
||||
AdapterId string `json:"adapterId"`
|
||||
AdapterName string `json:"taskName"`
|
||||
Clusters []*ClusterAvail `json:"clusters"`
|
||||
}
|
||||
|
||||
ClusterAvail {
|
||||
ClusterId string `json:"clusterId"`
|
||||
ClusterName string `json:"clusterName"`
|
||||
}
|
||||
|
||||
|
||||
)
|
||||
|
|
22
desc/pcm.api
22
desc/pcm.api
|
@ -386,8 +386,8 @@ service pcm {
|
|||
|
||||
/***********chat***********/
|
||||
@doc "文本识别"
|
||||
@handler ProxyApiHandler
|
||||
post /ai/chat (ChatReq) returns (CommonResp)
|
||||
@handler ChatHandler
|
||||
post /ai/chat (ChatReq) returns (ChatResult)
|
||||
/******chat end***********/
|
||||
}
|
||||
|
||||
|
@ -959,6 +959,24 @@ service pcm {
|
|||
|
||||
@handler InferenceTaskStatHandler
|
||||
get /inference/taskStat (InferenceTaskStatReq) returns (InferenceTaskStatResp)
|
||||
|
||||
@handler StartAllByDeployTaskId
|
||||
post /inference/startAll (StartAllByDeployTaskIdReq) returns (StartAllByDeployTaskIdResp)
|
||||
|
||||
@handler StopAllByDeployTaskId
|
||||
post /inference/stopAll (StopAllByDeployTaskIdReq) returns (StopAllByDeployTaskIdResp)
|
||||
|
||||
@handler GetRunningInstanceById
|
||||
get /inference/getRunningInstanceById (GetRunningInstanceReq) returns (GetRunningInstanceResp)
|
||||
|
||||
@handler GetDeployTasksByType
|
||||
get /inference/getDeployTasksByType (GetDeployTasksByTypeReq) returns (GetDeployTasksByTypeResp)
|
||||
|
||||
@handler CreateDeployTask
|
||||
post /inference/createDeployTask (CreateDeployTaskReq) returns (CreateDeployTaskResp)
|
||||
|
||||
@handler GetAdaptersByModel
|
||||
get /inference/getAdaptersByModel (GetAdaptersByModelReq) returns (GetAdaptersByModelResp)
|
||||
}
|
||||
|
||||
@server(
|
||||
|
|
16
go.mod
16
go.mod
|
@ -19,8 +19,8 @@ require (
|
|||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/zeromicro/go-zero v1.6.6
|
||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240725071305-f751eec4dde1
|
||||
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240722092017-50d17f36d023
|
||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240718073732-bc5d687f6330
|
||||
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240724095608-1727d09f030c
|
||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110
|
||||
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203
|
||||
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5
|
||||
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d
|
||||
|
@ -37,7 +37,6 @@ require (
|
|||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||
github.com/alecthomas/kingpin/v2 v2.4.0 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 // indirect
|
||||
github.com/armon/go-metrics v0.4.1 // indirect
|
||||
|
@ -51,14 +50,8 @@ require (
|
|||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/distribution/reference v0.6.0 // indirect
|
||||
github.com/docker/distribution v2.8.3+incompatible // indirect
|
||||
github.com/docker/docker v27.1.1+incompatible // indirect
|
||||
github.com/docker/go-connections v0.5.0 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
|
||||
github.com/fatih/color v1.17.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/go-kit/log v0.2.1 // indirect
|
||||
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
||||
|
@ -94,7 +87,6 @@ require (
|
|||
github.com/hashicorp/golang-lru v0.6.0 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/hashicorp/memberlist v0.5.0 // indirect
|
||||
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.106 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
|
@ -108,15 +100,12 @@ require (
|
|||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/miekg/dns v1.1.58 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/moby/docker-image-spec v1.3.1 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
|
||||
github.com/oklog/run v1.1.0 // indirect
|
||||
github.com/oklog/ulid v1.3.1 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.1.0 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/openzipkin/zipkin-go v0.4.3 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
|
@ -135,7 +124,6 @@ require (
|
|||
go.etcd.io/etcd/client/pkg/v3 v3.5.15 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.15 // indirect
|
||||
go.mongodb.org/mongo-driver v1.13.1 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
|
||||
go.opentelemetry.io/otel v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
|
||||
|
|
44
go.sum
44
go.sum
|
@ -42,8 +42,6 @@ github.com/JCCE-nudt/apigw-go-sdk v0.0.0-20230525025609-34159d6f2818 h1:QLulhUyx
|
|||
github.com/JCCE-nudt/apigw-go-sdk v0.0.0-20230525025609-34159d6f2818/go.mod h1:j+am5/1URgsvyhOAyURFR9vH3malaW7Tq6d33OyPsnM=
|
||||
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
|
||||
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY=
|
||||
github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
|
@ -100,16 +98,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
|
|||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
|
||||
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
|
||||
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
|
||||
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/docker v27.1.1+incompatible h1:hO/M4MtV36kzKldqnA37IWhebRA+LnqqcqDja6kVaKY=
|
||||
github.com/docker/docker v27.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
|
||||
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
|
||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU=
|
||||
github.com/emicklei/go-restful/v3 v3.12.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
|
@ -118,8 +106,6 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
|
|||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
|
||||
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||
|
@ -253,7 +239,6 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
|||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
|
||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
|
||||
|
@ -285,8 +270,6 @@ github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs
|
|||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/hashicorp/memberlist v0.5.0 h1:EtYPN8DpAURiapus508I4n9CzHs2W+8NZGbmmR/prTM=
|
||||
github.com/hashicorp/memberlist v0.5.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0=
|
||||
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.106 h1:qjB7sACTAlHcwYKJgJB0kivPWpt7uujl/4YHFUHLpXc=
|
||||
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.106/go.mod h1:JWz2ujO9X3oU5wb6kXp+DpR2UuDj2SldDbX8T0FSuhI=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
|
@ -356,8 +339,6 @@ github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4=
|
|||
github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
|
||||
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
|
@ -383,10 +364,6 @@ github.com/onsi/ginkgo/v2 v2.17.2 h1:7eMhcy3GimbsA3hEnVKdw/PQM9XN9krpKVXsZdph0/g
|
|||
github.com/onsi/ginkgo/v2 v2.17.2/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc=
|
||||
github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
|
||||
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
|
||||
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
|
||||
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7sjsSdg=
|
||||
|
@ -475,7 +452,6 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
|
|||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
|
||||
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
|
||||
|
@ -497,12 +473,10 @@ github.com/zeromicro/go-zero v1.6.6 h1:nZTVYObklHiBdYJ/nPoAZ8kGVAplWSDjT7DGE7ur0
|
|||
github.com/zeromicro/go-zero v1.6.6/go.mod h1:olKf1/hELbSmuIgLgJeoeNVp3tCbLqj6UmO7ATSta4A=
|
||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240725071305-f751eec4dde1 h1:DicBXoQiC6mumMBeyqSPNrsjtqJIgk5Pv2hscu2xryw=
|
||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240725071305-f751eec4dde1/go.mod h1:3eECiw9O2bIFkkePlloKyLNXiqBAhOxNrDoGaaGseGY=
|
||||
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240722092017-50d17f36d023 h1:9DNobl0gvRCSXtjyMsfUwq0w0TMvds4rqNRsEqeX4j8=
|
||||
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240722092017-50d17f36d023/go.mod h1:/eOmBFZKWGoabG3sRVkVvIbLwsd2631k4jkUBR6x1AA=
|
||||
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240724095608-1727d09f030c h1:CodJeGgTYJwA6NDHFnw6B+4pBXUl79tvAcECq39tgZI=
|
||||
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240724095608-1727d09f030c/go.mod h1:/eOmBFZKWGoabG3sRVkVvIbLwsd2631k4jkUBR6x1AA=
|
||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240718073732-bc5d687f6330 h1:WxPrFSO6LjDCr+k7nmNFlPst8CtoTHQ2iSjv+D2rNnM=
|
||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240718073732-bc5d687f6330/go.mod h1:QOD5+/l2D+AYBjF2h5T0mdJyfGAmF78QmeKdbBXbjLQ=
|
||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110 h1:GaXwr5sgDh0raHjUf9IewTvnRvajYea7zbLsaerYyXo=
|
||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110/go.mod h1:QOD5+/l2D+AYBjF2h5T0mdJyfGAmF78QmeKdbBXbjLQ=
|
||||
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 h1:s6PsZ1+bev294IWdZRlV7mnOwI1+UzFcldVW/BqhQzI=
|
||||
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8=
|
||||
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 h1:+/5vnzkJBfMRnya1NrhOzlroUtRa5ePiYbPKlHLoLV0=
|
||||
|
@ -515,7 +489,6 @@ go.etcd.io/etcd/client/pkg/v3 v3.5.15 h1:fo0HpWz/KlHGMCC+YejpiCmyWDEuIpnTDzpJLB5
|
|||
go.etcd.io/etcd/client/pkg/v3 v3.5.15/go.mod h1:mXDI4NAOwEiszrHCb0aqfAYNCrZP4e9hRca3d1YK8EU=
|
||||
go.etcd.io/etcd/client/v3 v3.5.15 h1:23M0eY4Fd/inNv1ZfU3AxrbbOdW79r9V9Rl62Nm6ip4=
|
||||
go.etcd.io/etcd/client/v3 v3.5.15/go.mod h1:CLSJxrYjvLtHsrPKsy7LmZEE+DK2ktfd2bN4RhBMwlU=
|
||||
go.mongodb.org/mongo-driver v1.12.0/go.mod h1:AZkxhPnFJUoH7kZlFkVKucV20K387miPfm7oimrSmK0=
|
||||
go.mongodb.org/mongo-driver v1.13.1 h1:YIc7HTYsKndGK4RFzJ3covLz1byri52x0IoMB0Pt/vk=
|
||||
go.mongodb.org/mongo-driver v1.13.1/go.mod h1:wcDf1JBCXy2mOW0bWHwO/IOYqdca1MPCwDtFu/Z9+eo=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
|
@ -523,8 +496,6 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
|||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 h1:4K4tsIXefpVJtvA/8srF4V4y0akAoPHkIslgAkjixJA=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0/go.mod h1:jjdQuTGVsXV4vSs+CJ2qYDeDPf9yIJV23qlIzBm73Vg=
|
||||
go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
|
||||
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4=
|
||||
|
@ -564,12 +535,10 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
|
|||
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
|
@ -638,7 +607,6 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/
|
|||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
|
@ -725,7 +693,6 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
|
@ -734,7 +701,6 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
|||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
|
||||
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
@ -748,7 +714,6 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
|||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
@ -861,12 +826,8 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc
|
|||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240722135656-d784300faade h1:WxZOF2yayUHpHSbUE6NMzumUzBxYc3YGwo0YHnbzsJY=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240722135656-d784300faade/go.mod h1:mw8MG/Qz5wfgYr6VqVCiZcHe/GJEfI+oGGDCohaVgB0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a h1:YIa/rzVqMEokBkPtydCkx1VLmv3An1Uw7w1P1m6EhOY=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:AHT0dDg3SoMOgZGnZk29b5xTbPHMoEC8qthmBLJCpys=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade h1:oCRSWfwGXQsqlVdErcyTt4A93Y8fo0/9D4b1gnI++qo=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a h1:hqK4+jJZXCU4pW7jsAdGOVFIfLHQeV7LaizZKnZ84HI=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
|
@ -907,7 +868,6 @@ gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY=
|
|||
gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0=
|
||||
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
package ai
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func ProxyApiHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
func ChatHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ChatReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := ai.NewProxyApiLogic(r.Context(), svcCtx)
|
||||
resp, err := l.ProxyApi(&req)
|
||||
l := ai.NewChatLogic(r.Context(), svcCtx)
|
||||
resp, err := l.Chat(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
)
|
||||
|
||||
func CreateDeployTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CreateDeployTaskReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := inference.NewCreateDeployTaskLogic(r.Context(), svcCtx)
|
||||
resp, err := l.CreateDeployTask(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
)
|
||||
|
||||
func GetAdaptersByModelHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetAdaptersByModelReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := inference.NewGetAdaptersByModelLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetAdaptersByModel(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
)
|
||||
|
||||
func GetDeployTasksByTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetDeployTasksByTypeReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := inference.NewGetDeployTasksByTypeLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetDeployTasksByType(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
)
|
||||
|
||||
func GetRunningInstanceByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetRunningInstanceReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := inference.NewGetRunningInstanceByIdLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetRunningInstanceById(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
)
|
||||
|
||||
func StartAllByDeployTaskIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.StartAllByDeployTaskIdReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := inference.NewStartAllByDeployTaskIdLogic(r.Context(), svcCtx)
|
||||
resp, err := l.StartAllByDeployTaskId(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
)
|
||||
|
||||
func StopAllByDeployTaskIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.StopAllByDeployTaskIdReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := inference.NewStopAllByDeployTaskIdLogic(r.Context(), svcCtx)
|
||||
resp, err := l.StopAllByDeployTaskId(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
|
||||
}
|
||||
}
|
|
@ -460,7 +460,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/ai/chat",
|
||||
Handler: ai.ProxyApiHandler(serverCtx),
|
||||
Handler: ai.ChatHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/pcm/v1"),
|
||||
|
@ -1213,6 +1213,36 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
Path: "/inference/taskStat",
|
||||
Handler: inference.InferenceTaskStatHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/inference/startAll",
|
||||
Handler: inference.StartAllByDeployTaskIdHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/inference/stopAll",
|
||||
Handler: inference.StopAllByDeployTaskIdHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/inference/getRunningInstanceById",
|
||||
Handler: inference.GetRunningInstanceByIdHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/inference/getDeployTasksByType",
|
||||
Handler: inference.GetDeployTasksByTypeHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/inference/createDeployTask",
|
||||
Handler: inference.CreateDeployTaskHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/inference/getAdaptersByModel",
|
||||
Handler: inference.GetAdaptersByModelHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/pcm/v1"),
|
||||
)
|
||||
|
|
|
@ -27,11 +27,14 @@ func NewCreateAdapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre
|
|||
|
||||
func (l *CreateAdapterLogic) CreateAdapter(req *types.AdapterCreateReq) (resp *types.AdapterResp, err error) {
|
||||
adapter := types.AdapterInfo{}
|
||||
existAdapter := types.AdapterResp{}
|
||||
resp = &types.AdapterResp{}
|
||||
utils.Convert(req, &adapter)
|
||||
//check name
|
||||
exist := l.svcCtx.DbEngin.Table("t_adapter").Where("name = ?", req.Name).First(&types.AdapterInfo{}).Error
|
||||
exist := l.svcCtx.DbEngin.Table("t_adapter").Where("name = ?", req.Name).First(&existAdapter).Error
|
||||
if !errors.Is(exist, gorm.ErrRecordNotFound) {
|
||||
return nil, errors.New("name already exists")
|
||||
resp = &existAdapter
|
||||
return resp, errors.New("name already exists")
|
||||
}
|
||||
//check type
|
||||
var arr = [...]string{"0", "1", "2"}
|
||||
|
@ -60,8 +63,10 @@ func (l *CreateAdapterLogic) CreateAdapter(req *types.AdapterCreateReq) (resp *t
|
|||
adapter.CreateTime = time.Now().Format("2006-01-02 15:04:05")
|
||||
result := l.svcCtx.DbEngin.Table("t_adapter").Create(&adapter)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
return resp, result.Error
|
||||
}
|
||||
|
||||
return
|
||||
_ = l.svcCtx.DbEngin.Table("t_adapter").Where("name = ?", req.Name).First(&existAdapter).Error
|
||||
resp = &existAdapter
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
package ai
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/pkg/errors"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/hws"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ChatLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewChatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatLogic {
|
||||
return &ChatLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ChatLogic) Chat(req *types.ChatReq) (resp *types.ChatResult, err error) {
|
||||
resp = &types.ChatResult{}
|
||||
jsonBytes, err := json.Marshal(&req.ReqData)
|
||||
if err != nil {
|
||||
logx.Errorf("【序列化请求数据失败: %v】", err)
|
||||
return nil, errors.New("请求数据序列化失败")
|
||||
}
|
||||
|
||||
taskAi := models.TaskAi{}
|
||||
l.svcCtx.DbEngin.Model(models.TaskAi{}).Where("id", req.Id).Scan(&taskAi)
|
||||
logx.Infof("【开始处理请求,目标URL: %s】", taskAi.InferUrl)
|
||||
|
||||
// 构建 HTTP 请求
|
||||
request, err := http.NewRequest("POST", taskAi.InferUrl, bytes.NewBuffer(jsonBytes))
|
||||
if err != nil {
|
||||
logx.Errorf("【构建 HTTP 请求失败: %v】", err)
|
||||
return nil, errors.New("网络错误,请稍后重试")
|
||||
}
|
||||
client := resty.New().SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
|
||||
restReq := client.R()
|
||||
|
||||
//ModelArts
|
||||
cluster := models.CloudModel{}
|
||||
l.svcCtx.DbEngin.Table("t_cluster").Where("id", taskAi.ClusterId).Scan(&cluster)
|
||||
if strings.EqualFold(cluster.Label, constants.MODELARTS) {
|
||||
signer := &hws.Signer{
|
||||
Key: cluster.Ak,
|
||||
Secret: cluster.Sk,
|
||||
}
|
||||
if err := signer.Sign(request); err != nil {
|
||||
logx.Errorf("【接口签名错误: %v】", err)
|
||||
return nil, errors.New("网络错误,请稍后重试")
|
||||
}
|
||||
restReq.
|
||||
SetHeader("X-Project-Id", cluster.ProjectId).
|
||||
SetHeader("x-stage", "RELEASE").
|
||||
SetHeader("Authorization", request.Header.Get(hws.HeaderXAuthorization)).
|
||||
SetHeader("X-Sdk-Date", request.Header.Get(hws.HeaderXDateTime))
|
||||
}
|
||||
|
||||
response, err := restReq.
|
||||
SetHeader("Content-Type", "application/json").
|
||||
SetBody(jsonBytes).
|
||||
SetResult(&resp).
|
||||
Post(taskAi.InferUrl)
|
||||
|
||||
if err != nil {
|
||||
logx.Errorf("【远程调用接口URL:%s, 返回错误: %s】", taskAi.InferUrl, err.Error())
|
||||
return nil, errors.New("网络错误,请稍后重试")
|
||||
}
|
||||
|
||||
if response.StatusCode() != 200 {
|
||||
logx.Errorf("【远程调用接口URL:%s, 返回错误: %s】", taskAi.InferUrl, response.Body())
|
||||
return nil, errors.New("网络错误,请稍后重试")
|
||||
}
|
||||
|
||||
logx.Infof("【请求处理成功,目标URL: %s】", taskAi.InferUrl)
|
||||
return resp, nil
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
package ai
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/pkg/errors"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/hws"
|
||||
"net/http"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ProxyApiLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewProxyApiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProxyApiLogic {
|
||||
return &ProxyApiLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
XProjectID = "d18190e28e3f45a281ef0b0696ec9d52"
|
||||
XStage = "RELEASE"
|
||||
ContentType = "application/json"
|
||||
)
|
||||
|
||||
func (l *ProxyApiLogic) ProxyApi(req *types.ChatReq) (resp *types.ChatResult, err error) {
|
||||
logx.Infof("【开始处理请求,目标URL: %s】", req.ApiUrl)
|
||||
|
||||
jsonBytes, err := json.Marshal(&req.ReqData)
|
||||
if err != nil {
|
||||
logx.Errorf("【序列化请求数据失败: %v】", err)
|
||||
return nil, errors.New("请求数据序列化失败")
|
||||
}
|
||||
|
||||
resp = &types.ChatResult{}
|
||||
|
||||
// 构建 HTTP 请求
|
||||
request, err := http.NewRequest("POST", req.ApiUrl, bytes.NewBuffer(jsonBytes))
|
||||
if err != nil {
|
||||
logx.Errorf("【构建 HTTP 请求失败: %v】", err)
|
||||
return nil, errors.New("网络错误,请稍后重试")
|
||||
}
|
||||
|
||||
signer := &hws.Signer{
|
||||
Key: "UNEHPHO4Z7YSNPKRXFE4",
|
||||
Secret: "JWXCE9qcYbc7RjpSRIWt4WgG3ZKF6Q4lPzkJReX9",
|
||||
}
|
||||
|
||||
if err := signer.Sign(request); err != nil {
|
||||
logx.Errorf("【接口签名错误: %v】", err)
|
||||
return nil, errors.New("网络错误,请稍后重试")
|
||||
}
|
||||
|
||||
client := resty.New().SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
|
||||
|
||||
response, err := client.R().
|
||||
SetHeader("X-Project-Id", XProjectID).
|
||||
SetHeader("x-stage", XStage).
|
||||
SetHeader("Content-Type", ContentType).
|
||||
SetHeader("Authorization", request.Header.Get(hws.HeaderXAuthorization)).
|
||||
SetHeader("X-Sdk-Date", request.Header.Get(hws.HeaderXDateTime)).
|
||||
SetBody(jsonBytes).
|
||||
SetResult(&resp).
|
||||
Post(req.ApiUrl)
|
||||
|
||||
if err != nil {
|
||||
logx.Errorf("【远程调用接口URL:%s, 返回错误: %s】", req.ApiUrl, err.Error())
|
||||
return nil, errors.New("网络错误,请稍后重试")
|
||||
}
|
||||
|
||||
if response.StatusCode() != 200 {
|
||||
logx.Errorf("【远程调用接口URL:%s, 返回错误: %s】", req.ApiUrl, response.Body())
|
||||
return nil, errors.New("网络错误,请稍后重试")
|
||||
}
|
||||
|
||||
logx.Infof("【请求处理成功,目标URL: %s】", req.ApiUrl)
|
||||
return resp, nil
|
||||
}
|
|
@ -2,8 +2,6 @@ package ai
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
|
@ -37,10 +35,6 @@ func (l *TrainingTaskStatLogic) TrainingTaskStat() (resp *types.TrainingTaskStat
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if total == 0 {
|
||||
return nil, errors.New("get statistics failed")
|
||||
}
|
||||
|
||||
resp.Total = total
|
||||
resp.Running = running
|
||||
return resp, nil
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option"
|
||||
"strconv"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateDeployTaskLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateDeployTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDeployTaskLogic {
|
||||
return &CreateDeployTaskLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateDeployTaskLogic) CreateDeployTask(req *types.CreateDeployTaskReq) (resp *types.CreateDeployTaskResp, err error) {
|
||||
resp = &types.CreateDeployTaskResp{}
|
||||
|
||||
if len(req.AdapterClusterMap) == 0 {
|
||||
return nil, errors.New("adapters are empty")
|
||||
}
|
||||
|
||||
opt := &option.InferOption{
|
||||
TaskName: req.TaskName,
|
||||
ModelType: req.ModelType,
|
||||
ModelName: req.ModelName,
|
||||
Cmd: "",
|
||||
}
|
||||
|
||||
taskId, err := l.svcCtx.Scheduler.AiStorages.SaveInferDeployTask(req.TaskName, req.ModelName, req.ModelType, req.TaskDesc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for aid, v := range req.AdapterClusterMap {
|
||||
for _, cid := range v {
|
||||
err = l.createDeployInstance(taskId, aid, cid, opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (l *CreateDeployTaskLogic) createDeployInstance(taskId int64, adapterId string, clusterId string, opt *option.InferOption) error {
|
||||
cmap, found := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[adapterId]
|
||||
if !found {
|
||||
return errors.New("adapterId not exist: " + adapterId)
|
||||
}
|
||||
iCluster, found := cmap[clusterId]
|
||||
if !found {
|
||||
return errors.New("clusterId not exist: " + clusterId)
|
||||
}
|
||||
insId, err := iCluster.CreateInferDeployInstance(l.ctx, opt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
aid, err := strconv.ParseInt(adapterId, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cid, err := strconv.ParseInt(clusterId, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
adapterName, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(adapterId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clusterName, err := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(clusterId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ins, err := iCluster.GetInferDeployInstance(l.ctx, insId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = l.svcCtx.Scheduler.AiStorages.SaveInferDeployInstance(taskId, ins.InstanceId, ins.InstanceName, aid, adapterName, cid, clusterName, ins.ModelName, ins.ModelType, ins.InferCard)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -4,9 +4,12 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/common"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/updater"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||
"time"
|
||||
)
|
||||
|
||||
type DeployInstanceListLogic struct {
|
||||
|
@ -28,9 +31,8 @@ func (l *DeployInstanceListLogic) DeployInstanceList(req *types.DeployInstanceLi
|
|||
offset := req.PageSize * (req.PageNum - 1)
|
||||
resp = &types.DeployInstanceListResp{}
|
||||
|
||||
var list []*models.AiInferDeployInstance
|
||||
|
||||
tx := l.svcCtx.DbEngin.Raw("select * from ai_infer_deploy_instance").Scan(&list)
|
||||
var tasklist []*models.AiDeployInstanceTask
|
||||
tx := l.svcCtx.DbEngin.Raw("select * from ai_deploy_instance_task").Scan(&tasklist)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return nil, tx.Error
|
||||
|
@ -45,14 +47,66 @@ func (l *DeployInstanceListLogic) DeployInstanceList(req *types.DeployInstanceLi
|
|||
return resp, err
|
||||
}
|
||||
|
||||
err = tx.Order("create_time desc").Find(&list).Error
|
||||
err = tx.Order("create_time desc").Find(&tasklist).Error
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
resp.List = &list
|
||||
|
||||
deployTasks := l.GenerateDeployTasks(tasklist)
|
||||
slices := make([][]*models.AiInferDeployInstance, len(deployTasks))
|
||||
for i := 0; i < len(deployTasks); i++ {
|
||||
slices[i] = deployTasks[i].Instances
|
||||
}
|
||||
list := common.ConcatMultipleSlices(slices)
|
||||
|
||||
if len(list) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
go updater.UpdateDeployInstanceStatusBatch(l.svcCtx, list)
|
||||
|
||||
ins := list[0]
|
||||
for i := range list {
|
||||
uTime, _ := time.Parse(time.RFC3339, ins.UpdateTime)
|
||||
latest, _ := time.Parse(time.RFC3339, list[i].UpdateTime)
|
||||
if latest.After(uTime) {
|
||||
ins = list[i]
|
||||
}
|
||||
}
|
||||
|
||||
go updater.UpdateDeployInstanceStatus(l.svcCtx, ins, true)
|
||||
go updater.UpdateDeployTaskStatus(l.svcCtx)
|
||||
|
||||
resp.List = &deployTasks
|
||||
resp.PageSize = req.PageSize
|
||||
resp.PageNum = req.PageNum
|
||||
resp.Total = total
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (l *DeployInstanceListLogic) GenerateDeployTasks(tasklist []*models.AiDeployInstanceTask) []*DeployTask {
|
||||
var tasks []*DeployTask
|
||||
for _, t := range tasklist {
|
||||
list, err := l.svcCtx.Scheduler.AiStorages.GetInstanceListByDeployTaskId(t.Id)
|
||||
if err != nil {
|
||||
logx.Errorf("db GetInstanceListByDeployTaskId error")
|
||||
continue
|
||||
}
|
||||
deployTask := &DeployTask{
|
||||
Id: t.Id,
|
||||
Name: t.Name,
|
||||
Desc: t.Desc,
|
||||
Instances: list,
|
||||
}
|
||||
tasks = append(tasks, deployTask)
|
||||
}
|
||||
return tasks
|
||||
}
|
||||
|
||||
type DeployTask struct {
|
||||
Id int64 `json:"id,string"`
|
||||
Name string `json:"name,string"`
|
||||
Desc string `json:"desc,string"`
|
||||
Instances []*models.AiInferDeployInstance `json:"instances,string"`
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ package inference
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
|
@ -37,10 +35,6 @@ func (l *DeployInstanceStatLogic) DeployInstanceStat(req *types.DeployInstanceSt
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if total == 0 {
|
||||
return nil, errors.New("get statistics failed")
|
||||
}
|
||||
|
||||
resp.Total = total
|
||||
resp.Running = running
|
||||
return resp, nil
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetAdaptersByModelLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetAdaptersByModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAdaptersByModelLogic {
|
||||
return &GetAdaptersByModelLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetAdaptersByModelLogic) GetAdaptersByModel(req *types.GetAdaptersByModelReq) (resp *types.GetAdaptersByModelResp, err error) {
|
||||
resp = &types.GetAdaptersByModelResp{}
|
||||
|
||||
adapterList, err := l.svcCtx.Scheduler.AiStorages.GetAdaptersByType("1")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, adapter := range adapterList {
|
||||
var clusterAvail []*types.ClusterAvail
|
||||
clusters, err := l.svcCtx.Scheduler.AiStorages.GetClustersByAdapterId(adapter.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, cluster := range clusters.List {
|
||||
exist := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[adapter.Id][cluster.Id].CheckModelExistence(l.ctx, req.ModelName, req.ModelType)
|
||||
if exist {
|
||||
c := &types.ClusterAvail{
|
||||
ClusterId: cluster.Id,
|
||||
ClusterName: cluster.Name,
|
||||
}
|
||||
clusterAvail = append(clusterAvail, c)
|
||||
}
|
||||
}
|
||||
|
||||
if len(clusterAvail) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
adapterAvail := &types.AdapterAvail{
|
||||
AdapterId: adapter.Id,
|
||||
AdapterName: adapter.Name,
|
||||
Clusters: clusterAvail,
|
||||
}
|
||||
|
||||
resp.Adapters = append(resp.Adapters, adapterAvail)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetDeployTasksByTypeLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetDeployTasksByTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDeployTasksByTypeLogic {
|
||||
return &GetDeployTasksByTypeLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDeployTasksByTypeLogic) GetDeployTasksByType(req *types.GetDeployTasksByTypeReq) (resp *types.GetDeployTasksByTypeResp, err error) {
|
||||
resp = &types.GetDeployTasksByTypeResp{}
|
||||
|
||||
list, err := l.svcCtx.Scheduler.AiStorages.GetDeployTaskListByType(req.ModelType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(list) == 0 {
|
||||
return nil, errors.New("实列不存在")
|
||||
}
|
||||
|
||||
resp.List = list
|
||||
return resp, nil
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetRunningInstanceByIdLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetRunningInstanceByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRunningInstanceByIdLogic {
|
||||
return &GetRunningInstanceByIdLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetRunningInstanceByIdLogic) GetRunningInstanceById(req *types.GetRunningInstanceReq) (resp *types.GetRunningInstanceResp, err error) {
|
||||
resp = &types.GetRunningInstanceResp{}
|
||||
|
||||
id, err := strconv.ParseInt(req.Id, 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list, err := l.svcCtx.Scheduler.AiStorages.GetRunningDeployInstanceById(id, req.AdapterId)
|
||||
|
||||
resp.List = list
|
||||
return
|
||||
}
|
|
@ -10,7 +10,9 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type ImageInferenceLogic struct {
|
||||
|
@ -34,17 +36,24 @@ func NewImageInferenceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Im
|
|||
|
||||
func (l *ImageInferenceLogic) ImageInfer(r *http.Request, req *types.ImageInferenceReq) (resp *types.ImageInferenceResp, err error) {
|
||||
resp = &types.ImageInferenceResp{}
|
||||
opt := &option.InferOption{
|
||||
TaskName: req.TaskName,
|
||||
TaskDesc: req.TaskDesc,
|
||||
AdapterId: req.AdapterId,
|
||||
AiClusterIds: req.AiClusterIds,
|
||||
ModelName: req.ModelName,
|
||||
ModelType: req.ModelType,
|
||||
Strategy: req.Strategy,
|
||||
StaticWeightMap: req.StaticWeightMap,
|
||||
if len(req.InstanceIds) == 0 {
|
||||
return nil, errors.New("instances are empty")
|
||||
}
|
||||
|
||||
var instanceList []*models.AiInferDeployInstance
|
||||
for _, id := range req.InstanceIds {
|
||||
instance, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceById(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
instanceList = append(instanceList, instance)
|
||||
}
|
||||
|
||||
if len(instanceList) == 0 {
|
||||
return nil, errors.New("instances are empty")
|
||||
}
|
||||
|
||||
// process uploaded images
|
||||
var ts []*imageInference.ImageFile
|
||||
|
||||
uploadedFiles := r.MultipartForm.File
|
||||
|
@ -72,9 +81,37 @@ func (l *ImageInferenceLogic) ImageInfer(r *http.Request, req *types.ImageInfere
|
|||
ts = append(ts, &t)
|
||||
}
|
||||
|
||||
_, ok := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[opt.AdapterId]
|
||||
//single adapter logic
|
||||
if len(req.StaticWeightMap) != 1 {
|
||||
return nil, errors.New("staticWeightMap != 1")
|
||||
}
|
||||
|
||||
adapterId := strconv.FormatInt(instanceList[0].AdapterId, 10)
|
||||
staticWeightMap, ok := req.StaticWeightMap[adapterId]
|
||||
if !ok {
|
||||
return nil, errors.New("AdapterId does not exist")
|
||||
return nil, errors.New("set staticWeightMap failed")
|
||||
}
|
||||
|
||||
// create InferOption
|
||||
opt := &option.InferOption{
|
||||
TaskName: req.TaskName,
|
||||
TaskDesc: req.TaskDesc,
|
||||
AdapterId: adapterId,
|
||||
//AiClusterIds: req.AiClusterIds,
|
||||
//ModelName: req.ModelName,
|
||||
ModelType: req.ModelType,
|
||||
Strategy: req.Strategy,
|
||||
StaticWeightMap: staticWeightMap,
|
||||
}
|
||||
|
||||
adapterName, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(opt.AdapterId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// set strategy
|
||||
if opt.Strategy != "" {
|
||||
return nil, errors.New("strategy is empty")
|
||||
}
|
||||
|
||||
var strat strategy.Strategy
|
||||
|
@ -102,12 +139,8 @@ func (l *ImageInferenceLogic) ImageInfer(r *http.Request, req *types.ImageInfere
|
|||
}
|
||||
}
|
||||
|
||||
adapterName, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(opt.AdapterId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
imageInfer, err := imageInference.New(imageInference.NewImageClassification(), ts, clusters, opt, l.svcCtx.Scheduler.AiStorages, l.svcCtx.Scheduler.AiService.InferenceAdapterMap, adapterName)
|
||||
// create inference struct
|
||||
imageInfer, err := imageInference.New(imageInference.NewImageClassification(), ts, clusters, instanceList, opt, l.svcCtx.Scheduler.AiStorages, l.svcCtx.Scheduler.AiService.InferenceAdapterMap, adapterName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ package inference
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
|
@ -37,10 +35,6 @@ func (l *InferenceTaskStatLogic) InferenceTaskStat(req *types.InferenceTaskStatR
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if total == 0 {
|
||||
return nil, errors.New("get statistics failed")
|
||||
}
|
||||
|
||||
resp.Total = total
|
||||
resp.Running = running
|
||||
return resp, nil
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/inference"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type StartAllByDeployTaskIdLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewStartAllByDeployTaskIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StartAllByDeployTaskIdLogic {
|
||||
return &StartAllByDeployTaskIdLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *StartAllByDeployTaskIdLogic) StartAllByDeployTaskId(req *types.StartAllByDeployTaskIdReq) (resp *types.StartAllByDeployTaskIdResp, err error) {
|
||||
resp = &types.StartAllByDeployTaskIdResp{}
|
||||
|
||||
id, err := strconv.ParseInt(req.Id, 10, 64)
|
||||
|
||||
list, err := l.svcCtx.Scheduler.AiStorages.GetInstanceListByDeployTaskId(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, ins := range list {
|
||||
in, err := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].GetInferDeployInstance(l.ctx, ins.InstanceId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if checkStopStatus(in) {
|
||||
success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].StartInferDeployInstance(l.ctx, ins.InstanceId)
|
||||
if !success {
|
||||
return nil, errors.New(ins.InstanceName + " start failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = l.svcCtx.Scheduler.AiStorages.UpdateDeployTaskById(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func checkStopStatus(in *inference.DeployInstance) bool {
|
||||
switch in.ClusterType {
|
||||
case storeLink.TYPE_OCTOPUS:
|
||||
switch in.Status {
|
||||
case "stopped":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
case storeLink.TYPE_MODELARTS:
|
||||
switch in.Status {
|
||||
case "stopped":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
case storeLink.TYPE_SHUGUANGAI:
|
||||
switch in.Status {
|
||||
case "Terminated":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/updater"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
"strconv"
|
||||
|
@ -25,18 +26,19 @@ func NewStartDeployInstanceListLogic(ctx context.Context, svcCtx *svc.ServiceCon
|
|||
|
||||
func (l *StartDeployInstanceListLogic) StartDeployInstanceList(req *types.StartDeployInstanceReq) (resp *types.StartDeployInstanceResp, err error) {
|
||||
resp = &types.StartDeployInstanceResp{}
|
||||
success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[req.AdapterId][req.ClusterId].StartInferDeployInstance(l.ctx, req.InstanceId)
|
||||
|
||||
id, err := strconv.ParseInt(req.Id, 10, 64)
|
||||
ins, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceById(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
l.svcCtx.Scheduler.AiStorages.UpdateInferDeployInstance(ins)
|
||||
|
||||
success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[req.AdapterId][req.ClusterId].StartInferDeployInstance(l.ctx, req.InstanceId)
|
||||
if !success {
|
||||
return nil, errors.New("start instance failed")
|
||||
}
|
||||
|
||||
go updater.UpdateDeployInstanceStatus(l.svcCtx, ins, true)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/inference"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
"strconv"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type StopAllByDeployTaskIdLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewStopAllByDeployTaskIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StopAllByDeployTaskIdLogic {
|
||||
return &StopAllByDeployTaskIdLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *StopAllByDeployTaskIdLogic) StopAllByDeployTaskId(req *types.StopAllByDeployTaskIdReq) (resp *types.StopAllByDeployTaskIdResp, err error) {
|
||||
resp = &types.StopAllByDeployTaskIdResp{}
|
||||
|
||||
id, err := strconv.ParseInt(req.Id, 10, 64)
|
||||
|
||||
list, err := l.svcCtx.Scheduler.AiStorages.GetInstanceListByDeployTaskId(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, ins := range list {
|
||||
in, err := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].GetInferDeployInstance(l.ctx, ins.InstanceId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if checkStatus(in) {
|
||||
success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].StopInferDeployInstance(l.ctx, ins.InstanceId)
|
||||
if !success {
|
||||
return nil, errors.New(ins.InstanceName + " stop failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = l.svcCtx.Scheduler.AiStorages.UpdateDeployTaskById(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func checkStatus(in *inference.DeployInstance) bool {
|
||||
switch in.ClusterType {
|
||||
case storeLink.TYPE_OCTOPUS:
|
||||
switch in.Status {
|
||||
case "running":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
case storeLink.TYPE_MODELARTS:
|
||||
switch in.Status {
|
||||
case "running":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
case storeLink.TYPE_SHUGUANGAI:
|
||||
switch in.Status {
|
||||
case "Running":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/updater"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
"strconv"
|
||||
|
@ -25,17 +26,19 @@ func NewStopDeployInstanceLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
|
||||
func (l *StopDeployInstanceLogic) StopDeployInstance(req *types.StopDeployInstanceReq) (resp *types.StopDeployInstanceResp, err error) {
|
||||
resp = &types.StopDeployInstanceResp{}
|
||||
success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[req.AdapterId][req.ClusterId].StopInferDeployInstance(l.ctx, req.InstanceId)
|
||||
|
||||
id, err := strconv.ParseInt(req.Id, 10, 64)
|
||||
ins, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceById(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
l.svcCtx.Scheduler.AiStorages.UpdateInferDeployInstance(ins)
|
||||
|
||||
success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[req.AdapterId][req.ClusterId].StopInferDeployInstance(l.ctx, req.InstanceId)
|
||||
if !success {
|
||||
return nil, errors.New("stop instance failed")
|
||||
}
|
||||
|
||||
go updater.UpdateDeployInstanceStatus(l.svcCtx, ins, true)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -97,3 +97,21 @@ func Contains(s []string, e string) bool {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func ConcatMultipleSlices[T any](slices [][]T) []T {
|
||||
var totalLen int
|
||||
|
||||
for _, s := range slices {
|
||||
totalLen += len(s)
|
||||
}
|
||||
|
||||
result := make([]T, totalLen)
|
||||
|
||||
var i int
|
||||
|
||||
for _, s := range slices {
|
||||
i += copy(result[i:], s)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -373,23 +373,24 @@ func (s *AiStorage) AddNoticeInfo(adapterId string, adapterName string, clusterI
|
|||
}
|
||||
}
|
||||
|
||||
func (s *AiStorage) SaveInferDeployInstance(instanceId string, instanceName string, adapterId int64,
|
||||
func (s *AiStorage) SaveInferDeployInstance(taskId int64, instanceId string, instanceName string, adapterId int64,
|
||||
adapterName string, clusterId int64, clusterName string, modelName string, modelType string, inferCard string) (int64, error) {
|
||||
startTime := time.Now().Format(time.RFC3339)
|
||||
// 构建主任务结构体
|
||||
insModel := models.AiInferDeployInstance{
|
||||
InstanceId: instanceId,
|
||||
InstanceName: instanceName,
|
||||
AdapterId: adapterId,
|
||||
AdapterName: adapterName,
|
||||
ClusterId: clusterId,
|
||||
ClusterName: clusterName,
|
||||
ModelName: modelName,
|
||||
ModelType: modelType,
|
||||
InferCard: inferCard,
|
||||
Status: constants.Saved,
|
||||
CreateTime: startTime,
|
||||
UpdateTime: startTime,
|
||||
DeployInstanceTaskId: taskId,
|
||||
InstanceId: instanceId,
|
||||
InstanceName: instanceName,
|
||||
AdapterId: adapterId,
|
||||
AdapterName: adapterName,
|
||||
ClusterId: clusterId,
|
||||
ClusterName: clusterName,
|
||||
ModelName: modelName,
|
||||
ModelType: modelType,
|
||||
InferCard: inferCard,
|
||||
Status: constants.Stopped,
|
||||
CreateTime: startTime,
|
||||
UpdateTime: startTime,
|
||||
}
|
||||
// 保存任务数据到数据库
|
||||
tx := s.DbEngin.Table("ai_infer_deploy_instance").Create(&insModel)
|
||||
|
@ -399,8 +400,10 @@ func (s *AiStorage) SaveInferDeployInstance(instanceId string, instanceName stri
|
|||
return insModel.Id, nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) UpdateInferDeployInstance(instance *models.AiInferDeployInstance) error {
|
||||
instance.UpdateTime = time.Now().Format(time.RFC3339)
|
||||
func (s *AiStorage) UpdateInferDeployInstance(instance *models.AiInferDeployInstance, needUpdateTime bool) error {
|
||||
if needUpdateTime {
|
||||
instance.UpdateTime = time.Now().Format(time.RFC3339)
|
||||
}
|
||||
tx := s.DbEngin.Table("ai_infer_deploy_instance").Updates(instance)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
|
@ -419,6 +422,70 @@ func (s *AiStorage) GetInferDeployInstanceById(id int64) (*models.AiInferDeployI
|
|||
return &deployIns, nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) GetDeployTaskById(id int64) (*models.AiDeployInstanceTask, error) {
|
||||
var task models.AiDeployInstanceTask
|
||||
tx := s.DbEngin.Raw("select * from ai_deploy_instance_task where `id` = ?", id).Scan(&task)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return nil, tx.Error
|
||||
}
|
||||
return &task, nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) GetDeployTaskListByType(modelType string) ([]*models.AiDeployInstanceTask, error) {
|
||||
var tasks []*models.AiDeployInstanceTask
|
||||
tx := s.DbEngin.Raw("select * from ai_deploy_instance_task where `model_type` = ?", modelType).Scan(&tasks)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return nil, tx.Error
|
||||
}
|
||||
return tasks, nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) GetAllDeployTasks() ([]*models.AiDeployInstanceTask, error) {
|
||||
var tasks []*models.AiDeployInstanceTask
|
||||
tx := s.DbEngin.Raw("select * from ai_deploy_instance_task").Scan(&tasks)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return nil, tx.Error
|
||||
}
|
||||
return tasks, nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) UpdateDeployTask(task *models.AiDeployInstanceTask, needUpdateTime bool) error {
|
||||
if needUpdateTime {
|
||||
task.UpdateTime = time.Now().Format(time.RFC3339)
|
||||
}
|
||||
tx := s.DbEngin.Table("ai_deploy_instance_task").Updates(task)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return tx.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) UpdateDeployTaskById(id int64) error {
|
||||
task, err := s.GetDeployTaskById(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = s.UpdateDeployTask(task, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) GetInstanceListByDeployTaskId(id int64) ([]*models.AiInferDeployInstance, error) {
|
||||
var list []*models.AiInferDeployInstance
|
||||
tx := s.DbEngin.Raw("select * from ai_infer_deploy_instance where `deploy_instance_task_id` = ?", id).Scan(&list)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return nil, tx.Error
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) GetInferDeployInstanceList() ([]*models.AiInferDeployInstance, error) {
|
||||
var list []*models.AiInferDeployInstance
|
||||
tx := s.DbEngin.Raw("select * from ai_infer_deploy_instance").Scan(&list)
|
||||
|
@ -429,6 +496,16 @@ func (s *AiStorage) GetInferDeployInstanceList() ([]*models.AiInferDeployInstanc
|
|||
return list, nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) GetDeployTaskList() ([]*models.AiDeployInstanceTask, error) {
|
||||
var list []*models.AiDeployInstanceTask
|
||||
tx := s.DbEngin.Raw("select * from ai_deploy_instance_task").Scan(&list)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return nil, tx.Error
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) GetInferDeployInstanceTotalNum() (int32, error) {
|
||||
var total int32
|
||||
tx := s.DbEngin.Raw("select count(*) from ai_infer_deploy_instance").Scan(&total)
|
||||
|
@ -441,7 +518,7 @@ func (s *AiStorage) GetInferDeployInstanceTotalNum() (int32, error) {
|
|||
|
||||
func (s *AiStorage) GetInferDeployInstanceRunningNum() (int32, error) {
|
||||
var total int32
|
||||
tx := s.DbEngin.Raw("select count(*) from ai_infer_deploy_instance where `status` = 'running'").Scan(&total)
|
||||
tx := s.DbEngin.Raw("select count(*) from ai_infer_deploy_instance where `status` = 'Running'").Scan(&total)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return 0, tx.Error
|
||||
|
@ -481,10 +558,39 @@ func (s *AiStorage) GetTrainingTaskTotalNum() (int32, error) {
|
|||
|
||||
func (s *AiStorage) GetTrainingTaskRunningNum() (int32, error) {
|
||||
var total int32
|
||||
tx := s.DbEngin.Raw("select count(*) from task where `task_type_dict` = 11 and `status` = 'Running'").Scan(&total)
|
||||
tx := s.DbEngin.Raw("select count(*) from task where `task_type_dict` = 10 and `status` = 'Running'").Scan(&total)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return 0, tx.Error
|
||||
}
|
||||
return total, nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) SaveInferDeployTask(taskName string, modelName string, modelType string, desc string) (int64, error) {
|
||||
startTime := time.Now().Format(time.RFC3339)
|
||||
// 构建主任务结构体
|
||||
taskModel := models.AiDeployInstanceTask{
|
||||
Name: taskName,
|
||||
ModelName: modelName,
|
||||
ModelType: modelType,
|
||||
Desc: desc,
|
||||
CreateTime: startTime,
|
||||
UpdateTime: startTime,
|
||||
}
|
||||
// 保存任务数据到数据库
|
||||
tx := s.DbEngin.Table("ai_deploy_instance_task").Create(&taskModel)
|
||||
if tx.Error != nil {
|
||||
return 0, tx.Error
|
||||
}
|
||||
return taskModel.Id, nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) GetRunningDeployInstanceById(id int64, adapterId string) ([]*models.AiInferDeployInstance, error) {
|
||||
var list []*models.AiInferDeployInstance
|
||||
tx := s.DbEngin.Raw("select * from ai_infer_deploy_instance where `deploy_instance_task_id` = ? and `adapter_id` = ? and `status` = 'Running'", id, adapterId).Scan(&list)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return nil, tx.Error
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
|
|
@ -15,6 +15,17 @@ type InferOption struct {
|
|||
Envs []string `json:"envs,optional"`
|
||||
Cmd string `json:"cmd,optional"`
|
||||
Replica int32 `json:"replicas,optional"`
|
||||
|
||||
ResourceId string
|
||||
AlgorithmId string
|
||||
ImageId string
|
||||
|
||||
//modelarts
|
||||
InferType string
|
||||
Specification string
|
||||
Weight int32
|
||||
ModelId string
|
||||
InstanceCount int32
|
||||
}
|
||||
|
||||
func (a InferOption) GetOptionType() string {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/inference"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||
|
@ -37,6 +38,7 @@ type FilteredCluster struct {
|
|||
urls []*inference.InferUrl
|
||||
clusterId string
|
||||
clusterName string
|
||||
clusterType string
|
||||
imageNum int32
|
||||
}
|
||||
|
||||
|
@ -44,6 +46,7 @@ type ImageInference struct {
|
|||
inference IImageInference
|
||||
files []*ImageFile
|
||||
clusters []*strategy.AssignedCluster
|
||||
instances []*models.AiInferDeployInstance
|
||||
opt *option.InferOption
|
||||
storage *database.AiStorage
|
||||
inferAdapter map[string]map[string]inference.ICluster
|
||||
|
@ -55,6 +58,7 @@ func New(
|
|||
inference IImageInference,
|
||||
files []*ImageFile,
|
||||
clusters []*strategy.AssignedCluster,
|
||||
instances []*models.AiInferDeployInstance,
|
||||
opt *option.InferOption,
|
||||
storage *database.AiStorage,
|
||||
inferAdapter map[string]map[string]inference.ICluster,
|
||||
|
@ -64,6 +68,7 @@ func New(
|
|||
inference: inference,
|
||||
files: files,
|
||||
clusters: clusters,
|
||||
instances: instances,
|
||||
opt: opt,
|
||||
storage: storage,
|
||||
inferAdapter: inferAdapter,
|
||||
|
@ -126,7 +131,7 @@ func (i *ImageInference) saveTask() (int64, error) {
|
|||
return 0, err
|
||||
}
|
||||
|
||||
i.storage.AddNoticeInfo(i.opt.AdapterId, i.adapterName, "", "", i.opt.TaskName, "create", "任务创建中")
|
||||
i.storage.AddNoticeInfo("", "", "", "", i.opt.TaskName, "create", "任务创建中")
|
||||
|
||||
return id, nil
|
||||
}
|
||||
|
@ -143,7 +148,7 @@ func (i *ImageInference) saveAiTask(id int64) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (i *ImageInference) filterClusters() ([]*FilteredCluster, error) {
|
||||
func (i *ImageInference) filterClustersTemp() ([]*FilteredCluster, error) {
|
||||
var wg sync.WaitGroup
|
||||
var ch = make(chan *FilteredCluster, len(i.clusters))
|
||||
var cs []*FilteredCluster
|
||||
|
@ -156,7 +161,7 @@ func (i *ImageInference) filterClusters() ([]*FilteredCluster, error) {
|
|||
c := cluster
|
||||
go func() {
|
||||
r := http.Request{}
|
||||
imageUrls, err := inferMap[c.ClusterId].GetInferUrl(r.Context(), i.opt)
|
||||
clusterInferUrl, err := inferMap[c.ClusterId].GetClusterInferUrl(r.Context(), i.opt)
|
||||
if err != nil {
|
||||
mutex.Lock()
|
||||
i.errMap[c.ClusterId] = err.Error()
|
||||
|
@ -165,14 +170,13 @@ func (i *ImageInference) filterClusters() ([]*FilteredCluster, error) {
|
|||
return
|
||||
}
|
||||
|
||||
i.inference.AppendRoute(imageUrls)
|
||||
|
||||
clusterName, _ := i.storage.GetClusterNameById(c.ClusterId)
|
||||
i.inference.AppendRoute(clusterInferUrl.InferUrls)
|
||||
|
||||
var f FilteredCluster
|
||||
f.urls = imageUrls
|
||||
f.urls = clusterInferUrl.InferUrls
|
||||
f.clusterId = c.ClusterId
|
||||
f.clusterName = clusterName
|
||||
f.clusterName = clusterInferUrl.ClusterName
|
||||
f.clusterType = clusterInferUrl.ClusterType
|
||||
f.imageNum = c.Replicas
|
||||
|
||||
ch <- &f
|
||||
|
@ -189,6 +193,45 @@ func (i *ImageInference) filterClusters() ([]*FilteredCluster, error) {
|
|||
return cs, nil
|
||||
}
|
||||
|
||||
func (i *ImageInference) filterClusters() ([]*FilteredCluster, error) {
|
||||
var cs []*FilteredCluster
|
||||
for _, cluster := range i.clusters {
|
||||
var inferurls []*inference.InferUrl
|
||||
var clustertype string
|
||||
for _, instance := range i.instances {
|
||||
clusterId := strconv.FormatInt(instance.ClusterId, 10)
|
||||
adapterId := strconv.FormatInt(instance.AdapterId, 10)
|
||||
|
||||
if cluster.ClusterId == clusterId {
|
||||
r := http.Request{}
|
||||
deployInstance, err := i.inferAdapter[adapterId][clusterId].GetInferDeployInstance(r.Context(), instance.InstanceId)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
var url inference.InferUrl
|
||||
url.Url = deployInstance.InferUrl
|
||||
url.Card = deployInstance.InferCard
|
||||
inferurls = append(inferurls, &url)
|
||||
|
||||
clustertype = deployInstance.ClusterType
|
||||
}
|
||||
}
|
||||
if len(inferurls) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
i.inference.AppendRoute(inferurls)
|
||||
|
||||
var f FilteredCluster
|
||||
f.urls = inferurls
|
||||
f.clusterName = cluster.ClusterName
|
||||
f.clusterType = clustertype
|
||||
f.imageNum = cluster.Replicas
|
||||
cs = append(cs, &f)
|
||||
}
|
||||
return cs, nil
|
||||
}
|
||||
|
||||
func (i *ImageInference) inferImages(cs []*FilteredCluster) ([]*types.ImageResult, error) {
|
||||
var wg sync.WaitGroup
|
||||
var ch = make(chan *types.ImageResult, len(i.files))
|
||||
|
@ -206,7 +249,7 @@ func (i *ImageInference) inferImages(cs []*FilteredCluster) ([]*types.ImageResul
|
|||
imageNumIdx = imageNumIdx + c.imageNum
|
||||
|
||||
wg.Add(len(new_images))
|
||||
go sendInferReq(new_images, c, &wg, ch, limit)
|
||||
go i.sendInferReq(new_images, c, &wg, ch, limit)
|
||||
}
|
||||
wg.Wait()
|
||||
close(ch)
|
||||
|
@ -300,12 +343,12 @@ func (i *ImageInference) updateStatus(aiTaskList []*models.TaskAi, cs []*Filtere
|
|||
return nil
|
||||
}
|
||||
|
||||
func sendInferReq(images []*ImageFile, cluster *FilteredCluster, wg *sync.WaitGroup, ch chan<- *types.ImageResult, limit chan bool) {
|
||||
func (i *ImageInference) sendInferReq(images []*ImageFile, cluster *FilteredCluster, wg *sync.WaitGroup, ch chan<- *types.ImageResult, limit chan bool) {
|
||||
for _, image := range images {
|
||||
limit <- true
|
||||
go func(t *ImageFile, c *FilteredCluster) {
|
||||
if len(c.urls) == 1 {
|
||||
r, err := getInferResult(c.urls[0].Url, t.File, t.ImageResult.ImageName, c.clusterName)
|
||||
r, err := getInferResult(c.urls[0].Url, t.File, t.ImageResult.ImageName, c.clusterId, c.clusterType, i.inferAdapter, i.opt.AdapterId)
|
||||
if err != nil {
|
||||
t.ImageResult.ImageResult = err.Error()
|
||||
t.ImageResult.ClusterId = c.clusterId
|
||||
|
@ -327,7 +370,7 @@ func sendInferReq(images []*ImageFile, cluster *FilteredCluster, wg *sync.WaitGr
|
|||
return
|
||||
} else {
|
||||
idx := rand.Intn(len(c.urls))
|
||||
r, err := getInferResult(c.urls[idx].Url, t.File, t.ImageResult.ImageName, c.clusterName)
|
||||
r, err := getInferResult(c.urls[idx].Url, t.File, t.ImageResult.ImageName, c.clusterId, c.clusterType, i.inferAdapter, i.opt.AdapterId)
|
||||
if err != nil {
|
||||
t.ImageResult.ImageResult = err.Error()
|
||||
t.ImageResult.ClusterId = c.clusterId
|
||||
|
@ -404,24 +447,35 @@ func (i *ImageInference) saveAiSubTasks(id int64, aiTaskList []*models.TaskAi, c
|
|||
return nil
|
||||
}
|
||||
|
||||
func getInferResult(url string, file multipart.File, fileName string, clusterName string) (string, error) {
|
||||
if clusterName == "鹏城云脑II-modelarts" {
|
||||
func getInferResult(url string, file multipart.File, fileName string, clusterId string, clusterType string, inferAdapter map[string]map[string]inference.ICluster, adapterId string) (string, error) {
|
||||
inferMap := inferAdapter[adapterId]
|
||||
|
||||
switch clusterType {
|
||||
case storeLink.TYPE_OCTOPUS:
|
||||
r := http.Request{}
|
||||
result, err := inferMap[clusterId].GetInferResult(r.Context(), url, file, fileName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return result, nil
|
||||
case storeLink.TYPE_MODELARTS:
|
||||
r, err := getInferResultModelarts(url, file, fileName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return r, nil
|
||||
default:
|
||||
var res Res
|
||||
req := GetRestyRequest(20)
|
||||
_, err := req.
|
||||
SetFileReader("file", fileName, file).
|
||||
SetResult(&res).
|
||||
Post(url)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return res.Result, nil
|
||||
}
|
||||
var res Res
|
||||
req := GetRestyRequest(20)
|
||||
_, err := req.
|
||||
SetFileReader("file", fileName, file).
|
||||
SetResult(&res).
|
||||
Post(url)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return res.Result, nil
|
||||
}
|
||||
|
||||
func getInferResultModelarts(url string, file multipart.File, fileName string) (string, error) {
|
||||
|
|
|
@ -3,7 +3,7 @@ package imageInference
|
|||
import "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/inference"
|
||||
|
||||
const (
|
||||
IMAGETOTEXT = "image-to-text"
|
||||
IMAGETOTEXT = "image"
|
||||
IMAGETOTEXT_AiTYPE = "13"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package inference
|
|||
import (
|
||||
"context"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option"
|
||||
"mime/multipart"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -10,11 +11,14 @@ const (
|
|||
)
|
||||
|
||||
type ICluster interface {
|
||||
GetInferUrl(ctx context.Context, option *option.InferOption) ([]*InferUrl, error)
|
||||
GetClusterInferUrl(ctx context.Context, option *option.InferOption) (*ClusterInferUrl, error)
|
||||
GetInferResult(ctx context.Context, url string, file multipart.File, fileName string) (string, error)
|
||||
GetInferDeployInstanceList(ctx context.Context) ([]*DeployInstance, error)
|
||||
StartInferDeployInstance(ctx context.Context, id string) bool
|
||||
StopInferDeployInstance(ctx context.Context, id string) bool
|
||||
GetInferDeployInstance(ctx context.Context, id string) (*DeployInstance, error)
|
||||
CreateInferDeployInstance(ctx context.Context, option *option.InferOption) (string, error)
|
||||
CheckModelExistence(ctx context.Context, modelName string, modelType string) bool
|
||||
}
|
||||
|
||||
type IInference interface {
|
||||
|
@ -26,6 +30,12 @@ type Inference struct {
|
|||
In IInference
|
||||
}
|
||||
|
||||
type ClusterInferUrl struct {
|
||||
ClusterName string
|
||||
ClusterType string
|
||||
InferUrls []*InferUrl
|
||||
}
|
||||
|
||||
type InferUrl struct {
|
||||
Url string
|
||||
Card string
|
||||
|
@ -37,7 +47,9 @@ type DeployInstance struct {
|
|||
ModelName string
|
||||
ModelType string
|
||||
InferCard string
|
||||
InferUrl string
|
||||
ClusterName string
|
||||
ClusterType string
|
||||
Status string
|
||||
CreatedTime string
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
TEXTTOIMAGE = "text-to-image"
|
||||
TEXTTOIMAGE = "generate_image"
|
||||
TEXTTOIMAGE_AiTYPE = "14"
|
||||
)
|
||||
|
||||
|
|
|
@ -74,18 +74,20 @@ func filterClusters(opt *option.InferOption, storage *database.AiStorage, inferA
|
|||
wg.Add(1)
|
||||
go func(cId string) {
|
||||
r := http.Request{}
|
||||
urls, err := inferMap[cId].GetInferUrl(r.Context(), opt)
|
||||
clusterInferUrl, err := inferMap[cId].GetClusterInferUrl(r.Context(), opt)
|
||||
if err != nil {
|
||||
wg.Done()
|
||||
return
|
||||
}
|
||||
for i, _ := range urls {
|
||||
urls[i].Url = urls[i].Url + inference.FORWARD_SLASH + CHAT
|
||||
|
||||
for i, _ := range clusterInferUrl.InferUrls {
|
||||
clusterInferUrl.InferUrls[i].Url = clusterInferUrl.InferUrls[i].Url + inference.FORWARD_SLASH + CHAT
|
||||
}
|
||||
|
||||
clusterName, _ := storage.GetClusterNameById(cId)
|
||||
|
||||
var f FilteredCluster
|
||||
f.urls = urls
|
||||
f.urls = clusterInferUrl.InferUrls
|
||||
f.clusterId = cId
|
||||
f.clusterName = clusterName
|
||||
|
||||
|
|
|
@ -7,9 +7,52 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func UpdateDeployInstanceStatus(svc *svc.ServiceContext, instance *models.AiInferDeployInstance) {
|
||||
func UpdateDeployInstanceStatusBatch(svc *svc.ServiceContext, insList []*models.AiInferDeployInstance) {
|
||||
list := make([]*models.AiInferDeployInstance, len(insList))
|
||||
copy(list, insList)
|
||||
for i := len(list) - 1; i >= 0; i-- {
|
||||
if list[i].Status == constants.Running || list[i].Status == constants.Stopped {
|
||||
list = append(list[:i], list[i+1:]...)
|
||||
}
|
||||
}
|
||||
|
||||
if len(list) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for _, instance := range list {
|
||||
go UpdateDeployInstanceStatus(svc, instance, false)
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateDeployTaskStatus(svc *svc.ServiceContext) {
|
||||
list, err := svc.Scheduler.AiStorages.GetAllDeployTasks()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ins := list[0]
|
||||
for i := range list {
|
||||
uTime, _ := time.Parse(time.RFC3339, ins.UpdateTime)
|
||||
latest, _ := time.Parse(time.RFC3339, list[i].UpdateTime)
|
||||
if latest.After(uTime) {
|
||||
ins = list[i]
|
||||
}
|
||||
}
|
||||
inslist, err := svc.Scheduler.AiStorages.GetInstanceListByDeployTaskId(ins.Id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, instance := range inslist {
|
||||
go UpdateDeployInstanceStatus(svc, instance, false)
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateDeployInstanceStatus(svc *svc.ServiceContext, instance *models.AiInferDeployInstance, updatetime bool) {
|
||||
amap, found := svc.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(instance.AdapterId, 10)]
|
||||
if !found {
|
||||
return
|
||||
|
@ -27,24 +70,51 @@ func UpdateDeployInstanceStatus(svc *svc.ServiceContext, instance *models.AiInfe
|
|||
case storeLink.TYPE_OCTOPUS:
|
||||
switch ins.Status {
|
||||
case "running":
|
||||
if instance.Status == constants.Running {
|
||||
return
|
||||
}
|
||||
instance.Status = constants.Running
|
||||
case "stopped":
|
||||
if instance.Status == constants.Stopped {
|
||||
return
|
||||
}
|
||||
instance.Status = constants.Stopped
|
||||
default:
|
||||
instance.Status = ins.Status
|
||||
}
|
||||
|
||||
case storeLink.TYPE_SHUGUANGAI:
|
||||
case storeLink.TYPE_MODELARTS:
|
||||
switch ins.Status {
|
||||
case "running":
|
||||
if instance.Status == constants.Running {
|
||||
return
|
||||
}
|
||||
instance.Status = constants.Running
|
||||
case "stopped":
|
||||
if instance.Status == constants.Stopped {
|
||||
return
|
||||
}
|
||||
instance.Status = constants.Stopped
|
||||
default:
|
||||
instance.Status = ins.Status
|
||||
}
|
||||
case storeLink.TYPE_SHUGUANGAI:
|
||||
switch ins.Status {
|
||||
case "Running":
|
||||
if instance.Status == constants.Running {
|
||||
return
|
||||
}
|
||||
instance.Status = constants.Running
|
||||
case "Terminated":
|
||||
if instance.Status == constants.Stopped {
|
||||
return
|
||||
}
|
||||
instance.Status = constants.Stopped
|
||||
default:
|
||||
instance.Status = ins.Status
|
||||
}
|
||||
}
|
||||
err = svc.Scheduler.AiStorages.UpdateInferDeployInstance(instance)
|
||||
|
||||
err = svc.Scheduler.AiStorages.UpdateInferDeployInstance(instance, updatetime)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice"
|
||||
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
|
||||
modelartsclient "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
|
||||
"mime/multipart"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -201,10 +202,11 @@ func (m *ModelArtsLink) GetResourceStats(ctx context.Context) (*collector.Resour
|
|||
num32, _ := strconv.Atoi(resp1.Items[0].Spec.Npu.Size)
|
||||
var cards []*collector.Card
|
||||
card := &collector.Card{
|
||||
Platform: MODELARTS,
|
||||
Type: CARD,
|
||||
Name: Npu,
|
||||
CardNum: int32(num32),
|
||||
Platform: MODELARTS,
|
||||
Type: CARD,
|
||||
Name: Npu,
|
||||
CardNum: int32(num32),
|
||||
TOpsAtFp16: float64(num32 * 320),
|
||||
}
|
||||
cards = append(cards, card)
|
||||
resourceStats.CardsAvail = cards
|
||||
|
@ -258,6 +260,28 @@ func (m *ModelArtsLink) UploadAlgorithmCode(ctx context.Context, resourceType st
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *ModelArtsLink) GetModelId(ctx context.Context, option *option.AiOption, ifoption *option.InferOption) error {
|
||||
req := &modelarts.ListModelReq{
|
||||
Platform: m.platform,
|
||||
Limit: int64(m.pageIndex),
|
||||
Offset: int64(m.pageSize),
|
||||
ModelName: option.ModelName,
|
||||
//ModelType: option.ModelType,
|
||||
}
|
||||
ListResp, err := m.modelArtsRpc.ListModels(ctx, req)
|
||||
for _, Models := range ListResp.Models {
|
||||
if Models.ModelName == option.ModelName {
|
||||
ifoption.ModelId = Models.ModelId
|
||||
return nil
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return errors.New("failed to set ModelId")
|
||||
}
|
||||
|
||||
func (m *ModelArtsLink) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) {
|
||||
req := &modelartsservice.GetTrainingJobLogsPreviewReq{
|
||||
Platform: m.platform,
|
||||
|
@ -335,7 +359,7 @@ func (m *ModelArtsLink) Execute(ctx context.Context, option *option.AiOption) (i
|
|||
}
|
||||
|
||||
func (m *ModelArtsLink) GenerateSubmitParams(ctx context.Context, option *option.AiOption) error {
|
||||
err := m.generateResourceId(ctx, option)
|
||||
err := m.generateResourceId(ctx, option, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -362,7 +386,7 @@ func (m *ModelArtsLink) GenerateSubmitParams(ctx context.Context, option *option
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *ModelArtsLink) generateResourceId(ctx context.Context, option *option.AiOption) error {
|
||||
func (m *ModelArtsLink) generateResourceId(ctx context.Context, option *option.AiOption, ifoption *option.InferOption) error {
|
||||
option.ResourceId = "modelarts.kat1.xlarge"
|
||||
return nil
|
||||
}
|
||||
|
@ -426,7 +450,7 @@ func (m *ModelArtsLink) generateAlgorithmId(ctx context.Context, option *option.
|
|||
return errors.New("failed to get AlgorithmId")
|
||||
}
|
||||
|
||||
func (m *ModelArtsLink) GetInferUrl(ctx context.Context, option *option.InferOption) ([]*inference.InferUrl, error) {
|
||||
func (m *ModelArtsLink) GetClusterInferUrl(ctx context.Context, option *option.InferOption) (*inference.ClusterInferUrl, error) {
|
||||
var imageUrls []*inference.InferUrl
|
||||
urlReq := &modelartsclient.ImageReasoningUrlReq{
|
||||
ServiceName: option.ModelName,
|
||||
|
@ -443,7 +467,12 @@ func (m *ModelArtsLink) GetInferUrl(ctx context.Context, option *option.InferOpt
|
|||
}
|
||||
imageUrls = append(imageUrls, imageUrl)
|
||||
|
||||
return imageUrls, nil
|
||||
clusterWithUrl := &inference.ClusterInferUrl{
|
||||
ClusterName: m.platform,
|
||||
ClusterType: TYPE_MODELARTS,
|
||||
InferUrls: imageUrls,
|
||||
}
|
||||
return clusterWithUrl, nil
|
||||
}
|
||||
|
||||
func (m *ModelArtsLink) GetInferDeployInstanceList(ctx context.Context) ([]*inference.DeployInstance, error) {
|
||||
|
@ -470,6 +499,7 @@ func (m *ModelArtsLink) GetInferDeployInstanceList(ctx context.Context) ([]*infe
|
|||
ins.InferCard = "NPU"
|
||||
ins.ClusterName = m.platform
|
||||
ins.CreatedTime = string(services.StartTime)
|
||||
ins.ClusterType = TYPE_MODELARTS
|
||||
insList = append(insList, ins)
|
||||
}
|
||||
|
||||
|
@ -524,5 +554,52 @@ func (m *ModelArtsLink) GetInferDeployInstance(ctx context.Context, id string) (
|
|||
ins.InferCard = "NPU"
|
||||
ins.ClusterName = m.platform
|
||||
ins.CreatedTime = string(resp.StartTime)
|
||||
ins.ClusterType = TYPE_MODELARTS
|
||||
return ins, nil
|
||||
}
|
||||
|
||||
func (m *ModelArtsLink) GetInferResult(ctx context.Context, url string, file multipart.File, fileName string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (m *ModelArtsLink) CreateInferDeployInstance(ctx context.Context, option *option.InferOption) (string, error) {
|
||||
|
||||
err := m.GetModelId(ctx, nil, option)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
configParam := &modelarts.ServiceConfig{
|
||||
Specification: "modelarts.kat1.xlarge.al",
|
||||
Weight: option.Weight,
|
||||
ModelId: option.ModelId,
|
||||
InstanceCount: option.InstanceCount,
|
||||
}
|
||||
var configItems []*modelarts.ServiceConfig
|
||||
configItems = append(configItems, configParam)
|
||||
req := &modelarts.CreateServiceReq{
|
||||
Platform: m.platform,
|
||||
Config: configItems,
|
||||
InferType: option.InferType,
|
||||
ServiceName: option.TaskName,
|
||||
}
|
||||
resp, err := m.modelArtsRpc.CreateService(ctx, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp.ServiceId, nil
|
||||
}
|
||||
|
||||
func (m *ModelArtsLink) CheckModelExistence(ctx context.Context, name string, mtype string) bool {
|
||||
ifoption := &option.InferOption{
|
||||
ModelName: name,
|
||||
ModelType: mtype,
|
||||
}
|
||||
err := m.GetModelId(ctx, nil, ifoption)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package storeLink
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"errors"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option"
|
||||
|
@ -24,7 +25,9 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
||||
"gitlink.org.cn/JointCloud/pcm-octopus/octopus"
|
||||
"gitlink.org.cn/JointCloud/pcm-octopus/octopusclient"
|
||||
"io"
|
||||
"math"
|
||||
"mime/multipart"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -78,6 +81,14 @@ var (
|
|||
MLU: CAMBRICONMLU290,
|
||||
GCU: EnflameT20,
|
||||
}
|
||||
CardModelNameCmdMap = map[string]map[string]string{
|
||||
BIV100: {"blip-image-captioning-base": "pip install -U transformers; pip install fastapi uvicorn[standard]; pip install python-multipart; cd /code; python infer_biv100.py",
|
||||
"imagenet_resnet50": "pip install -U transformers; pip install fastapi uvicorn[standard]; pip install python-multipart; cd /code/infer; python infer_biv100.py",
|
||||
"chatGLM_6B": "su root; pip install transformers==4.33.2; pip install fastapi uvicorn[standard]; cd /code; python infer_biv100.py"},
|
||||
MLU: {"blip-image-captioning-base": "",
|
||||
"imagenet_resnet50": "su root; . /torch/venv3/pytorch/bin/activate; pip install fastapi uvicorn[standard]; pip install python-multipart; cd /code/infer; python infer_mlu.py",
|
||||
"chatGLM_6B": ""},
|
||||
}
|
||||
)
|
||||
|
||||
func NewOctopusLink(octopusRpc octopusclient.Octopus, name string, id int64) *OctopusLink {
|
||||
|
@ -558,7 +569,7 @@ func (o *OctopusLink) Execute(ctx context.Context, option *option.AiOption) (int
|
|||
}
|
||||
|
||||
func (o *OctopusLink) GenerateSubmitParams(ctx context.Context, option *option.AiOption) error {
|
||||
err := o.generateResourceId(ctx, option)
|
||||
err := o.generateResourceId(ctx, option, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -566,15 +577,15 @@ func (o *OctopusLink) GenerateSubmitParams(ctx context.Context, option *option.A
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = o.generateImageId(ctx, option)
|
||||
err = o.generateImageId(ctx, option, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = o.generateAlgorithmId(ctx, option)
|
||||
err = o.generateAlgorithmId(ctx, option, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = o.generateCmd(option)
|
||||
err = o.generateCmd(option, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -589,10 +600,7 @@ func (o *OctopusLink) GenerateSubmitParams(ctx context.Context, option *option.A
|
|||
return nil
|
||||
}
|
||||
|
||||
func (o *OctopusLink) generateResourceId(ctx context.Context, option *option.AiOption) error {
|
||||
if option.ResourceType == "" {
|
||||
return errors.New("ResourceType not set")
|
||||
}
|
||||
func (o *OctopusLink) generateResourceId(ctx context.Context, option *option.AiOption, ifoption *option.InferOption) error {
|
||||
req := &octopus.GetResourceSpecsReq{
|
||||
Platform: o.platform,
|
||||
ResourcePool: RESOURCE_POOL,
|
||||
|
@ -605,6 +613,30 @@ func (o *OctopusLink) generateResourceId(ctx context.Context, option *option.AiO
|
|||
return errors.New(specResp.Error.Message)
|
||||
}
|
||||
|
||||
if option != nil {
|
||||
err = generateResourceIdForTraining(option, specResp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if ifoption != nil {
|
||||
err = generateResourceIdForInferDeployInstance(ifoption, specResp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("failed to set ResourceId")
|
||||
}
|
||||
|
||||
func generateResourceIdForTraining(option *option.AiOption, specResp *octopus.GetResourceSpecsResp) error {
|
||||
if option.ResourceType == "" {
|
||||
return errors.New("ResourceType not set")
|
||||
}
|
||||
|
||||
if option.ResourceType == CPU {
|
||||
for _, spec := range specResp.TrainResourceSpecs {
|
||||
if spec.Price == 0 {
|
||||
|
@ -618,14 +650,44 @@ func (o *OctopusLink) generateResourceId(ctx context.Context, option *option.AiO
|
|||
if option.ComputeCard == "" {
|
||||
option.ComputeCard = GCU
|
||||
}
|
||||
err = setResourceIdByCard(option, specResp, option.ComputeCard)
|
||||
err := setResourceIdByCard(option, specResp, option.ComputeCard)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("failed to get ResourceId")
|
||||
return errors.New("ResourceType not set")
|
||||
}
|
||||
|
||||
func generateResourceIdForInferDeployInstance(option *option.InferOption, specResp *octopus.GetResourceSpecsResp) error {
|
||||
// temporarily use bi-v100
|
||||
cardName, ok := cardCnMap[BIV100]
|
||||
if !ok {
|
||||
errors.New("computeCard not set")
|
||||
}
|
||||
|
||||
// set computeCard
|
||||
option.ComputeCard = BIV100
|
||||
|
||||
for _, spec := range specResp.TrainResourceSpecs {
|
||||
names := strings.Split(spec.Name, COMMA)
|
||||
if len(names) != 4 {
|
||||
continue
|
||||
}
|
||||
|
||||
ns := strings.Split(names[0], STAR)
|
||||
if len(ns) != 2 {
|
||||
continue
|
||||
}
|
||||
|
||||
if ns[0] == "1" && ns[1] == cardName {
|
||||
option.ResourceId = spec.Id
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return errors.New("failed to set ResourceId")
|
||||
}
|
||||
|
||||
func (o *OctopusLink) generateDatasetsId(ctx context.Context, option *option.AiOption) error {
|
||||
|
@ -653,33 +715,7 @@ func (o *OctopusLink) generateDatasetsId(ctx context.Context, option *option.AiO
|
|||
return errors.New("failed to get DatasetsId")
|
||||
}
|
||||
|
||||
func (o *OctopusLink) generateImageId(ctx context.Context, option *option.AiOption) error {
|
||||
if option.TaskType == "" {
|
||||
return errors.New("TaskType not set")
|
||||
}
|
||||
|
||||
req := &octopus.GetUserImageListReq{
|
||||
Platform: o.platform,
|
||||
PageIndex: o.pageIndex,
|
||||
PageSize: o.pageSize,
|
||||
}
|
||||
resp, err := o.octopusRpc.GetUserImageList(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !resp.Success {
|
||||
return errors.New("failed to get imageId")
|
||||
}
|
||||
|
||||
if option.ResourceType == CPU {
|
||||
for _, img := range resp.Payload.Images {
|
||||
if img.Image.ImageName == "test-image" {
|
||||
option.ImageId = img.Image.Id
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (o *OctopusLink) generateImageId(ctx context.Context, option *option.AiOption, ifoption *option.InferOption) error {
|
||||
preImgReq := &octopus.GetPresetImageListReq{
|
||||
Platform: o.platform,
|
||||
PageIndex: o.pageIndex,
|
||||
|
@ -693,6 +729,52 @@ func (o *OctopusLink) generateImageId(ctx context.Context, option *option.AiOpti
|
|||
return errors.New("failed to get PresetImages")
|
||||
}
|
||||
|
||||
if option != nil {
|
||||
if option.TaskType == "" {
|
||||
return errors.New("TaskType not set")
|
||||
}
|
||||
|
||||
req := &octopus.GetUserImageListReq{
|
||||
Platform: o.platform,
|
||||
PageIndex: o.pageIndex,
|
||||
PageSize: o.pageSize,
|
||||
}
|
||||
resp, err := o.octopusRpc.GetUserImageList(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !resp.Success {
|
||||
return errors.New("failed to get imageId")
|
||||
}
|
||||
|
||||
if option.ResourceType == CPU {
|
||||
for _, img := range resp.Payload.Images {
|
||||
if img.Image.ImageName == "test-image" {
|
||||
option.ImageId = img.Image.Id
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = generateImageIdForTraining(option, preImgResp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if ifoption != nil {
|
||||
err = generateImageIdForInferDeployInstance(ifoption, preImgResp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("failed to get ImageId")
|
||||
}
|
||||
|
||||
func generateImageIdForTraining(option *option.AiOption, preImgResp *octopus.GetPresetImageListResp) error {
|
||||
if option.ResourceType == CARD {
|
||||
for _, image := range preImgResp.Payload.Images {
|
||||
if strings.Contains(image.ImageName, cardAliasMap[strings.ToUpper(option.ComputeCard)]) {
|
||||
|
@ -714,11 +796,35 @@ func (o *OctopusLink) generateImageId(ctx context.Context, option *option.AiOpti
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return errors.New("failed to get ImageId")
|
||||
return errors.New("failed to set ImageId")
|
||||
}
|
||||
|
||||
func (o *OctopusLink) generateAlgorithmId(ctx context.Context, option *option.AiOption) error {
|
||||
func generateImageIdForInferDeployInstance(option *option.InferOption, preImgResp *octopus.GetPresetImageListResp) error {
|
||||
for _, image := range preImgResp.Payload.Images {
|
||||
// temporarily use bi-v100
|
||||
if strings.Contains(image.ImageName, cardAliasMap[strings.ToUpper(BIV100)]) {
|
||||
switch strings.ToUpper(BIV100) {
|
||||
case GCU:
|
||||
if strings.HasPrefix(image.ImageVersion, "t20_") {
|
||||
option.ImageId = image.Id
|
||||
return nil
|
||||
}
|
||||
case BIV100:
|
||||
if strings.HasPrefix(image.ImageVersion, "bi_") {
|
||||
option.ImageId = image.Id
|
||||
return nil
|
||||
}
|
||||
case MLU:
|
||||
option.ImageId = image.Id
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return errors.New("failed to set ImageId")
|
||||
}
|
||||
|
||||
func (o *OctopusLink) generateAlgorithmId(ctx context.Context, option *option.AiOption, ifoption *option.InferOption) error {
|
||||
req := &octopus.GetMyAlgorithmListReq{
|
||||
Platform: o.platform,
|
||||
PageIndex: o.pageIndex,
|
||||
|
@ -732,6 +838,26 @@ func (o *OctopusLink) generateAlgorithmId(ctx context.Context, option *option.Ai
|
|||
return errors.New("failed to get algorithmId")
|
||||
}
|
||||
|
||||
if option != nil {
|
||||
err = generateAlgorithmIdForTraining(option, resp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if ifoption != nil {
|
||||
err = generateAlgorithmIdForInferDeployInstance(ifoption, resp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("failed to set AlgorithmId")
|
||||
}
|
||||
|
||||
func generateAlgorithmIdForTraining(option *option.AiOption, resp *octopus.GetMyAlgorithmListResp) error {
|
||||
for _, algorithm := range resp.Payload.Algorithms {
|
||||
if algorithm.FrameworkName == strings.Title(option.TaskType) {
|
||||
ns := strings.Split(algorithm.AlgorithmName, UNDERSCORE)
|
||||
|
@ -757,14 +883,48 @@ func (o *OctopusLink) generateAlgorithmId(ctx context.Context, option *option.Ai
|
|||
}
|
||||
}
|
||||
|
||||
if option.AlgorithmId == "" {
|
||||
return errors.New("Algorithm does not exist")
|
||||
}
|
||||
|
||||
return errors.New("failed to get AlgorithmId")
|
||||
return errors.New("Algorithm does not exist")
|
||||
}
|
||||
|
||||
func (o *OctopusLink) generateCmd(option *option.AiOption) error {
|
||||
func generateAlgorithmIdForInferDeployInstance(option *option.InferOption, resp *octopus.GetMyAlgorithmListResp) error {
|
||||
if option.ModelType == "" {
|
||||
return errors.New("ModelType not set")
|
||||
}
|
||||
|
||||
if option.ModelName == "" {
|
||||
return errors.New("ModelName not set")
|
||||
}
|
||||
|
||||
for _, algorithm := range resp.Payload.Algorithms {
|
||||
if strings.Contains(algorithm.AlgorithmName, option.ModelName) {
|
||||
option.AlgorithmId = algorithm.AlgorithmId
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return errors.New("ModelName does not exist")
|
||||
}
|
||||
|
||||
func (o *OctopusLink) generateCmd(option *option.AiOption, ifoption *option.InferOption) error {
|
||||
if option != nil {
|
||||
err := generateCmdForTraining(option)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if ifoption != nil {
|
||||
err := generateCmdForInferDeployInstance(ifoption)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("failed to set cmd")
|
||||
}
|
||||
|
||||
func generateCmdForTraining(option *option.AiOption) error {
|
||||
if option.Cmd == "" {
|
||||
switch option.ComputeCard {
|
||||
case GCU:
|
||||
|
@ -779,6 +939,23 @@ func (o *OctopusLink) generateCmd(option *option.AiOption) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func generateCmdForInferDeployInstance(option *option.InferOption) error {
|
||||
if option.Cmd == "" {
|
||||
nameCmd, ok := CardModelNameCmdMap[option.ComputeCard]
|
||||
if !ok {
|
||||
return errors.New("failed to set cmd, ComputeCard not exist")
|
||||
}
|
||||
cmd, ok := nameCmd[option.ModelName]
|
||||
if !ok {
|
||||
return errors.New("failed to set cmd, ModelName not exist")
|
||||
}
|
||||
option.Cmd = cmd
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *OctopusLink) generateEnv(option *option.AiOption) error {
|
||||
|
||||
return nil
|
||||
|
@ -872,7 +1049,7 @@ func setResourceIdByCard(option *option.AiOption, specs *octopus.GetResourceSpec
|
|||
return errors.New("set ResourceId error")
|
||||
}
|
||||
|
||||
func (o *OctopusLink) GetInferUrl(ctx context.Context, option *option.InferOption) ([]*inference.InferUrl, error) {
|
||||
func (o *OctopusLink) GetClusterInferUrl(ctx context.Context, option *option.InferOption) (*inference.ClusterInferUrl, error) {
|
||||
req := &octopus.GetNotebookListReq{
|
||||
Platform: o.platform,
|
||||
PageIndex: o.pageIndex,
|
||||
|
@ -902,7 +1079,13 @@ func (o *OctopusLink) GetInferUrl(ctx context.Context, option *option.InferOptio
|
|||
if len(imageUrls) == 0 {
|
||||
return nil, errors.New("no infer url available")
|
||||
}
|
||||
return imageUrls, nil
|
||||
|
||||
clusterWithUrl := &inference.ClusterInferUrl{
|
||||
ClusterName: o.platform,
|
||||
ClusterType: TYPE_OCTOPUS,
|
||||
InferUrls: imageUrls,
|
||||
}
|
||||
return clusterWithUrl, nil
|
||||
}
|
||||
|
||||
func (o *OctopusLink) GetInferDeployInstanceList(ctx context.Context) ([]*inference.DeployInstance, error) {
|
||||
|
@ -926,6 +1109,7 @@ func (o *OctopusLink) GetInferDeployInstanceList(ctx context.Context) ([]*infere
|
|||
ins.InstanceId = notebook.Id
|
||||
ins.ClusterName = o.platform
|
||||
ins.Status = notebook.Status
|
||||
ins.ClusterType = TYPE_OCTOPUS
|
||||
insList = append(insList, ins)
|
||||
}
|
||||
return insList, nil
|
||||
|
@ -970,9 +1154,113 @@ func (o *OctopusLink) GetInferDeployInstance(ctx context.Context, id string) (*i
|
|||
if resp.Payload == nil {
|
||||
return nil, errors.New("instance does not exist")
|
||||
}
|
||||
|
||||
url := strings.Replace(resp.Payload.Notebook.Tasks[0].Url, FORWARD_SLASH, "", -1)
|
||||
inferUrl := DOMAIN + url
|
||||
|
||||
ins.InstanceName = resp.Payload.Notebook.Name
|
||||
ins.InstanceId = resp.Payload.Notebook.Id
|
||||
ins.ClusterName = o.platform
|
||||
ins.Status = resp.Payload.Notebook.Status
|
||||
ins.ClusterType = TYPE_OCTOPUS
|
||||
ins.InferUrl = inferUrl
|
||||
|
||||
return ins, nil
|
||||
}
|
||||
|
||||
func (o *OctopusLink) GetInferResult(ctx context.Context, url string, file multipart.File, fileName string) (string, error) {
|
||||
stream, err := o.octopusRpc.GetInferResult(ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
buffer := make([]byte, 2048)
|
||||
bufferedReader := bufio.NewReader(file)
|
||||
for {
|
||||
_, err = bufferedReader.Read(buffer)
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
return "", err
|
||||
}
|
||||
break
|
||||
}
|
||||
err = stream.Send(&octopus.InferResultReq{
|
||||
Platform: o.platform,
|
||||
InferUrl: url,
|
||||
FileName: fileName,
|
||||
FileBytes: buffer,
|
||||
})
|
||||
}
|
||||
|
||||
recv, err := stream.CloseAndRecv()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return recv.Result, nil
|
||||
}
|
||||
|
||||
func (o *OctopusLink) CreateInferDeployInstance(ctx context.Context, option *option.InferOption) (string, error) {
|
||||
err := o.generateResourceId(ctx, nil, option)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
err = o.generateAlgorithmId(ctx, nil, option)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
err = o.generateImageId(ctx, nil, option)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
err = o.generateCmd(nil, option)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
desc := option.ModelType + FORWARD_SLASH + option.ModelName + FORWARD_SLASH + strings.ToLower(BIV100)
|
||||
param := &octopus.CreateNotebookParam{
|
||||
Name: option.TaskName,
|
||||
ResourcePool: RESOURCE_POOL,
|
||||
ResourceSpecId: option.ResourceId,
|
||||
AlgorithmId: option.AlgorithmId,
|
||||
AlgorithmVersion: VERSION,
|
||||
ImageId: option.ImageId,
|
||||
DatasetId: "",
|
||||
DatasetVersion: "",
|
||||
Command: option.Cmd,
|
||||
Desc: desc,
|
||||
TaskNumber: 1,
|
||||
}
|
||||
req := &octopus.CreateNotebookReq{
|
||||
Platform: o.platform,
|
||||
Params: param,
|
||||
}
|
||||
|
||||
resp, err := o.octopusRpc.CreateNotebook(ctx, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if !resp.Success {
|
||||
return "", errors.New(resp.Error.Message)
|
||||
}
|
||||
|
||||
return resp.Payload.Id, nil
|
||||
}
|
||||
|
||||
func (o *OctopusLink) CheckModelExistence(ctx context.Context, name string, mtype string) bool {
|
||||
ifoption := &option.InferOption{
|
||||
ModelName: name,
|
||||
ModelType: mtype,
|
||||
}
|
||||
err := o.generateAlgorithmId(ctx, nil, ifoption)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/inference"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
||||
"mime/multipart"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -768,7 +769,7 @@ func (s *ShuguangAi) generateParams(option *option.AiOption) error {
|
|||
return errors.New("failed to set params")
|
||||
}
|
||||
|
||||
func (s *ShuguangAi) GetInferUrl(ctx context.Context, option *option.InferOption) ([]*inference.InferUrl, error) {
|
||||
func (s *ShuguangAi) GetClusterInferUrl(ctx context.Context, option *option.InferOption) (*inference.ClusterInferUrl, error) {
|
||||
var imageUrls []*inference.InferUrl
|
||||
|
||||
urlReq := &hpcAC.GetInferUrlReq{
|
||||
|
@ -787,7 +788,12 @@ func (s *ShuguangAi) GetInferUrl(ctx context.Context, option *option.InferOption
|
|||
}
|
||||
imageUrls = append(imageUrls, imageUrl)
|
||||
|
||||
return imageUrls, nil
|
||||
clusterWithUrl := &inference.ClusterInferUrl{
|
||||
ClusterName: s.platform,
|
||||
ClusterType: TYPE_SHUGUANGAI,
|
||||
InferUrls: imageUrls,
|
||||
}
|
||||
return clusterWithUrl, nil
|
||||
}
|
||||
|
||||
func (s *ShuguangAi) GetInferDeployInstanceList(ctx context.Context) ([]*inference.DeployInstance, error) {
|
||||
|
@ -815,6 +821,8 @@ func (s *ShuguangAi) GetInferDeployInstanceList(ctx context.Context) ([]*inferen
|
|||
ins.Status = datum.Status
|
||||
ins.InferCard = DCU
|
||||
ins.CreatedTime = datum.CreateTime
|
||||
ins.ClusterType = TYPE_SHUGUANGAI
|
||||
|
||||
insList = append(insList, ins)
|
||||
}
|
||||
|
||||
|
@ -865,5 +873,20 @@ func (s *ShuguangAi) GetInferDeployInstance(ctx context.Context, id string) (*in
|
|||
ins.Status = resp.Data.Status
|
||||
ins.InferCard = DCU
|
||||
ins.CreatedTime = resp.Data.CreateTime
|
||||
ins.ClusterType = TYPE_SHUGUANGAI
|
||||
|
||||
return ins, nil
|
||||
}
|
||||
|
||||
func (s *ShuguangAi) GetInferResult(ctx context.Context, url string, file multipart.File, fileName string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (s *ShuguangAi) CreateInferDeployInstance(ctx context.Context, option *option.InferOption) (string, error) {
|
||||
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (s *ShuguangAi) CheckModelExistence(ctx context.Context, name string, mtype string) bool {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -81,6 +81,8 @@ var (
|
|||
ModelTypeMap = map[string][]string{
|
||||
"image_classification": {"imagenet_resnet50"},
|
||||
"text_to_text": {"chatGLM_6B"},
|
||||
"image_to_text": {"blip-image-captioning-base"},
|
||||
"text_to_image": {"stable-diffusion-xl-base-1.0"},
|
||||
}
|
||||
AITYPE = map[string]string{
|
||||
"1": OCTOPUS,
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"github.com/robfig/cron/v3"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/config"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/database"
|
||||
|
|
|
@ -722,7 +722,14 @@ type AdapterInfo struct {
|
|||
}
|
||||
|
||||
type AdapterResp struct {
|
||||
Data AdapterInfo `json:"data,omitempty"`
|
||||
Id string `json:"id,omitempty" db:"id"`
|
||||
Name string `json:"name,omitempty" db:"name"`
|
||||
Type string `json:"type,omitempty" db:"type"`
|
||||
ResourceType string `json:"resourceType,omitempty" db:"resource_type"`
|
||||
Nickname string `json:"nickname,omitempty" db:"nickname"`
|
||||
Version string `json:"version,omitempty" db:"version"`
|
||||
Server string `json:"server,omitempty" db:"server"`
|
||||
CreateTime string `json:"createTime,omitempty" db:"create_time" gorm:"autoCreateTime"`
|
||||
}
|
||||
|
||||
type AdapterListResp struct {
|
||||
|
@ -2908,7 +2915,7 @@ type TrainingTaskStatResp struct {
|
|||
}
|
||||
|
||||
type ChatReq struct {
|
||||
ApiUrl string `json:"apiUrl"`
|
||||
Id uint `json:"id,string"`
|
||||
Method string `json:"method,optional"`
|
||||
ReqData map[string]interface{} `json:"reqData"`
|
||||
}
|
||||
|
@ -5897,6 +5904,24 @@ type Category struct {
|
|||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type DeployInstance struct {
|
||||
Id string `json:"id"`
|
||||
DeployTaskId string `json:"deployTaskId"`
|
||||
InstanceId string `json:"instanceId"`
|
||||
InstanceName string `json:"instanceName"`
|
||||
AdapterId string `json:"adapterId"`
|
||||
AdapterName string `json:"adapterName"`
|
||||
ClusterId string `json:"clusterId"`
|
||||
ClusterName string `json:"clusterName"`
|
||||
ModelName string `json:"modelName"`
|
||||
ModelType string `json:"modelType"`
|
||||
InferCard string `json:"inferCard"`
|
||||
Status string `json:"status"`
|
||||
CreateTime string `json:"createTime"`
|
||||
UpdateTime string `json:"updateTime"`
|
||||
ClusterType string `json:"clusterType"`
|
||||
}
|
||||
|
||||
type ModelTypesResp struct {
|
||||
ModelTypes []string `json:"types"`
|
||||
}
|
||||
|
@ -5910,20 +5935,13 @@ type ModelNamesResp struct {
|
|||
}
|
||||
|
||||
type ImageInferenceReq struct {
|
||||
TaskName string `form:"taskName"`
|
||||
TaskDesc string `form:"taskDesc"`
|
||||
ModelName string `form:"modelName"`
|
||||
ModelType string `form:"modelType"`
|
||||
AdapterId string `form:"adapterId"`
|
||||
AiClusterIds []string `form:"aiClusterIds,optional"`
|
||||
ResourceType string `form:"resourceType,optional"`
|
||||
ComputeCard string `form:"card,optional"`
|
||||
Strategy string `form:"strategy"`
|
||||
StaticWeightMap map[string]int32 `form:"staticWeightMap,optional"`
|
||||
Params []string `form:"params,optional"`
|
||||
Envs []string `form:"envs,optional"`
|
||||
Cmd string `form:"cmd,optional"`
|
||||
Replica int32 `form:"replicas,optional"`
|
||||
TaskName string `form:"taskName"`
|
||||
TaskDesc string `form:"taskDesc"`
|
||||
ModelType string `form:"modelType"`
|
||||
InstanceIds []int64 `form:"instanceIds"`
|
||||
Strategy string `form:"strategy,,optional"`
|
||||
StaticWeightMap map[string]map[string]int32 `form:"staticWeightMap,optional"`
|
||||
Replica int32 `form:"replicas,optional"`
|
||||
}
|
||||
|
||||
type ImageInferenceResp struct {
|
||||
|
@ -5969,6 +5987,18 @@ type TextToTextInferenceReq struct {
|
|||
type TextToTextInferenceResp struct {
|
||||
}
|
||||
|
||||
type TextToImageInferenceReq struct {
|
||||
TaskName string `form:"taskName"`
|
||||
TaskDesc string `form:"taskDesc"`
|
||||
ModelName string `form:"modelName"`
|
||||
ModelType string `form:"modelType"`
|
||||
AiClusterIds []string `form:"aiClusterIds"`
|
||||
}
|
||||
|
||||
type TextToImageInferenceResp struct {
|
||||
Result []byte `json:"result"`
|
||||
}
|
||||
|
||||
type DeployInstanceListReq struct {
|
||||
PageInfo
|
||||
}
|
||||
|
@ -6012,3 +6042,65 @@ type InferenceTaskStatResp struct {
|
|||
Running int32 `json:"running"`
|
||||
Total int32 `json:"total"`
|
||||
}
|
||||
|
||||
type StartAllByDeployTaskIdReq struct {
|
||||
Id string `json:"deployTaskId"`
|
||||
}
|
||||
|
||||
type StartAllByDeployTaskIdResp struct {
|
||||
}
|
||||
|
||||
type StopAllByDeployTaskIdReq struct {
|
||||
Id string `json:"deployTaskId"`
|
||||
}
|
||||
|
||||
type StopAllByDeployTaskIdResp struct {
|
||||
}
|
||||
|
||||
type GetRunningInstanceReq struct {
|
||||
Id string `form:"deployTaskId"`
|
||||
AdapterId string `form:"adapterId"`
|
||||
}
|
||||
|
||||
type GetRunningInstanceResp struct {
|
||||
List interface{} `json:"list"`
|
||||
}
|
||||
|
||||
type GetDeployTasksByTypeReq struct {
|
||||
ModelType string `form:"modelType"`
|
||||
}
|
||||
|
||||
type GetDeployTasksByTypeResp struct {
|
||||
List interface{} `json:"list"`
|
||||
}
|
||||
|
||||
type CreateDeployTaskReq struct {
|
||||
TaskName string `form:"taskName"`
|
||||
TaskDesc string `form:"taskDesc"`
|
||||
ModelName string `form:"modelName"`
|
||||
ModelType string `form:"modelType"`
|
||||
AdapterClusterMap map[string][]string `form:"adapterClusterMap"`
|
||||
}
|
||||
|
||||
type CreateDeployTaskResp struct {
|
||||
}
|
||||
|
||||
type GetAdaptersByModelReq struct {
|
||||
ModelName string `form:"modelName"`
|
||||
ModelType string `form:"modelType"`
|
||||
}
|
||||
|
||||
type GetAdaptersByModelResp struct {
|
||||
Adapters []*AdapterAvail `json:"adapters"`
|
||||
}
|
||||
|
||||
type AdapterAvail struct {
|
||||
AdapterId string `json:"adapterId"`
|
||||
AdapterName string `json:"taskName"`
|
||||
Clusters []*ClusterAvail `json:"clusters"`
|
||||
}
|
||||
|
||||
type ClusterAvail struct {
|
||||
ClusterId string `json:"clusterId"`
|
||||
ClusterName string `json:"clusterName"`
|
||||
}
|
||||
|
|
|
@ -28,4 +28,5 @@ const (
|
|||
WaitStart = "WaitStart"
|
||||
Pending = "Pending"
|
||||
Stopped = "Stopped"
|
||||
Deploying = "Deploying"
|
||||
)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package models
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ AiDeployInstanceTaskModel = (*customAiDeployInstanceTaskModel)(nil)
|
||||
|
||||
type (
|
||||
// AiDeployInstanceTaskModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customAiDeployInstanceTaskModel.
|
||||
AiDeployInstanceTaskModel interface {
|
||||
aiDeployInstanceTaskModel
|
||||
withSession(session sqlx.Session) AiDeployInstanceTaskModel
|
||||
}
|
||||
|
||||
customAiDeployInstanceTaskModel struct {
|
||||
*defaultAiDeployInstanceTaskModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewAiDeployInstanceTaskModel returns a model for the database table.
|
||||
func NewAiDeployInstanceTaskModel(conn sqlx.SqlConn) AiDeployInstanceTaskModel {
|
||||
return &customAiDeployInstanceTaskModel{
|
||||
defaultAiDeployInstanceTaskModel: newAiDeployInstanceTaskModel(conn),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customAiDeployInstanceTaskModel) withSession(session sqlx.Session) AiDeployInstanceTaskModel {
|
||||
return NewAiDeployInstanceTaskModel(sqlx.NewSqlConnFromSession(session))
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
var (
|
||||
aiDeployInstanceTaskFieldNames = builder.RawFieldNames(&AiDeployInstanceTask{})
|
||||
aiDeployInstanceTaskRows = strings.Join(aiDeployInstanceTaskFieldNames, ",")
|
||||
aiDeployInstanceTaskRowsExpectAutoSet = strings.Join(stringx.Remove(aiDeployInstanceTaskFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
aiDeployInstanceTaskRowsWithPlaceHolder = strings.Join(stringx.Remove(aiDeployInstanceTaskFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
)
|
||||
|
||||
type (
|
||||
aiDeployInstanceTaskModel interface {
|
||||
Insert(ctx context.Context, data *AiDeployInstanceTask) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*AiDeployInstanceTask, error)
|
||||
Update(ctx context.Context, data *AiDeployInstanceTask) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
|
||||
defaultAiDeployInstanceTaskModel struct {
|
||||
conn sqlx.SqlConn
|
||||
table string
|
||||
}
|
||||
|
||||
AiDeployInstanceTask struct {
|
||||
Id int64 `db:"id"`
|
||||
Name string `db:"name"`
|
||||
ModelName string `db:"model_name"`
|
||||
ModelType string `db:"model_type"`
|
||||
Desc string `db:"desc"`
|
||||
CreateTime string `db:"create_time"`
|
||||
UpdateTime string `db:"update_time"`
|
||||
}
|
||||
)
|
||||
|
||||
func newAiDeployInstanceTaskModel(conn sqlx.SqlConn) *defaultAiDeployInstanceTaskModel {
|
||||
return &defaultAiDeployInstanceTaskModel{
|
||||
conn: conn,
|
||||
table: "`ai_deploy_instance_task`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultAiDeployInstanceTaskModel) Delete(ctx context.Context, id int64) error {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
_, err := m.conn.ExecCtx(ctx, query, id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultAiDeployInstanceTaskModel) FindOne(ctx context.Context, id int64) (*AiDeployInstanceTask, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", aiDeployInstanceTaskRows, m.table)
|
||||
var resp AiDeployInstanceTask
|
||||
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultAiDeployInstanceTaskModel) Insert(ctx context.Context, data *AiDeployInstanceTask) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?)", m.table, aiDeployInstanceTaskRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.Name, data.ModelName, data.ModelType, data.Desc)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultAiDeployInstanceTaskModel) Update(ctx context.Context, data *AiDeployInstanceTask) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, aiDeployInstanceTaskRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, data.Name, data.ModelName, data.ModelType, data.Desc, data.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultAiDeployInstanceTaskModel) tableName() string {
|
||||
return m.table
|
||||
}
|
|
@ -35,20 +35,21 @@ type (
|
|||
}
|
||||
|
||||
AiInferDeployInstance struct {
|
||||
Id int64 `db:"id"`
|
||||
InstanceId string `db:"instance_id"`
|
||||
InstanceName string `db:"instance_name"`
|
||||
AdapterId int64 `db:"adapter_id"`
|
||||
AdapterName string `db:"adapter_name"`
|
||||
ClusterId int64 `db:"cluster_id"`
|
||||
ClusterName string `db:"cluster_name"`
|
||||
ModelName string `db:"model_name"`
|
||||
ModelType string `db:"model_type"`
|
||||
InferCard string `db:"infer_card"`
|
||||
Status string `db:"status"`
|
||||
CreateTime string `db:"create_time"`
|
||||
UpdateTime string `db:"update_time"`
|
||||
ClusterType string `db:"cluster_type"`
|
||||
Id int64 `db:"id" json:"id,string"`
|
||||
DeployInstanceTaskId int64 `db:"deploy_instance_task_id" json:"deployTaskId,string"`
|
||||
InstanceId string `db:"instance_id" json:"instanceId"`
|
||||
InstanceName string `db:"instance_name" json:"instanceName"`
|
||||
AdapterId int64 `db:"adapter_id" json:"adapterId,string"`
|
||||
AdapterName string `db:"adapter_name" json:"adapterName" `
|
||||
ClusterId int64 `db:"cluster_id" json:"clusterId,string"`
|
||||
ClusterName string `db:"cluster_name" json:"clusterName"`
|
||||
ModelName string `db:"model_name" json:"modelName"`
|
||||
ModelType string `db:"model_type" json:"modelType"`
|
||||
InferCard string `db:"infer_card" json:"inferCard"`
|
||||
Status string `db:"status" json:"status"`
|
||||
CreateTime string `db:"create_time" json:"createTime"`
|
||||
UpdateTime string `db:"update_time" json:"updateTime"`
|
||||
ClusterType string `db:"cluster_type" json:"clusterType"`
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -78,8 +78,18 @@ func HttpResult(r *http.Request, w http.ResponseWriter, resp interface{}, err er
|
|||
}
|
||||
|
||||
logx.WithContext(r.Context()).Errorf("【API-ERR】 : %+v ", err)
|
||||
|
||||
httpx.WriteJson(w, http.StatusBadRequest, Error(errcode, errmsg, r.Context()))
|
||||
// 判断如果err内容为"name already exists",则将resp作为body.Data的信息返回
|
||||
if errmsg == "name already exists" {
|
||||
body := Body{
|
||||
Code: 409,
|
||||
Msg: errmsg,
|
||||
TraceID: traceIDFromContext(r.Context()),
|
||||
Data: resp,
|
||||
}
|
||||
httpx.WriteJson(w, http.StatusBadRequest, body)
|
||||
} else {
|
||||
httpx.WriteJson(w, http.StatusBadRequest, Error(errcode, errmsg, r.Context()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,11 @@ func HttpClientWithBodyAndCode(method string, url string, payload io.Reader, tok
|
|||
func HttpClientWithScreen(method string, url string, payload io.Reader) (int, []byte, error) {
|
||||
request, err := http.NewRequest(method, url, payload)
|
||||
|
||||
client := &http.Client{}
|
||||
client := &http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
},
|
||||
}
|
||||
res, err := client.Do(request)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
Loading…
Reference in New Issue