fix convert bugs

Former-commit-id: 3cb8e750a3fb55017152108be812b37dff510095
This commit is contained in:
tzwang 2024-05-11 17:59:03 +08:00
parent f264ac5124
commit 52aa14c613
1 changed files with 31 additions and 7 deletions

View File

@ -53,7 +53,7 @@ const (
EnflameT20 = 128
BASE_TOPS = 128
CAMBRICON = "cambricon"
TIANSHU = "天数"
ILUVATAR = "iluvatar"
TRAIN_CMD = "cd /code; python train.py"
VERSION = "V1"
DOMAIN = "http://192.168.242.41:8001/"
@ -63,7 +63,7 @@ var (
cardAliasMap = map[string]string{
MLU: CAMBRICON,
GCU: ENFLAME,
BIV100: TIANSHU,
BIV100: ILUVATAR,
}
cardTopsMap = map[string]float64{
MLU: CAMBRICONMLU290,
@ -373,20 +373,37 @@ func (o *OctopusLink) DownloadAlgorithmCode(ctx context.Context, resourceType st
}
var algorithmId string
var algorithms []*octopus.Algorithms
for _, a := range resp.Payload.Algorithms {
if strings.ToLower(a.FrameworkName) != taskType {
continue
}
if a.AlgorithmName == name {
algorithmId = a.AlgorithmId
break
if a.AlgorithmDescript == name {
algorithms = append(algorithms, a)
}
}
if algorithmId == "" {
if len(algorithms) == 0 {
return "", errors.New("algorithmId not found")
}
if len(algorithms) == 1 {
algorithmId = algorithms[0].AlgorithmId
}
aLatest := &octopus.Algorithms{}
for i, _ := range algorithms {
if time.Unix(aLatest.CreatedAt, 0).After(time.Unix(algorithms[i].CreatedAt, 0)) {
aLatest = algorithms[i]
}
}
if aLatest.AlgorithmId == "" {
return "", errors.New("algorithmId not found")
}
algorithmId = aLatest.AlgorithmId
dcReq := &octopus.DownloadCompressReq{
Platform: o.platform,
Version: VERSION,
@ -428,6 +445,13 @@ func (o *OctopusLink) DownloadAlgorithmCode(ctx context.Context, resourceType st
}
func (o *OctopusLink) UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error {
//var name string
//if resourceType == CARD {
// name = dataset + UNDERSCORE + algorithm + UNDERSCORE + card
//} else {
// name = dataset + UNDERSCORE + algorithm + UNDERSCORE + CPU
//}
//uploadReq := &octopus.UploadAlgorithmReq{}
return nil
}
@ -457,7 +481,7 @@ func (o *OctopusLink) GetTrainingTask(ctx context.Context, taskId string) (*coll
}
jobresp := (resp).(*octopus.GetTrainJobResp)
if !jobresp.Success {
return nil, errors.New(jobresp.Error.Message)
return nil, errors.New("get training task failed")
}
var task collector.Task
task.Id = jobresp.Payload.TrainJob.Id