diff --git a/adaptor/PCM-CORE/api/internal/config/config.go b/adaptor/PCM-CORE/api/internal/config/config.go index 5a09f30d..1a862052 100644 --- a/adaptor/PCM-CORE/api/internal/config/config.go +++ b/adaptor/PCM-CORE/api/internal/config/config.go @@ -31,5 +31,5 @@ type Config struct { THRpcConf zrpc.RpcClientConf ModelArtsRpcConf zrpc.RpcClientConf CephRpcConf zrpc.RpcClientConf - //OctopusRpcConf zrpc.RpcClientConf + OctopusRpcConf zrpc.RpcClientConf } diff --git a/adaptor/PCM-CORE/api/internal/logic/core/getcomputingpowerlogic.go b/adaptor/PCM-CORE/api/internal/logic/core/getcomputingpowerlogic.go index fbec51c3..c199760e 100644 --- a/adaptor/PCM-CORE/api/internal/logic/core/getcomputingpowerlogic.go +++ b/adaptor/PCM-CORE/api/internal/logic/core/getcomputingpowerlogic.go @@ -1,11 +1,12 @@ package core import ( - "PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC" - "context" - + "PCM/adaptor/PCM-AI/PCM-OCTOPUS/rpc/octopus" "PCM/adaptor/PCM-CORE/api/internal/svc" "PCM/adaptor/PCM-CORE/api/internal/types" + "PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC" + "context" + "log" "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) { 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{} acCpResp, err := l.svcCtx.ACRpc.GetComputingPower(l.ctx, acCpReq) if err != nil { - return nil, err + log.Println("ACRpc 算力请求失败", err) } - //octopusCpReq := &octopus.ResourceReq{} - //octopusCpResp, err := l.svcCtx.OctopusRpc.GetComputingPower(l.ctx, octopusCpReq) - //if err != nil { - // return nil, err - //} - // - //computingPowerAggregated := acCpResp.POpsAtFp16 + octopusCpResp.POpsAtFp16 - apiResp.POpsAtFp16 = acCpResp.POpsAtFp16 + computingPowerAggregated := acCpResp.POpsAtFp16 + octopusCpResp.POpsAtFp16 + apiResp.POpsAtFp16 = computingPowerAggregated return &apiResp, nil } diff --git a/adaptor/PCM-CORE/api/internal/svc/servicecontext.go b/adaptor/PCM-CORE/api/internal/svc/servicecontext.go index 81b795e7..14675c6e 100644 --- a/adaptor/PCM-CORE/api/internal/svc/servicecontext.go +++ b/adaptor/PCM-CORE/api/internal/svc/servicecontext.go @@ -2,6 +2,7 @@ package svc import ( "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-HPC/PCM-AC/rpc/hpcacclient" "PCM/adaptor/PCM-HPC/PCM-TH/rpc/hpcthclient" @@ -26,8 +27,8 @@ type ServiceContext struct { DbEngin *gorm.DB ACRpc hpcacclient.HpcAC THRpc hpcthclient.HpcTH - //OctopusRpc octopusclient.Octopus - CephRpc cephclient.Ceph + OctopusRpc octopusclient.Octopus + CephRpc cephclient.Ceph } func NewServiceContext(c config.Config) *ServiceContext { @@ -52,6 +53,6 @@ func NewServiceContext(c config.Config) *ServiceContext { CephRpc: cephclient.NewCeph(zrpc.MustNewClient(c.CephRpcConf)), ACRpc: hpcacclient.NewHpcAC(zrpc.MustNewClient(c.ACRpcConf)), //THRpc: hpcthclient.NewHpcTH(zrpc.MustNewClient(c.THRpcConf)), - //OctopusRpc: octopusclient.NewOctopus(zrpc.MustNewClient(c.OctopusRpcConf)), + OctopusRpc: octopusclient.NewOctopus(zrpc.MustNewClient(c.OctopusRpcConf)), } } diff --git a/adaptor/PCM-HPC/PCM-AC/rpc/internal/logic/getcomputingpowerlogic.go b/adaptor/PCM-HPC/PCM-AC/rpc/internal/logic/getcomputingpowerlogic.go index 74293ba0..d549aa11 100644 --- a/adaptor/PCM-HPC/PCM-AC/rpc/internal/logic/getcomputingpowerlogic.go +++ b/adaptor/PCM-HPC/PCM-AC/rpc/internal/logic/getcomputingpowerlogic.go @@ -30,6 +30,8 @@ func NewGetComputingPowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) func (l *GetComputingPowerLogic) GetComputingPower(in *hpcAC.ResourceReq) (*hpcAC.CpResp, error) { resp := &hpcAC.CpResp{} + resp.POpsAtFp16 = 0 + cpConf := l.svcCtx.Config.CPConf tokenUrl := cpConf.AcBaseUrl + cpConf.AuthUrl @@ -47,7 +49,7 @@ func (l *GetComputingPowerLogic) GetComputingPower(in *hpcAC.ResourceReq) (*hpcA Post(tokenUrl) if err != nil || tokenResp.Code != "0" { - return nil, err + return resp, nil } for _, datum := range tokenResp.Data { @@ -67,7 +69,7 @@ func (l *GetComputingPowerLogic) GetComputingPower(in *hpcAC.ResourceReq) (*hpcA SetResult(¢erResp). Get(centerUrl) if err != nil || centerResp.Code != "0" { - return nil, err + return resp, nil } hpc_prefix_url = centerResp.Data.HpcUrls[0].Url @@ -83,7 +85,7 @@ func (l *GetComputingPowerLogic) GetComputingPower(in *hpcAC.ResourceReq) (*hpcA SetResult(&clusterResp). Get(clusterUrl) if err != nil || clusterResp.Code != "0" { - return nil, err + return resp, nil } jobManagerId = clusterResp.Data[0].Id @@ -99,7 +101,7 @@ func (l *GetComputingPowerLogic) GetComputingPower(in *hpcAC.ResourceReq) (*hpcA SetResult("aResp). Get(quotaUrl) 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 } + if computingPowerInTops == 0 { + return resp, nil + } + resp.POpsAtFp16 = computingPowerInTops / 1024 return resp, nil }