Browse Source

update octopusHttp service

pull/503/head
tzwang 5 months ago
parent
commit
4cb7633870
3 changed files with 18 additions and 9 deletions
  1. +8
    -3
      internal/scheduler/schedulers/aiScheduler.go
  2. +1
    -1
      internal/scheduler/service/aiService.go
  3. +9
    -5
      internal/storeLink/octopusHttp/octopusHttp.go

+ 8
- 3
internal/scheduler/schedulers/aiScheduler.go View File

@@ -471,13 +471,18 @@ func convertType(in interface{}) (*AiResult, error) {


return &result, nil return &result, nil
case *entity.OctCreateJobResp: case *entity.OctCreateJobResp:
resp := (in).(entity.OctCreateJobResp)
resp := (in).(*entity.OctCreateJobResp)


if resp.Code != 200 { if resp.Code != 200 {
result.Msg = resp.Msg result.Msg = resp.Msg
} else { } else {
job := (resp.Data).(*omodel.OctCreateJob)
result.JobId = job.JobId
var cj omodel.OctCreateJob
m, _ := json.Marshal(resp.Data)
err := json.Unmarshal([]byte(m), &cj)
if err != nil {
return nil, err
}
result.JobId = cj.JobId
} }


return &result, nil return &result, nil


+ 1
- 1
internal/scheduler/service/aiService.go View File

@@ -73,7 +73,7 @@ func InitAiClusterMap(conf *config.Config, clusters []types.ClusterInfo) (map[st
collectorMap := make(map[string]collector.AiCollector) collectorMap := make(map[string]collector.AiCollector)
inferenceMap := make(map[string]inference.ICluster) inferenceMap := make(map[string]inference.ICluster)
for _, c := range clusters { for _, c := range clusters {
switch c.Name {
switch c.Driver {
case OCTOPUS: case OCTOPUS:
id, _ := strconv.ParseInt(c.Id, 10, 64) id, _ := strconv.ParseInt(c.Id, 10, 64)
octopus := octopusHttp.NewOctopusHttp(id, c.Nickname, c.Server, c.Address, c.Username, c.Password) octopus := octopusHttp.NewOctopusHttp(id, c.Nickname, c.Server, c.Address, c.Username, c.Password)


+ 9
- 5
internal/storeLink/octopusHttp/octopusHttp.go View File

@@ -129,7 +129,6 @@ func (o *OctopusHttp) Stop(ctx context.Context, id string) error {
} }


func (o *OctopusHttp) SubmitTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) { func (o *OctopusHttp) SubmitTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) {

// octopus提交任务 // octopus提交任务
reqUrl := o.server + CreateTrainJobUrl reqUrl := o.server + CreateTrainJobUrl


@@ -188,6 +187,8 @@ func (o *OctopusHttp) SubmitTask(ctx context.Context, imageId string, cmd string
req := common.GetRestyRequest(common.TIMEOUT) req := common.GetRestyRequest(common.TIMEOUT)
_, err = req. _, err = req.
SetHeader("Authorization", "Bearer "+token). SetHeader("Authorization", "Bearer "+token).
SetQueryString("token=" + token).
SetQueryString("addr=" + o.host).
SetBody(param). SetBody(param).
SetResult(resp). SetResult(resp).
Post(reqUrl) Post(reqUrl)
@@ -531,13 +532,16 @@ func genClusterResources(cType string, cNum string, s *omodel.Spec) (*collector.
cres := &collector.ClusterResource{} cres := &collector.ClusterResource{}
bres := make([]*collector.Usage, 0) bres := make([]*collector.Usage, 0)


var cardNum int64
var cpuCore int64

cardNum, err := strconv.ParseInt(cNum, 10, 64) cardNum, err := strconv.ParseInt(cNum, 10, 64)
if err != nil { if err != nil {
return nil, err
cardNum = 0
} }
cpuCore, err := strconv.ParseInt(s.ResourceQuantity.Cpu, 10, 64)
cpuCore, err = strconv.ParseInt(s.ResourceQuantity.Cpu, 10, 64)
if err != nil { if err != nil {
return nil, err
cpuCore = 0
} }
gi := strings.Split(s.ResourceQuantity.Memory, Gi) gi := strings.Split(s.ResourceQuantity.Memory, Gi)
if len(gi) != 2 { if len(gi) != 2 {
@@ -546,7 +550,7 @@ func genClusterResources(cType string, cNum string, s *omodel.Spec) (*collector.


memGi, err := strconv.ParseInt(gi[0], 10, 64) memGi, err := strconv.ParseInt(gi[0], 10, 64)
if err != nil { if err != nil {
return nil, err
memGi = 0
} }


card := &collector.Usage{ card := &collector.Usage{


Loading…
Cancel
Save