算力接口、配置调整
This commit is contained in:
parent
9471d0cb71
commit
fdbe177c63
|
@ -31,5 +31,5 @@ type Config struct {
|
||||||
THRpcConf zrpc.RpcClientConf
|
THRpcConf zrpc.RpcClientConf
|
||||||
ModelArtsRpcConf zrpc.RpcClientConf
|
ModelArtsRpcConf zrpc.RpcClientConf
|
||||||
CephRpcConf zrpc.RpcClientConf
|
CephRpcConf zrpc.RpcClientConf
|
||||||
//OctopusRpcConf zrpc.RpcClientConf
|
OctopusRpcConf zrpc.RpcClientConf
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC"
|
"PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus"
|
||||||
"context"
|
|
||||||
|
|
||||||
"PCM/adaptor/PCM-CORE/api/internal/svc"
|
"PCM/adaptor/PCM-CORE/api/internal/svc"
|
||||||
"PCM/adaptor/PCM-CORE/api/internal/types"
|
"PCM/adaptor/PCM-CORE/api/internal/types"
|
||||||
|
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC"
|
||||||
|
"context"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
@ -27,19 +28,22 @@ func NewGetComputingPowerLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
||||||
func (l *GetComputingPowerLogic) GetComputingPower() (resp *types.CpResp, err error) {
|
func (l *GetComputingPowerLogic) GetComputingPower() (resp *types.CpResp, err error) {
|
||||||
|
|
||||||
apiResp := types.CpResp{}
|
apiResp := types.CpResp{}
|
||||||
|
|
||||||
|
//启智章鱼资源算力
|
||||||
|
octopusCpReq := &octopus.ResourceReq{}
|
||||||
|
octopusCpResp, err := l.svcCtx.OctopusRpc.GetComputingPower(l.ctx, octopusCpReq)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("OctopusRpc 算力请求失败", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
//曙光账号算力
|
||||||
acCpReq := &hpcAC.ResourceReq{}
|
acCpReq := &hpcAC.ResourceReq{}
|
||||||
acCpResp, err := l.svcCtx.ACRpc.GetComputingPower(l.ctx, acCpReq)
|
acCpResp, err := l.svcCtx.ACRpc.GetComputingPower(l.ctx, acCpReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
log.Println("ACRpc 算力请求失败", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//octopusCpReq := &octopus.ResourceReq{}
|
computingPowerAggregated := acCpResp.POpsAtFp16 + octopusCpResp.POpsAtFp16
|
||||||
//octopusCpResp, err := l.svcCtx.OctopusRpc.GetComputingPower(l.ctx, octopusCpReq)
|
apiResp.POpsAtFp16 = computingPowerAggregated
|
||||||
//if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//computingPowerAggregated := acCpResp.POpsAtFp16 + octopusCpResp.POpsAtFp16
|
|
||||||
apiResp.POpsAtFp16 = acCpResp.POpsAtFp16
|
|
||||||
return &apiResp, nil
|
return &apiResp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package svc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelartsclient"
|
"PCM/adaptor/PCM-AI/PCM-MODELARTS/rpc/modelartsclient"
|
||||||
|
"PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopusclient"
|
||||||
"PCM/adaptor/PCM-CORE/api/internal/config"
|
"PCM/adaptor/PCM-CORE/api/internal/config"
|
||||||
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcacclient"
|
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcacclient"
|
||||||
"PCM/adaptor/PCM-HPC/PCM-TH/rpc/hpcthclient"
|
"PCM/adaptor/PCM-HPC/PCM-TH/rpc/hpcthclient"
|
||||||
|
@ -26,7 +27,7 @@ type ServiceContext struct {
|
||||||
DbEngin *gorm.DB
|
DbEngin *gorm.DB
|
||||||
ACRpc hpcacclient.HpcAC
|
ACRpc hpcacclient.HpcAC
|
||||||
THRpc hpcthclient.HpcTH
|
THRpc hpcthclient.HpcTH
|
||||||
//OctopusRpc octopusclient.Octopus
|
OctopusRpc octopusclient.Octopus
|
||||||
CephRpc cephclient.Ceph
|
CephRpc cephclient.Ceph
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +53,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||||
CephRpc: cephclient.NewCeph(zrpc.MustNewClient(c.CephRpcConf)),
|
CephRpc: cephclient.NewCeph(zrpc.MustNewClient(c.CephRpcConf)),
|
||||||
ACRpc: hpcacclient.NewHpcAC(zrpc.MustNewClient(c.ACRpcConf)),
|
ACRpc: hpcacclient.NewHpcAC(zrpc.MustNewClient(c.ACRpcConf)),
|
||||||
//THRpc: hpcthclient.NewHpcTH(zrpc.MustNewClient(c.THRpcConf)),
|
//THRpc: hpcthclient.NewHpcTH(zrpc.MustNewClient(c.THRpcConf)),
|
||||||
//OctopusRpc: octopusclient.NewOctopus(zrpc.MustNewClient(c.OctopusRpcConf)),
|
OctopusRpc: octopusclient.NewOctopus(zrpc.MustNewClient(c.OctopusRpcConf)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ func NewGetComputingPowerLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
||||||
func (l *GetComputingPowerLogic) GetComputingPower(in *hpcAC.ResourceReq) (*hpcAC.CpResp, error) {
|
func (l *GetComputingPowerLogic) GetComputingPower(in *hpcAC.ResourceReq) (*hpcAC.CpResp, error) {
|
||||||
|
|
||||||
resp := &hpcAC.CpResp{}
|
resp := &hpcAC.CpResp{}
|
||||||
|
resp.POpsAtFp16 = 0
|
||||||
|
|
||||||
cpConf := l.svcCtx.Config.CPConf
|
cpConf := l.svcCtx.Config.CPConf
|
||||||
|
|
||||||
tokenUrl := cpConf.AcBaseUrl + cpConf.AuthUrl
|
tokenUrl := cpConf.AcBaseUrl + cpConf.AuthUrl
|
||||||
|
@ -47,7 +49,7 @@ func (l *GetComputingPowerLogic) GetComputingPower(in *hpcAC.ResourceReq) (*hpcA
|
||||||
Post(tokenUrl)
|
Post(tokenUrl)
|
||||||
|
|
||||||
if err != nil || tokenResp.Code != "0" {
|
if err != nil || tokenResp.Code != "0" {
|
||||||
return nil, err
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, datum := range tokenResp.Data {
|
for _, datum := range tokenResp.Data {
|
||||||
|
@ -67,7 +69,7 @@ func (l *GetComputingPowerLogic) GetComputingPower(in *hpcAC.ResourceReq) (*hpcA
|
||||||
SetResult(¢erResp).
|
SetResult(¢erResp).
|
||||||
Get(centerUrl)
|
Get(centerUrl)
|
||||||
if err != nil || centerResp.Code != "0" {
|
if err != nil || centerResp.Code != "0" {
|
||||||
return nil, err
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
hpc_prefix_url = centerResp.Data.HpcUrls[0].Url
|
hpc_prefix_url = centerResp.Data.HpcUrls[0].Url
|
||||||
|
@ -83,7 +85,7 @@ func (l *GetComputingPowerLogic) GetComputingPower(in *hpcAC.ResourceReq) (*hpcA
|
||||||
SetResult(&clusterResp).
|
SetResult(&clusterResp).
|
||||||
Get(clusterUrl)
|
Get(clusterUrl)
|
||||||
if err != nil || clusterResp.Code != "0" {
|
if err != nil || clusterResp.Code != "0" {
|
||||||
return nil, err
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
jobManagerId = clusterResp.Data[0].Id
|
jobManagerId = clusterResp.Data[0].Id
|
||||||
|
@ -99,7 +101,7 @@ func (l *GetComputingPowerLogic) GetComputingPower(in *hpcAC.ResourceReq) (*hpcA
|
||||||
SetResult("aResp).
|
SetResult("aResp).
|
||||||
Get(quotaUrl)
|
Get(quotaUrl)
|
||||||
if err != nil || quotaResp.Code != "0" {
|
if err != nil || quotaResp.Code != "0" {
|
||||||
return nil, err
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取算力
|
//获取算力
|
||||||
|
@ -115,6 +117,10 @@ func (l *GetComputingPowerLogic) GetComputingPower(in *hpcAC.ResourceReq) (*hpcA
|
||||||
computingPowerInTops += float32(cpuCoreNum) * cpConf.CpuCore
|
computingPowerInTops += float32(cpuCoreNum) * cpConf.CpuCore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if computingPowerInTops == 0 {
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
resp.POpsAtFp16 = computingPowerInTops / 1024
|
resp.POpsAtFp16 = computingPowerInTops / 1024
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue