@@ -597,6 +597,7 @@ var ( | |||||
}{} | }{} | ||||
C2NetInfos *C2NetSqInfos | C2NetInfos *C2NetSqInfos | ||||
C2NetMapInfo map[string]*C2NetSequenceInfo | |||||
//elk config | //elk config | ||||
ElkUrl string | ElkUrl string | ||||
@@ -1632,6 +1633,10 @@ func getGrampusConfig() { | |||||
if err := json.Unmarshal([]byte(Grampus.C2NetSequence), &C2NetInfos); err != nil { | if err := json.Unmarshal([]byte(Grampus.C2NetSequence), &C2NetInfos); err != nil { | ||||
log.Error("Unmarshal(C2NetSequence) failed:%v", err) | log.Error("Unmarshal(C2NetSequence) failed:%v", err) | ||||
} | } | ||||
C2NetMapInfo=make(map[string]*C2NetSequenceInfo) | |||||
for _,value :=range C2NetInfos.C2NetSqInfo{ | |||||
C2NetMapInfo[value.Name]=value | |||||
} | |||||
} | } | ||||
Grampus.SyncScriptProject = sec.Key("SYNC_SCRIPT_PROJECT").MustString("script_for_grampus") | Grampus.SyncScriptProject = sec.Key("SYNC_SCRIPT_PROJECT").MustString("script_for_grampus") | ||||
@@ -752,47 +752,48 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||||
ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | ||||
return | return | ||||
} | } | ||||
result, err := cloudbrain.GetJob(task.JobID) | |||||
if err != nil { | |||||
log.Info("error:" + err.Error()) | |||||
ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||||
return | |||||
} | |||||
prepareSpec4Show(ctx, task) | prepareSpec4Show(ctx, task) | ||||
if ctx.Written() { | if ctx.Written() { | ||||
return | return | ||||
} | } | ||||
if task.Status==string(models.JobWaiting) || task.Status==string(models.JobRunning) { | |||||
result, err := cloudbrain.GetJob(task.JobID) | |||||
if err != nil { | |||||
log.Info("error:" + err.Error()) | |||||
ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||||
return | |||||
} | |||||
if result != nil { | |||||
jobRes, _ := models.ConvertToJobResultPayload(result.Payload) | |||||
taskRoles := jobRes.TaskRoles | |||||
taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | |||||
ctx.Data["taskRes"] = taskRes | |||||
ctx.Data["ExitDiagnostics"] = taskRes.TaskStatuses[0].ExitDiagnostics | |||||
oldStatus := task.Status | |||||
task.Status = taskRes.TaskStatuses[0].State | |||||
task.ContainerIp = "" | |||||
task.ContainerID = taskRes.TaskStatuses[0].ContainerID | |||||
models.ParseAndSetDurationFromCloudBrainOne(jobRes, task) | |||||
if task.DeletedAt.IsZero() { //normal record | |||||
if oldStatus != task.Status { | |||||
notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||||
} | |||||
err = models.UpdateJob(task) | |||||
if err != nil { | |||||
ctx.Data["error"] = err.Error() | |||||
return | |||||
} | |||||
} else { //deleted record | |||||
if result != nil { | |||||
jobRes, _ := models.ConvertToJobResultPayload(result.Payload) | |||||
taskRoles := jobRes.TaskRoles | |||||
taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | |||||
ctx.Data["taskRes"] = taskRes | |||||
ctx.Data["ExitDiagnostics"] = taskRes.TaskStatuses[0].ExitDiagnostics | |||||
oldStatus := task.Status | |||||
task.Status = taskRes.TaskStatuses[0].State | |||||
task.ContainerIp = "" | |||||
task.ContainerID = taskRes.TaskStatuses[0].ContainerID | |||||
models.ParseAndSetDurationFromCloudBrainOne(jobRes, task) | |||||
if task.DeletedAt.IsZero() { //normal record | |||||
if oldStatus != task.Status { | |||||
notification.NotifyChangeCloudbrainStatus(task, oldStatus) | |||||
} | |||||
err = models.UpdateJob(task) | |||||
if err != nil { | |||||
ctx.Data["error"] = err.Error() | |||||
return | |||||
} | } | ||||
} else { //deleted record | |||||
ctx.Data["result"] = jobRes | |||||
} else { | |||||
log.Info("error:" + err.Error()) | |||||
return | |||||
} | } | ||||
ctx.Data["result"] = jobRes | |||||
} else { | |||||
log.Info("error:" + err.Error()) | |||||
return | |||||
} | } | ||||
user, err := models.GetUserByID(task.UserID) | user, err := models.GetUserByID(task.UserID) | ||||
@@ -523,6 +523,7 @@ func ReferenceDatasetAvailable(ctx *context.Context) { | |||||
PublicOnly: true, | PublicOnly: true, | ||||
NeedAttachment: false, | NeedAttachment: false, | ||||
CloudBrainType: models.TypeCloudBrainAll, | CloudBrainType: models.TypeCloudBrainAll, | ||||
SearchOrderBy: models.SearchOrderByDefault, | |||||
} | } | ||||
dataset, _ := models.GetDatasetByRepo(&models.Repository{ID: ctx.Repo.Repository.ID}) | dataset, _ := models.GetDatasetByRepo(&models.Repository{ID: ctx.Repo.Repository.ID}) | ||||
if dataset != nil { | if dataset != nil { | ||||
@@ -538,6 +539,7 @@ func PublicDatasetMultiple(ctx *context.Context) { | |||||
PublicOnly: true, | PublicOnly: true, | ||||
NeedAttachment: true, | NeedAttachment: true, | ||||
CloudBrainType: ctx.QueryInt("type"), | CloudBrainType: ctx.QueryInt("type"), | ||||
SearchOrderBy: models.SearchOrderByDefault, | |||||
} | } | ||||
datasetMultiple(ctx, opts) | datasetMultiple(ctx, opts) | ||||
@@ -37,6 +37,7 @@ import ( | |||||
"code.gitea.io/gitea/modules/context" | "code.gitea.io/gitea/modules/context" | ||||
"code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
"code.gitea.io/gitea/modules/setting" | "code.gitea.io/gitea/modules/setting" | ||||
cloudbrainService "code.gitea.io/gitea/services/cloudbrain" | |||||
) | ) | ||||
const ( | const ( | ||||
@@ -915,10 +916,7 @@ func GrampusTrainJobShow(ctx *context.Context) { | |||||
ctx.Data["canDownload"] = cloudbrain.CanModifyJob(ctx, task) | ctx.Data["canDownload"] = cloudbrain.CanModifyJob(ctx, task) | ||||
ctx.Data["displayJobName"] = task.DisplayJobName | ctx.Data["displayJobName"] = task.DisplayJobName | ||||
aiCenterInfo := strings.Split(task.AiCenter, "+") | |||||
if len(aiCenterInfo) == 2 { | |||||
ctx.Data["ai_center"] = aiCenterInfo[1] | |||||
} | |||||
ctx.Data["ai_center"] = cloudbrainService.GetAiCenterShow(task.AiCenter,ctx) | |||||
ctx.HTML(http.StatusOK, tplGrampusTrainJobShow) | ctx.HTML(http.StatusOK, tplGrampusTrainJobShow) | ||||
} | } | ||||
@@ -0,0 +1,33 @@ | |||||
package cloudbrain | |||||
import ( | |||||
"code.gitea.io/gitea/modules/context" | |||||
"code.gitea.io/gitea/modules/setting" | |||||
"strings" | |||||
) | |||||
func GetAiCenterShow(aiCenter string,ctx *context.Context) string{ | |||||
aiCenterInfo := strings.Split(aiCenter, "+") | |||||
if len(aiCenterInfo) == 2{ | |||||
if setting.C2NetMapInfo!=nil { | |||||
if info,ok:=setting.C2NetMapInfo[aiCenterInfo[0]];ok { | |||||
if ctx.Language() == "zh-CN" { | |||||
return info.Content | |||||
} else { | |||||
return info.ContentEN | |||||
} | |||||
}else{ | |||||
return aiCenterInfo[1] | |||||
} | |||||
}else{ | |||||
return aiCenterInfo[1] | |||||
} | |||||
} | |||||
return "" | |||||
} |
@@ -55,7 +55,7 @@ | |||||
if (!this.dom) return; | if (!this.dom) return; | ||||
var self = this; | var self = this; | ||||
var clientX = 0, oLeft = 0, imgHideTimer = null; | var clientX = 0, oLeft = 0, imgHideTimer = null; | ||||
this.dom.find('.slide-bar-bg').on('mouseenter', function (e) { | |||||
this.dom.find('.slide-bar-bg').on('mouseenter touchstart', function (e) { | |||||
if (self.verifySucess) return; | if (self.verifySucess) return; | ||||
imgHideTimer && clearTimeout(imgHideTimer); | imgHideTimer && clearTimeout(imgHideTimer); | ||||
self.dom.find('.slide-image-big').slideDown(); | self.dom.find('.slide-image-big').slideDown(); | ||||