Browse Source

Merge pull request 'fix-1515' (#1517) from fix-1515 into V20220228

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/1517
Reviewed-by: lewis <747342561@qq.com>
pull/1526/head
lewis 3 years ago
parent
commit
4f18981ce1
5 changed files with 29 additions and 24 deletions
  1. +1
    -1
      routers/api/v1/api.go
  2. +4
    -4
      routers/api/v1/repo/cloudbrain.go
  3. +4
    -1
      routers/routes/routes.go
  4. +17
    -15
      templates/repo/cloudbrain/benchmark/index.tmpl
  5. +3
    -3
      templates/repo/cloudbrain/benchmark/show.tmpl

+ 1
- 1
routers/api/v1/api.go View File

@@ -880,7 +880,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/cloudbrain", func() { m.Group("/cloudbrain", func() {
// m.Get("/:jobid", repo.GetCloudbrainTask) // m.Get("/:jobid", repo.GetCloudbrainTask)
m.Get("/:jobname", repo.GetCloudbrainTask) m.Get("/:jobname", repo.GetCloudbrainTask)
m.Get("/:jobid/log", repo.CloudbrainGetLog)
m.Get("/:jobname/log", repo.CloudbrainGetLog)
}, reqRepoReader(models.UnitTypeCloudBrain)) }, reqRepoReader(models.UnitTypeCloudBrain))
m.Group("/modelarts", func() { m.Group("/modelarts", func() {
m.Group("/notebook", func() { m.Group("/notebook", func() {


+ 4
- 4
routers/api/v1/repo/cloudbrain.go View File

@@ -93,8 +93,8 @@ func GetCloudbrainTask(ctx *context.APIContext) {
} }


func CloudbrainGetLog(ctx *context.Context) { 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 { if err != nil {
log.Error("GetCloudbrainByJobID failed: %v", err, ctx.Data["MsgID"]) log.Error("GetCloudbrainByJobID failed: %v", err, ctx.Data["MsgID"])
ctx.ServerError(err.Error(), err) ctx.ServerError(err.Error(), err)
@@ -102,7 +102,7 @@ func CloudbrainGetLog(ctx *context.Context) {
} }


var hits []models.Hits var hits []models.Hits
result, err := cloudbrain.GetJobLog(jobID)
result, err := cloudbrain.GetJobLog(job.JobID)
if err != nil { if err != nil {
log.Error("GetJobLog failed: %v", err, ctx.Data["MsgID"]) log.Error("GetJobLog failed: %v", err, ctx.Data["MsgID"])
ctx.ServerError(err.Error(), err) ctx.ServerError(err.Error(), err)
@@ -141,7 +141,7 @@ func CloudbrainGetLog(ctx *context.Context) {
} }


ctx.JSON(http.StatusOK, map[string]interface{}{ ctx.JSON(http.StatusOK, map[string]interface{}{
"JobID": jobID,
"JobName": jobName,
"Content": content, "Content": content,
}) })




+ 4
- 1
routers/routes/routes.go View File

@@ -992,8 +992,11 @@ func RegisterRoutes(m *macaron.Macaron) {


m.Group("/benchmark", func() { m.Group("/benchmark", func() {
m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchmarkIndex) m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchmarkIndex)
m.Group("/:jobid", func() {
m.Group("/:jobname", func() {
m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchMarkShow) m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchMarkShow)
})
m.Group("/:jobid", func() {
// m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchMarkShow)
m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainStop) m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainStop)
m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.BenchmarkDel) m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.BenchmarkDel)
m.Get("/rate", reqRepoCloudBrainReader, repo.GetRate) m.Get("/rate", reqRepoCloudBrainReader, repo.GetRate)


+ 17
- 15
templates/repo/cloudbrain/benchmark/index.tmpl View File

@@ -99,14 +99,14 @@
<!-- 任务名 --> <!-- 任务名 -->
<div class="three wide column padding0"> <div class="three wide column padding0">
<a class="title" href="{{$.Link}}/{{.JobID}}" title="{{.JobName}}" style="font-size: 14px;">
<a class="title" href="{{$.Link}}/{{.JobName}}" title="{{.JobName}}" style="font-size: 14px;">
<span class="fitted" style="width: 90%;vertical-align: middle;">{{.JobName}}</span> <span class="fitted" style="width: 90%;vertical-align: middle;">{{.JobName}}</span>
</a> </a>
</div> </div>
<!-- 任务状态 --> <!-- 任务状态 -->
<div class="two wide column padding0" style="padding-left: 2.2rem !important;"> <div class="two wide column padding0" style="padding-left: 2.2rem !important;">
<span class="job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}" data-version="{{.VersionName}}">
<span class="job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}" data-version="{{.VersionName}}" data-jobname="{{.JobName}}">
<span><i id="{{.JobID}}-icon" style="vertical-align: middle;" class="{{.Status}}"></i><span id="{{.JobID}}-text" style="margin-left: 0.4em;font-size: 12px;">{{.Status}}</span></span> <span><i id="{{.JobID}}-icon" style="vertical-align: middle;" class="{{.Status}}"></i><span id="{{.JobID}}-text" style="margin-left: 0.4em;font-size: 12px;">{{.Status}}</span></span>
</span> </span>
</div> </div>
@@ -274,7 +274,7 @@
$(document).ready(loadJobStatus); $(document).ready(loadJobStatus);
function loadJobStatus() { function loadJobStatus() {
$(".job-status").each((index, job) => { $(".job-status").each((index, job) => {
const jobID = job.dataset.jobid;
const jobName = job.dataset.jobname;
const repoPath = job.dataset.repopath; const repoPath = job.dataset.repopath;
const computeResource = job.dataset.resource const computeResource = job.dataset.resource
const initArray = ['STOPPED','FAILED','START_FAILED','CREATE_FAILED','SUCCEEDED'] const initArray = ['STOPPED','FAILED','START_FAILED','CREATE_FAILED','SUCCEEDED']
@@ -283,38 +283,40 @@
return return
} }
const diffResource = computeResource == "NPU" ? 'modelarts/notebook' : 'cloudbrain' 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 jobID = data.JobID
const jobName = data.JobName
const status = data.JobStatus const status = data.JobStatus
if (status != job.textContent.trim()) { 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"){ 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"){ if(status!=="RUNNING"){
// $('#model-debug-'+jobID).removeClass('blue') // $('#model-debug-'+jobID).removeClass('blue')
// $('#model-debug-'+jobID).addClass('disabled') // $('#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)){ 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)){ 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)){ 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)){ 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"){ if(status==="STOPPED" || status==="FAILED"|| status==="START_FAILED"){
$('#model-delete-'+jobID).removeClass('disabled').addClass('blue')
$('#model-delete-'+jobName).removeClass('disabled').addClass('blue')
}else{ }else{
$('#model-delete-'+jobID).removeClass('blue').addClass('disabled')
$('#model-delete-'+jobName).removeClass('blue').addClass('disabled')
} }
}).fail(function(err) { }).fail(function(err) {
console.log(err); console.log(err);


+ 3
- 3
templates/repo/cloudbrain/benchmark/show.tmpl View File

@@ -432,19 +432,19 @@ td, th {
let userName let userName
let repoPath let repoPath
let jobID
let jobName
$(document).ready(function(){ $(document).ready(function(){
let url = window.location.href; let url = window.location.href;
let urlArr = url.split('/') let urlArr = url.split('/')
userName = urlArr.slice(-5)[0] userName = urlArr.slice(-5)[0]
repoPath = urlArr.slice(-4)[0] repoPath = urlArr.slice(-4)[0]
jobID = urlArr.slice(-1)[0]
jobName = urlArr.slice(-1)[0]
}) })




function loadLog(version_name){ function loadLog(version_name){
document.getElementById("mask").style.display = "block" 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=end_line]').val(data.EndLine)
$('input[name=start_line]').val(data.StartLine) $('input[name=start_line]').val(data.StartLine)
$(`#log_file${version_name}`).text(data.Content) $(`#log_file${version_name}`).text(data.Content)


Loading…
Cancel
Save