diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index c6c5703b3..36f220cef 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -880,7 +880,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/cloudbrain", func() { // m.Get("/:jobid", repo.GetCloudbrainTask) m.Get("/:jobname", repo.GetCloudbrainTask) - m.Get("/:jobid/log", repo.CloudbrainGetLog) + m.Get("/:jobname/log", repo.CloudbrainGetLog) }, reqRepoReader(models.UnitTypeCloudBrain)) m.Group("/modelarts", func() { m.Group("/notebook", func() { diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index 35044a894..6a2538048 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -93,8 +93,8 @@ func GetCloudbrainTask(ctx *context.APIContext) { } func CloudbrainGetLog(ctx *context.Context) { - jobID := ctx.Params(":jobid") - _, err := models.GetCloudbrainByJobID(jobID) + jobName := ctx.Params(":jobname") + job, err := models.GetCloudbrainByName(jobName) if err != nil { log.Error("GetCloudbrainByJobID failed: %v", err, ctx.Data["MsgID"]) ctx.ServerError(err.Error(), err) @@ -102,7 +102,7 @@ func CloudbrainGetLog(ctx *context.Context) { } var hits []models.Hits - result, err := cloudbrain.GetJobLog(jobID) + result, err := cloudbrain.GetJobLog(job.JobID) if err != nil { log.Error("GetJobLog failed: %v", err, ctx.Data["MsgID"]) ctx.ServerError(err.Error(), err) @@ -141,7 +141,7 @@ func CloudbrainGetLog(ctx *context.Context) { } ctx.JSON(http.StatusOK, map[string]interface{}{ - "JobID": jobID, + "JobName": jobName, "Content": content, }) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index de355352f..55b24e97a 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -992,8 +992,11 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/benchmark", func() { m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchmarkIndex) - m.Group("/:jobid", func() { + m.Group("/:jobname", func() { m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchMarkShow) + }) + m.Group("/:jobid", func() { + // m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchMarkShow) m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainStop) m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.BenchmarkDel) m.Get("/rate", reqRepoCloudBrainReader, repo.GetRate) diff --git a/templates/repo/cloudbrain/benchmark/index.tmpl b/templates/repo/cloudbrain/benchmark/index.tmpl index ef81199fe..a08d688c6 100644 --- a/templates/repo/cloudbrain/benchmark/index.tmpl +++ b/templates/repo/cloudbrain/benchmark/index.tmpl @@ -99,14 +99,14 @@
- + {{.JobName}}
- + {{.Status}}
@@ -274,7 +274,7 @@ $(document).ready(loadJobStatus); function loadJobStatus() { $(".job-status").each((index, job) => { - const jobID = job.dataset.jobid; + const jobName = job.dataset.jobname; const repoPath = job.dataset.repopath; const computeResource = job.dataset.resource const initArray = ['STOPPED','FAILED','START_FAILED','CREATE_FAILED','SUCCEEDED'] @@ -283,38 +283,40 @@ return } const diffResource = computeResource == "NPU" ? 'modelarts/notebook' : 'cloudbrain' - $.get(`/api/v1/repos/${repoPath}/${diffResource}/${jobID}`, (data) => { + const diffApi = computeResource == "NPU" ? jobID : jobName + $.get(`/api/v1/repos/${repoPath}/${diffResource}/${diffApi}`, (data) => { const jobID = data.JobID + const jobName = data.JobName const status = data.JobStatus if (status != job.textContent.trim()) { - $('#' + jobID+'-icon').removeClass().addClass(status) - $('#' + jobID+ '-text').text(status) + $('#' + jobName+'-icon').removeClass().addClass(status) + $('#' + jobName+ '-text').text(status) } if(status==="RUNNING"){ - $('#model-debug-'+jobID).removeClass('disabled').addClass('blue').text('调试').css("margin","0 1rem") - $('#model-image-'+jobID).removeClass('disabled').addClass('blue') + $('#model-debug-'+jobName).removeClass('disabled').addClass('blue').text('调试').css("margin","0 1rem") + $('#model-image-'+jobName).removeClass('disabled').addClass('blue') } if(status!=="RUNNING"){ // $('#model-debug-'+jobID).removeClass('blue') // $('#model-debug-'+jobID).addClass('disabled') - $('#model-image-'+jobID).removeClass('blue').addClass('disabled') + $('#model-image-'+jobName).removeClass('blue').addClass('disabled') } if(["CREATING","STOPPING","WAITING","STARTING"].includes(status)){ - $('#model-debug-'+jobID).removeClass('blue').addClass('disabled') + $('#model-debug-'+jobName).removeClass('blue').addClass('disabled') } if(['STOPPED','FAILED','START_FAILED','CREATE_FAILED','SUCCEEDED'].includes(status)){ - $('#model-debug-'+jobID).removeClass('disabled').addClass('blue').text('再次调试').css("margin","0") + $('#model-debug-'+jobName).removeClass('disabled').addClass('blue').text('再次调试').css("margin","0") } if(["RUNNING","WAITING"].includes(status)){ - $('#stop-model-debug-'+jobID).removeClass('disabled').addClass('blue') + $('#stop-model-debug-'+jobName).removeClass('disabled').addClass('blue') } if(["CREATING","STOPPING","STARTING","STOPPED","FAILED","START_FAILED","SUCCEEDED"].includes(status)){ - $('#stop-model-debug-'+jobID).removeClass('blue').addClass('disabled') + $('#stop-model-debug-'+jobName).removeClass('blue').addClass('disabled') } if(status==="STOPPED" || status==="FAILED"|| status==="START_FAILED"){ - $('#model-delete-'+jobID).removeClass('disabled').addClass('blue') + $('#model-delete-'+jobName).removeClass('disabled').addClass('blue') }else{ - $('#model-delete-'+jobID).removeClass('blue').addClass('disabled') + $('#model-delete-'+jobName).removeClass('blue').addClass('disabled') } }).fail(function(err) { console.log(err); diff --git a/templates/repo/cloudbrain/benchmark/show.tmpl b/templates/repo/cloudbrain/benchmark/show.tmpl index 99fd35de2..10453b446 100755 --- a/templates/repo/cloudbrain/benchmark/show.tmpl +++ b/templates/repo/cloudbrain/benchmark/show.tmpl @@ -432,19 +432,19 @@ td, th { let userName let repoPath - let jobID + let jobName $(document).ready(function(){ let url = window.location.href; let urlArr = url.split('/') userName = urlArr.slice(-5)[0] repoPath = urlArr.slice(-4)[0] - jobID = urlArr.slice(-1)[0] + jobName = urlArr.slice(-1)[0] }) function loadLog(version_name){ document.getElementById("mask").style.display = "block" - $.get(`/api/v1/repos/${userName}/${repoPath}/cloudbrain/${jobID}/log?version_name=${version_name}&lines=50&order=asc`, (data) => { + $.get(`/api/v1/repos/${userName}/${repoPath}/cloudbrain/${jobName}/log?version_name=${version_name}&lines=50&order=asc`, (data) => { $('input[name=end_line]').val(data.EndLine) $('input[name=start_line]').val(data.StartLine) $(`#log_file${version_name}`).text(data.Content)