解决json格式字符串转义的问题

This commit is contained in:
somunslotus 2025-02-28 16:53:51 +08:00
parent 3fb935eeb5
commit cb9400e170
5 changed files with 22 additions and 7 deletions

View File

@ -47,8 +47,8 @@ fi
echo "################### deploy start ###################"
scp pipeline-convert_dlv.yaml root@172.20.32.181:/home/deploy/script/pipeline-convert/pipeline-convert_dlv.yaml
ssh root@172.20.32.181 "unset http_proxy && unset https_proxy && kubectl apply -f /home/deploy/script/pipeline-convert/pipeline-convert_dlv.yaml"
scp pipeline-convert_dlv.yaml root@172.20.32.197:/home/deploy/script/pipeline-convert/pipeline-convert_dlv.yaml
ssh root@172.20.32.197 "unset http_proxy && unset https_proxy && kubectl apply -f /home/deploy/script/pipeline-convert/pipeline-convert_dlv.yaml"
sed -i "s#${image}#pipeline-image#g" pipeline-convert_dlv.yaml
if [ "$?" -ne "0" ];then
echo "deploy fail"

View File

@ -299,7 +299,7 @@ func (c *ConvertHandler) optimizationReqToDag(req OptimizeRequest) (*model.Dag,
lines := []model.Line{
{
Source: frameworkComponent.TaskID,
Target: optimizerComponent.TaskID,
Target: trainCodeComponent.TaskID,
},
{
Source: trainCodeComponent.TaskID,

View File

@ -369,8 +369,8 @@ func (l *logService) getLogContent(c *gin.Context, response LogResponse, directi
var endTime string
var logEntries []*LogEntry
for _, result := range response.Data.Result {
//只获取stdout日志, 后续可能需要增加日志类型过滤
//if result.Stream.Stream != "stdout" {
////只获取stdout日志, 后续可能需要增加日志类型过滤
//if result.Stream.Container == "wait" {
// continue
//}
if len(result.Values) == 0 {

View File

@ -3,6 +3,7 @@ package parse
import (
"fmt"
"pipeline-convert/internal/model"
"strconv"
"strings"
)
@ -17,7 +18,21 @@ func escapeParam(value string) string {
return fmt.Sprintf(`"%s"`, strings.ReplaceAll(value, `"`, `\"`))
}
// 检查值是否为合法 JSON
func isNumber(s string) bool {
// 去除首尾空格(可选)
trimmed := strings.TrimSpace(s)
_, err := strconv.ParseFloat(trimmed, 64)
return err == nil
}
func (r *normalStrTypeParser) ParseType(key string, param model.Param) (*TypeResult, error) {
if isNumber(param.Value) {
return &TypeResult{
Args: []string{fmt.Sprintf("%s=%s", key, param.Value)},
}, nil
}
return &TypeResult{
Args: []string{fmt.Sprintf(`%s=%s`, key, escapeParam(param.Value))},
}, nil

View File

@ -60,8 +60,9 @@ kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pipeline-convert-log-pvc-nfs
namespace: argo
spec:
storageClassName: storage-nfs
storageClassName: nfs-client
accessModes:
- ReadWriteMany
resources:
@ -72,4 +73,3 @@ spec: