Browse Source

增加打印。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.10.1^2
zouap 3 years ago
parent
commit
442fe4799e
2 changed files with 30 additions and 14 deletions
  1. +20
    -7
      modules/aisafety/resty.go
  2. +10
    -7
      routers/repo/aisafety.go

+ 20
- 7
modules/aisafety/resty.go View File

@@ -167,7 +167,7 @@ func CreateSafetyTask(req TaskReq, jsonstr string) (string, error) {
return "", nil return "", nil
} }


func GetAlgorithmList() error {
func GetAlgorithmList() (map[string]interface{}, error) {
checkSetting() checkSetting()
client := getRestyClient() client := getRestyClient()
params := make(map[string]interface{}) params := make(map[string]interface{})
@@ -192,13 +192,20 @@ func GetAlgorithmList() error {


if err != nil { if err != nil {
log.Info("error =" + err.Error()) log.Info("error =" + err.Error())
return fmt.Errorf("resty GetJob: %v", err)
return nil, fmt.Errorf("resty GetJob: %v", err)
} else {
reMap := make(map[string]interface{})
err = json.Unmarshal(res.Body(), &reMap)
if err == nil && reMap["code"] == "0" {
return reMap, nil
} else {
return nil, fmt.Errorf("get error,code not 0")
}
} }


return nil
} }


func GetTaskStatus(jobID string) error {
func GetTaskStatus(jobID string) (map[string]interface{}, error) {
checkSetting() checkSetting()
client := getRestyClient() client := getRestyClient()
var taskResult string var taskResult string
@@ -219,8 +226,14 @@ func GetTaskStatus(jobID string) error {


if err != nil { if err != nil {
log.Info("error =" + err.Error()) log.Info("error =" + err.Error())
return fmt.Errorf("resty GetJob: %v", err)
return nil, fmt.Errorf("resty GetJob: %v", err)
} else {
reMap := make(map[string]interface{})
err = json.Unmarshal(res.Body(), &reMap)
if err == nil && reMap["code"] == "0" {
return reMap, nil
} else {
return nil, fmt.Errorf("get error,code not 0")
}
} }

return nil
} }

+ 10
- 7
routers/repo/aisafety.go View File

@@ -23,7 +23,7 @@ func CloudBrainAiSafetyCreateTest(ctx *context.Context) {
log.Info("start to create CloudBrainAiSafetyCreate") log.Info("start to create CloudBrainAiSafetyCreate")
uuid := uuid.NewV4() uuid := uuid.NewV4()
id := uuid.String() id := uuid.String()
//jobType := ctx.Query("jobType")
seriaNoParas := ctx.Query("serialNo")
//if jobType == string(models.JobTypeBenchmark) { //if jobType == string(models.JobTypeBenchmark) {
jsonStr, err := getJsonContent("http://192.168.207.34:8065/Test_zap1234/openi_aisafety/raw/branch/master/result/0301.json") jsonStr, err := getJsonContent("http://192.168.207.34:8065/Test_zap1234/openi_aisafety/raw/branch/master/result/0301.json")
if err == nil { if err == nil {
@@ -37,13 +37,16 @@ func CloudBrainAiSafetyCreateTest(ctx *context.Context) {
BDName: "cifar10_1000", BDName: "cifar10_1000",
} }
aisafety.GetAlgorithmList() aisafety.GetAlgorithmList()
serialNo, err := aisafety.CreateSafetyTask(req, jsonStr)
if err == nil {
log.Info("serialNo=" + serialNo)
time.Sleep(time.Duration(2) * time.Second)
aisafety.GetTaskStatus(serialNo)
if seriaNoParas != "" {
aisafety.GetTaskStatus(seriaNoParas)
} else { } else {
log.Info("CreateSafetyTask error," + err.Error())
serialNo, err := aisafety.CreateSafetyTask(req, jsonStr)
if err == nil {
log.Info("serialNo=" + serialNo)
time.Sleep(time.Duration(2) * time.Second)
} else {
log.Info("CreateSafetyTask error," + err.Error())
}
} }
} }
//} //}


Loading…
Cancel
Save