forked from JointCloud/pcm-coordinator
fix: Modify the format models.TaskAi of the Ai task_ai
This commit is contained in:
parent
60babd1921
commit
78e9711628
|
@ -169,8 +169,8 @@ type AiInfo struct {
|
|||
Cmd string `json:"cmd,omitempty"`
|
||||
Envs []string `json:"envs,omitempty"`
|
||||
Params []string `json:"params,omitempty"`
|
||||
Environments []string `json:"environments,omitempty"`
|
||||
Parameters []string `json:"parameters,omitempty"`
|
||||
Environments string `json:"environments,omitempty"`
|
||||
Parameters string `json:"parameters,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
|
|
|
@ -2,12 +2,15 @@ package core
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/jinzhu/copier"
|
||||
clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models/cloud"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
||||
"gorm.io/gorm"
|
||||
"log"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
|
@ -81,6 +84,39 @@ func (l *PullTaskInfoLogic) PullTaskInfo(req *clientCore.PullTaskInfoReq) (*clie
|
|||
return nil, err
|
||||
}
|
||||
utils.Convert(aiModelList, &resp.AiInfoList)
|
||||
if len(resp.AiInfoList) > 0 {
|
||||
for i, aiInfo := range aiModelList {
|
||||
if resp.AiInfoList[i].Environments != "" {
|
||||
// 定义一个map来存储解析后的JSON数据
|
||||
var result map[string]interface{}
|
||||
// 解析JSON字符串
|
||||
err := json.Unmarshal([]byte(resp.AiInfoList[i].Environments), &result)
|
||||
if err != nil {
|
||||
log.Fatalf("Error parsing JSON: %v", err)
|
||||
}
|
||||
// 如果你需要将解析后的map再次转换为JSON字符串,可以使用json.MarshalIndent
|
||||
formattedJSON, err := json.MarshalIndent(result, "", " ")
|
||||
aiInfo.Environments = string(formattedJSON)
|
||||
fmt.Println(aiInfo.Environments)
|
||||
resp.AiInfoList[i].Environments = aiInfo.Environments
|
||||
}
|
||||
if resp.AiInfoList[i].Parameters != "" {
|
||||
// 定义一个map来存储解析后的JSON数据
|
||||
var result []interface{}
|
||||
// 解析JSON字符串
|
||||
err := json.Unmarshal([]byte(resp.AiInfoList[i].Parameters), &result)
|
||||
if err != nil {
|
||||
log.Fatalf("Error parsing JSON: %v", err)
|
||||
}
|
||||
// 如果你需要将解析后的map再次转换为JSON字符串,可以使用json.MarshalIndent
|
||||
formattedJSON, err := json.MarshalIndent(result, "", " ")
|
||||
aiInfo.Parameters = string(formattedJSON)
|
||||
fmt.Println(aiInfo.Parameters)
|
||||
resp.AiInfoList[i].Parameters = aiInfo.Parameters
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue