@@ -125,6 +125,8 @@ type TaskPod struct { | |||
ExitCode int `json:"exitCode"` | |||
ExitDiagnostics string `json:"exitDiagnostics"` | |||
RetriedCount int `json:"retriedCount"` | |||
StartTime string | |||
FinishedTime string | |||
} `json:"taskStatuses"` | |||
} | |||
@@ -132,6 +134,8 @@ func ConvertToTaskPod(input map[string]interface{}) (TaskPod, error) { | |||
data, _ := json.Marshal(input) | |||
var taskPod TaskPod | |||
err := json.Unmarshal(data, &taskPod) | |||
taskPod.TaskStatuses[0].StartTime = time.Unix(taskPod.TaskStatuses[0].StartAt.Unix() + 8*3600, 0).UTC().Format("2006-01-02 15:04:05") | |||
taskPod.TaskStatuses[0].FinishedTime = time.Unix(taskPod.TaskStatuses[0].FinishedAt.Unix() + 8*3600, 0).UTC().Format("2006-01-02 15:04:05") | |||
return taskPod, err | |||
} | |||
@@ -156,6 +160,8 @@ type JobResultPayload struct { | |||
AppExitDiagnostics string `json:"appExitDiagnostics"` | |||
AppExitType interface{} `json:"appExitType"` | |||
VirtualCluster string `json:"virtualCluster"` | |||
StartTime string | |||
EndTime string | |||
} `json:"jobStatus"` | |||
TaskRoles map[string]interface{} `json:"taskRoles"` | |||
Resource struct { | |||
@@ -194,6 +200,8 @@ func ConvertToJobResultPayload(input map[string]interface{}) (JobResultPayload, | |||
data, _ := json.Marshal(input) | |||
var jobResultPayload JobResultPayload | |||
err := json.Unmarshal(data, &jobResultPayload) | |||
jobResultPayload.JobStatus.StartTime = time.Unix(jobResultPayload.JobStatus.CreatedTime/1000, 0).Format("2006-01-02 15:04:05") | |||
jobResultPayload.JobStatus.EndTime = time.Unix(jobResultPayload.JobStatus.CompletedTime/1000, 0).Format("2006-01-02 15:04:05") | |||
return jobResultPayload, err | |||
} | |||
@@ -17,10 +17,7 @@ const ( | |||
SubTaskName = "task1" | |||
DebugGPUType = "debug" | |||
Success = "S000" | |||
) | |||
func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath string) error { | |||
@@ -32,7 +29,7 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, | |||
jobResult, err := CreateJob(jobName, models.CreateJobParams{ | |||
JobName: jobName, | |||
RetryCount: 1, | |||
GpuType: DebugGPUType, | |||
GpuType: setting.JobType, | |||
Image: image, | |||
TaskRoles: []models.TaskRole{ | |||
{ | |||
@@ -14,6 +14,6 @@ func GetCloudbrainConfig() CloudbrainLoginConfig { | |||
cloudbrainSec := Cfg.Section("cloudbrain") | |||
Cloudbrain.Username = cloudbrainSec.Key("USERNAME").MustString("") | |||
Cloudbrain.Password = cloudbrainSec.Key("PASSWORD").MustString("") | |||
Cloudbrain.Host = cloudbrainSec.Key("HOST").MustString("") | |||
Cloudbrain.Host = cloudbrainSec.Key("REST_SERVER_HOST").MustString("") | |||
return Cloudbrain | |||
} |
@@ -434,13 +434,10 @@ var ( | |||
//cloudbrain config | |||
CBAuthUser string | |||
CBAuthPassword string | |||
ClientID string | |||
ClientSecret string | |||
UserCeterHost string | |||
RestServerHost string | |||
JobPath string | |||
JobType string | |||
DebugServerHost string | |||
ImageServerHost string | |||
) | |||
// DateLang transforms standard language locale name to corresponding value in datetime plugin. | |||
@@ -1112,13 +1109,10 @@ func NewContext() { | |||
sec = Cfg.Section("cloudbrain") | |||
CBAuthUser = sec.Key("USER").MustString("cW4cMtH24eoWPE7X") | |||
CBAuthPassword = sec.Key("PWD").MustString("4BPmgvK2hb2Eywwyp4YZRY4B7yQf4DAC") | |||
ClientID = sec.Key("CLIENT_ID").MustString("3Z377wcplxeE2qpycpjv") | |||
ClientSecret = sec.Key("CLIENT_SECRET").MustString("J5ykfVl2kcxW0H9cawSL") | |||
UserCeterHost = sec.Key("USER_CENTER_HOST").MustString("http://192.168.202.73:31441") | |||
RestServerHost = sec.Key("REST_SERVER_HOST").MustString("http://192.168.202.73") | |||
JobPath = sec.Key("JOB_PATH").MustString("/datasets/minio/data/opendata/jobs/") | |||
DebugServerHost = sec.Key("DEBUG_SERVER_HOST").MustString("http://192.168.202.73") | |||
ImageServerHost = sec.Key("IMAGE_SERVER_HOST").MustString("http://192.168.202.73") | |||
JobType = sec.Key("JOB_TYPE").MustString("debug_openi") | |||
} | |||
func loadInternalToken(sec *ini.Section) string { | |||
@@ -6,6 +6,7 @@ | |||
package repo | |||
import ( | |||
"code.gitea.io/gitea/modules/log" | |||
"net/http" | |||
"time" | |||
@@ -48,7 +49,7 @@ func GetCloudbrainTask(ctx *context.APIContext) { | |||
jobID := ctx.Params(":jobid") | |||
repoID := ctx.Repo.Repository.ID | |||
_, err = models.GetRepoCloudBrainByJobID(repoID, jobID) | |||
job, err := models.GetRepoCloudBrainByJobID(repoID, jobID) | |||
if err != nil { | |||
ctx.NotFound(err) | |||
return | |||
@@ -64,10 +65,18 @@ func GetCloudbrainTask(ctx *context.APIContext) { | |||
return | |||
} | |||
if result.JobStatus.State != string(models.JobWaiting) { | |||
//todo | |||
taskRoles := result.TaskRoles | |||
taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | |||
job.ContainerIp = taskRes.TaskStatuses[0].ContainerIP | |||
job.ContainerID = taskRes.TaskStatuses[0].ContainerID | |||
job.Status = taskRes.TaskStatuses[0].State | |||
go models.SetCloudbrainStatusByJobID(result.Config.JobID, models.CloudbrainStatus(result.JobStatus.State)) | |||
if result.JobStatus.State != string(models.JobWaiting) { | |||
err = models.UpdateJob(job) | |||
if err != nil { | |||
log.Error("UpdateJob failed:", err) | |||
} | |||
} | |||
ctx.JSON(http.StatusOK, map[string]interface{}{ | |||
@@ -150,7 +150,6 @@ func CloudBrainShow(ctx *context.Context) { | |||
if err != nil { | |||
ctx.Data["error"] = err.Error() | |||
} | |||
ctx.Data["task"] = task | |||
result, err := cloudbrain.GetJob(jobID) | |||
if err != nil { | |||
@@ -161,7 +160,7 @@ func CloudBrainShow(ctx *context.Context) { | |||
jobRes, _ := models.ConvertToJobResultPayload(result.Payload) | |||
ctx.Data["result"] = jobRes | |||
taskRoles := jobRes.TaskRoles | |||
taskRes, _ := models.ConvertToTaskPod(taskRoles["task1"].(map[string]interface{})) | |||
taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | |||
ctx.Data["taskRes"] = taskRes | |||
task.Status = taskRes.TaskStatuses[0].State | |||
task.ContainerID = taskRes.TaskStatuses[0].ContainerID | |||
@@ -172,6 +171,7 @@ func CloudBrainShow(ctx *context.Context) { | |||
} | |||
} | |||
ctx.Data["task"] = task | |||
ctx.Data["jobID"] = jobID | |||
ctx.HTML(200, tplCloudBrainShow) | |||
} | |||
@@ -83,14 +83,14 @@ | |||
<div class="ui divider"></div> | |||
<div class="inline required field dis"> | |||
<label>镜像标签:</label> | |||
<input name="tag" id="image_tag" tabindex="3" autofocus required maxlength="255" style="width:300px"> | |||
<input name="tag" id="image_tag" tabindex="3" autofocus required maxlength="255" style="width:75%"> | |||
</div> | |||
<div class="inline required field" style="position:relative;height:200px;"> | |||
<div class="inline required field" style="position:relative;height:180px;"> | |||
<div style="height:20px;width:75px;"> | |||
<label>镜像描述:</label> | |||
</div> | |||
<div style="position:absolute;left:75px;top:0"> | |||
<textarea name="description" rows="10" style="width:300px"></textarea> | |||
<div style="position:absolute;left:75px;top:0;width:75%"> | |||
<textarea name="description" rows="10" style="width:100%"></textarea> | |||
</div> | |||
</div> | |||
<div class="ui divider"></div> | |||
@@ -99,12 +99,9 @@ | |||
<button class="ui green button"> | |||
{{$.i18n.Tr "repo.cloudbrain.commit_image"}} | |||
</button> | |||
<!--<a class="ui button" href="/">{{$.i18n.Tr "repo.cloudbrain.cancel"}}</a>--> | |||
</div> | |||
</form> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
@@ -122,7 +119,7 @@ $( document ).ready(function() { | |||
$( ".job-status" ).each(( index, job ) => { | |||
const jobID = job.dataset.jobid; | |||
const repoPath = job.dataset.repopath; | |||
if (job.textContent.trim() != 'WAITING') { | |||
if (job.textContent.trim() == 'STOPPED') { | |||
return | |||
} | |||
@@ -25,7 +25,7 @@ | |||
</select> | |||
</div> | |||
<div class="inline required field"> | |||
<label>数据集</label> | |||
<label>数据集(只有zip格式的数据集才能发起云脑任务)</label> | |||
<select id="cloudbrain_dataset" placeholder="选择数据集" style='width:385px' name="attachment"> | |||
{{range .attachments}} | |||
<option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option> | |||
@@ -26,11 +26,11 @@ | |||
</tr> | |||
<tr> | |||
<td> 开始时间 </td> | |||
<td>{{.StartAt}}</td> | |||
<td>{{.StartTime}}</td> | |||
</tr> | |||
<tr> | |||
<td> 结束时间 </td> | |||
<td>{{.FinishedAt}}</td> | |||
<td>{{.FinishedTime}}</td> | |||
</tr> | |||
<tr> | |||
<td> ExitCode </td> | |||
@@ -78,11 +78,11 @@ | |||
</tr> | |||
<tr> | |||
<td> 开始时间 </td> | |||
<td>{{.JobStatus.CreatedTime}}</td> | |||
<td>{{.JobStatus.StartTime}}</td> | |||
</tr> | |||
<tr> | |||
<td> 结束时间 </td> | |||
<td>{{.JobStatus.CompletedTime}}</td> | |||
<td>{{.JobStatus.EndTime}}</td> | |||
</tr> | |||
<tr> | |||
<td> ExitCode </td> | |||