| @@ -361,7 +361,7 @@ func RestartTask(ctx *context.Context, task *models.Cloudbrain, newJobID *string | |||||
| return err | return err | ||||
| } | } | ||||
| *newJobID = task.JobID | |||||
| *newJobID = jobID | |||||
| return nil | return nil | ||||
| } | } | ||||
| @@ -880,13 +880,13 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| }, reqAdmin()) | }, reqAdmin()) | ||||
| }, reqAnyRepoReader()) | }, reqAnyRepoReader()) | ||||
| m.Group("/cloudbrain", func() { | m.Group("/cloudbrain", func() { | ||||
| m.Get("/:jobid", repo.GetCloudbrainTask) | |||||
| m.Get("/:jobid/log", repo.CloudbrainGetLog) | |||||
| m.Get("/:id", repo.GetCloudbrainTask) | |||||
| m.Get("/:id/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() { | ||||
| //m.Get("/:jobid", repo.GetModelArtsNotebook) | //m.Get("/:jobid", repo.GetModelArtsNotebook) | ||||
| m.Get("/:jobid", repo.GetModelArtsNotebook2) | |||||
| m.Get("/:id", repo.GetModelArtsNotebook2) | |||||
| }) | }) | ||||
| m.Group("/train-job", func() { | m.Group("/train-job", func() { | ||||
| m.Group("/:jobid", func() { | m.Group("/:jobid", func() { | ||||
| @@ -51,14 +51,13 @@ func GetCloudbrainTask(ctx *context.APIContext) { | |||||
| // jobName := ctx.Params(":jobname") | // jobName := ctx.Params(":jobname") | ||||
| // job, err := models.GetCloudbrainByName(jobName) | // job, err := models.GetCloudbrainByName(jobName) | ||||
| jobID := ctx.Params(":jobid") | |||||
| repoID := ctx.Repo.Repository.ID | |||||
| job, err := models.GetRepoCloudBrainByJobID(repoID, jobID) | |||||
| ID := ctx.Params(":id") | |||||
| // repoID := ctx.Repo.Repository.ID | |||||
| job, err := models.GetCloudbrainByID(ID) | |||||
| if err != nil { | if err != nil { | ||||
| ctx.Data["error"] = err.Error() | ctx.Data["error"] = err.Error() | ||||
| } | } | ||||
| // jobResult, err := cloudbrain.GetJob(job.JobID) | |||||
| jobResult, err := cloudbrain.GetJob(jobID) | |||||
| jobResult, err := cloudbrain.GetJob(job.JobID) | |||||
| if err != nil { | if err != nil { | ||||
| ctx.NotFound(err) | ctx.NotFound(err) | ||||
| return | return | ||||
| @@ -87,7 +86,7 @@ func GetCloudbrainTask(ctx *context.APIContext) { | |||||
| } | } | ||||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | ctx.JSON(http.StatusOK, map[string]interface{}{ | ||||
| "JobID": jobID, | |||||
| "ID": ID, | |||||
| "JobName": result.Config.JobName, | "JobName": result.Config.JobName, | ||||
| "JobStatus": result.JobStatus.State, | "JobStatus": result.JobStatus.State, | ||||
| "SubState": result.JobStatus.SubState, | "SubState": result.JobStatus.SubState, | ||||
| @@ -98,8 +97,8 @@ func GetCloudbrainTask(ctx *context.APIContext) { | |||||
| } | } | ||||
| func CloudbrainGetLog(ctx *context.Context) { | func CloudbrainGetLog(ctx *context.Context) { | ||||
| jobID := ctx.Params(":jobid") | |||||
| job, err := models.GetCloudbrainByJobID(jobID) | |||||
| ID := ctx.Params(":id") | |||||
| job, err := models.GetCloudbrainByID(ID) | |||||
| if err != nil { | if err != nil { | ||||
| log.Error("GetCloudbrainByJobName failed: %v", err, ctx.Data["MsgID"]) | log.Error("GetCloudbrainByJobName failed: %v", err, ctx.Data["MsgID"]) | ||||
| ctx.ServerError(err.Error(), err) | ctx.ServerError(err.Error(), err) | ||||
| @@ -107,7 +106,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) | ||||
| @@ -56,14 +56,13 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { | |||||
| err error | err error | ||||
| ) | ) | ||||
| jobID := ctx.Params(":jobid") | |||||
| repoID := ctx.Repo.Repository.ID | |||||
| job, err := models.GetRepoCloudBrainByJobID(repoID, jobID) | |||||
| ID := ctx.Params(":id") | |||||
| job, err := models.GetCloudbrainByID(ID) | |||||
| if err != nil { | if err != nil { | ||||
| ctx.NotFound(err) | ctx.NotFound(err) | ||||
| return | return | ||||
| } | } | ||||
| result, err := modelarts.GetNotebook2(jobID) | |||||
| result, err := modelarts.GetNotebook2(job.JobID) | |||||
| if err != nil { | if err != nil { | ||||
| ctx.NotFound(err) | ctx.NotFound(err) | ||||
| return | return | ||||
| @@ -76,7 +75,7 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { | |||||
| } | } | ||||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | ctx.JSON(http.StatusOK, map[string]interface{}{ | ||||
| "JobID": jobID, | |||||
| "ID": ID, | |||||
| "JobName": job.JobName, | "JobName": job.JobName, | ||||
| "JobStatus": result.Status, | "JobStatus": result.Status, | ||||
| }) | }) | ||||
| @@ -283,8 +283,10 @@ func CloudBrainRestart(ctx *context.Context) { | |||||
| var resultCode = "0" | var resultCode = "0" | ||||
| var errorMsg = "" | var errorMsg = "" | ||||
| var status = string(models.JobWaiting) | var status = string(models.JobWaiting) | ||||
| task := ctx.Cloudbrain | |||||
| task, err := models.GetCloudbrainByID(ID) | |||||
| if err != nil { | |||||
| ctx.Data["error"] = err.Error() | |||||
| } | |||||
| for { | for { | ||||
| if task.Status != string(models.JobStopped) && task.Status != string(models.JobSucceeded) && task.Status != string(models.JobFailed) { | if task.Status != string(models.JobStopped) && task.Status != string(models.JobSucceeded) && task.Status != string(models.JobFailed) { | ||||
| log.Error("the job(%s) is not stopped", task.JobName, ctx.Data["MsgID"]) | log.Error("the job(%s) is not stopped", task.JobName, ctx.Data["MsgID"]) | ||||
| @@ -469,7 +471,12 @@ func CloudBrainStop(ctx *context.Context) { | |||||
| var errorMsg = "" | var errorMsg = "" | ||||
| var status = "" | var status = "" | ||||
| task := ctx.Cloudbrain | |||||
| task, err := models.GetCloudbrainByID(ID) | |||||
| if err != nil { | |||||
| ctx.Data["error"] = err.Error() | |||||
| } | |||||
| // task := ctx.Cloudbrain | |||||
| for { | for { | ||||
| if task.Status == string(models.JobStopped) || task.Status == string(models.JobFailed) || task.Status == string(models.JobSucceeded) { | if task.Status == string(models.JobStopped) || task.Status == string(models.JobFailed) || task.Status == string(models.JobSucceeded) { | ||||
| log.Error("the job(%s) has been stopped", task.JobName, ctx.Data["msgID"]) | log.Error("the job(%s) has been stopped", task.JobName, ctx.Data["msgID"]) | ||||
| @@ -479,6 +486,7 @@ func CloudBrainStop(ctx *context.Context) { | |||||
| } | } | ||||
| err := cloudbrain.StopJob(task.JobID) | err := cloudbrain.StopJob(task.JobID) | ||||
| // err := cloudbrain.StopJob("bbb60ea009a9b011ec08bb20f3128d160513") | |||||
| if err != nil { | if err != nil { | ||||
| log.Error("StopJob(%s) failed:%v", task.JobName, err, ctx.Data["msgID"]) | log.Error("StopJob(%s) failed:%v", task.JobName, err, ctx.Data["msgID"]) | ||||
| resultCode = "-1" | resultCode = "-1" | ||||
| @@ -330,14 +330,14 @@ func NotebookDebug2(ctx *context.Context) { | |||||
| } | } | ||||
| func NotebookManage(ctx *context.Context) { | func NotebookManage(ctx *context.Context) { | ||||
| var jobID = ctx.Params(":jobid") | |||||
| var ID = ctx.Params(":id") | |||||
| var action = ctx.Params(":action") | var action = ctx.Params(":action") | ||||
| var resultCode = "0" | var resultCode = "0" | ||||
| var errorMsg = "" | var errorMsg = "" | ||||
| var status = "" | var status = "" | ||||
| for { | for { | ||||
| task, err := models.GetCloudbrainByJobID(jobID) | |||||
| task, err := models.GetCloudbrainByID(ID) | |||||
| if err != nil { | if err != nil { | ||||
| log.Error("GetCloudbrainByJobID failed:%v", err, ctx.Data["MsgID"]) | log.Error("GetCloudbrainByJobID failed:%v", err, ctx.Data["MsgID"]) | ||||
| resultCode = "-1" | resultCode = "-1" | ||||
| @@ -404,7 +404,7 @@ func NotebookManage(ctx *context.Context) { | |||||
| param := models.NotebookAction{ | param := models.NotebookAction{ | ||||
| Action: action, | Action: action, | ||||
| } | } | ||||
| res, err := modelarts.ManageNotebook2(jobID, param) | |||||
| res, err := modelarts.ManageNotebook2(task.JobID, param) | |||||
| if err != nil { | if err != nil { | ||||
| log.Error("ManageNotebook2(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"]) | log.Error("ManageNotebook2(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"]) | ||||
| resultCode = "-1" | resultCode = "-1" | ||||
| @@ -433,7 +433,7 @@ func NotebookManage(ctx *context.Context) { | |||||
| "result_code": resultCode, | "result_code": resultCode, | ||||
| "error_msg": errorMsg, | "error_msg": errorMsg, | ||||
| "status": status, | "status": status, | ||||
| "job_id": jobID, | |||||
| "id": ID, | |||||
| }) | }) | ||||
| } | } | ||||
| @@ -287,14 +287,14 @@ | |||||
| <div class="row"> | <div class="row"> | ||||
| <!-- 任务名 --> | <!-- 任务名 --> | ||||
| <div class="four wide column"> | <div class="four wide column"> | ||||
| <a class="title" href='{{if eq .ComputeResource "CPU/GPU"}}{{$.RepoLink}}/cloudbrain/{{.JobID}}{{else}}{{$.RepoLink}}/modelarts/notebook/{{.JobID}}{{end}}' title="{{.JobName}}" style="font-size: 14px;"> | |||||
| <a class="title" href='{{if eq .ComputeResource "CPU/GPU"}}{{$.RepoLink}}/cloudbrain/{{.Cloudbrain.ID}}{{else}}{{$.RepoLink}}/modelarts/notebook/{{.Cloudbrain.ID}}{{end}}' title="{{.JobName}}" style="font-size: 14px;"> | |||||
| <span class="fitted text_over" style="width: 90%;vertical-align: middle;">{{.DisplayJobName}}</span> | <span class="fitted text_over" style="width: 90%;vertical-align: middle;">{{.DisplayJobName}}</span> | ||||
| </a> | </a> | ||||
| </div> | </div> | ||||
| <div class="two wide column text center"> | <div class="two wide column text center"> | ||||
| <!--任务状态 --> | <!--任务状态 --> | ||||
| <span class="job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}{{if eq .ComputeResource "CPU/GPU"}}/cloudbrain{{else}}/modelarts/notebook{{end}}" data-jobid="{{.JobID}}" data-resource="{{.ComputeResource}}"> | |||||
| <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 class="job-status" id="{{.Cloudbrain.ID}}" data-repopath="{{$.RepoRelPath}}{{if eq .ComputeResource "CPU/GPU"}}/cloudbrain{{else}}/modelarts/notebook{{end}}" data-jobid="{{.Cloudbrain.ID}}" data-resource="{{.ComputeResource}}"> | |||||
| <span><i id="{{.Cloudbrain.ID}}-icon" style="vertical-align: middle;" class="{{.Status}}"></i><span id="{{.Cloudbrain.ID}}-text" style="margin-left: 0.4em;font-size: 12px;">{{.Status}}</span></span> | |||||
| </span> | </span> | ||||
| </div> | </div> | ||||
| <div class="two wide column text center"> | <div class="two wide column text center"> | ||||
| @@ -315,20 +315,20 @@ | |||||
| <div class="five wide column text center"> | <div class="five wide column text center"> | ||||
| <div class="ui compact buttons"> | <div class="ui compact buttons"> | ||||
| <!-- {{if and (ne .Status "WAITING") (ne .JobType "DEBUG")}} | <!-- {{if and (ne .Status "WAITING") (ne .JobType "DEBUG")}} | ||||
| <a class="ui basic button" href="{{$.Link}}/{{.JobID}}/rate" target="_blank"> | |||||
| <a class="ui basic button" href="{{$.Link}}/{{.Cloudbrain.ID}}/rate" target="_blank"> | |||||
| 评分 | 评分 | ||||
| </a> | </a> | ||||
| {{end}} --> | {{end}} --> | ||||
| <!-- 调试 --> | <!-- 调试 --> | ||||
| <form id="debugAgainForm-{{.JobID}}"> | |||||
| <form id="debugAgainForm-{{.Cloudbrain.ID}}"> | |||||
| {{$.CsrfTokenHtml}} | {{$.CsrfTokenHtml}} | ||||
| {{if .CanDebug}} | {{if .CanDebug}} | ||||
| {{if eq .Status "RUNNING" "WAITING" "CREATING" "STARTING"}} | {{if eq .Status "RUNNING" "WAITING" "CREATING" "STARTING"}} | ||||
| <a style="margin: 0 1rem;" id="ai-debug-{{.JobID}}" class='ui basic ai_debug {{if eq .Status "CREATING" "STOPPING" "WAITING" "STARTING"}}disabled {{else}}blue {{end}}button' data-jobid="{{.JobID}}" data-repopath='{{$.RepoLink}}{{if eq .ComputeResource "CPU/GPU"}}/cloudbrain{{else}}/modelarts/notebook{{end}}/{{.JobID}}/'> | |||||
| <a style="margin: 0 1rem;" id="ai-debug-{{.Cloudbrain.ID}}" class='ui basic ai_debug {{if eq .Status "CREATING" "STOPPING" "WAITING" "STARTING"}}disabled {{else}}blue {{end}}button' data-jobid="{{.Cloudbrain.ID}}" data-repopath='{{$.RepoLink}}{{if eq .ComputeResource "CPU/GPU"}}/cloudbrain{{else}}/modelarts/notebook{{end}}/{{.Cloudbrain.ID}}/'> | |||||
| {{$.i18n.Tr "repo.debug"}} | {{$.i18n.Tr "repo.debug"}} | ||||
| </a> | </a> | ||||
| {{else}} | {{else}} | ||||
| <a id="ai-debug-{{.JobID}}" class='ui basic ai_debug {{if eq .Status "CREATING" "STOPPING" "WAITING" "STARTING"}} disabled {{else}}blue {{end}}button' data-jobid="{{.JobID}}" data-repopath='{{$.RepoLink}}{{if eq .ComputeResource "CPU/GPU"}}/cloudbrain{{else}}/modelarts/notebook{{end}}/{{.JobID}}/' data-linkpath='{{$.Link}}'> | |||||
| <a id="ai-debug-{{.Cloudbrain.ID}}" class='ui basic ai_debug {{if eq .Status "CREATING" "STOPPING" "WAITING" "STARTING"}} disabled {{else}}blue {{end}}button' data-jobid="{{.Cloudbrain.ID}}" data-repopath='{{$.RepoLink}}{{if eq .ComputeResource "CPU/GPU"}}/cloudbrain{{else}}/modelarts/notebook{{end}}/{{.Cloudbrain.ID}}/' data-linkpath='{{$.Link}}'> | |||||
| {{$.i18n.Tr "repo.debug_again"}} | {{$.i18n.Tr "repo.debug_again"}} | ||||
| </a> | </a> | ||||
| {{end}} | {{end}} | ||||
| @@ -346,10 +346,10 @@ | |||||
| </form> | </form> | ||||
| <!-- 停止 --> | <!-- 停止 --> | ||||
| <form id="stopForm-{{.JobID}}" style="margin-left:-1px;"> | |||||
| <form id="stopForm-{{.Cloudbrain.ID}}" style="margin-left:-1px;"> | |||||
| {{$.CsrfTokenHtml}} | {{$.CsrfTokenHtml}} | ||||
| {{if .CanDel}} | {{if .CanDel}} | ||||
| <a id="ai-stop-{{.JobID}}" class='ui basic ai_stop {{if eq .Status "STOPPED" "FAILED" "START_FAILED" "STOPPING" "CREATING" "STARTING" "SUCCEEDED"}}disabled {{else}}blue {{end}}button' data-repopath="{{$.RepoLink}}{{if eq .ComputeResource "CPU/GPU"}}/cloudbrain{{else}}/modelarts/notebook{{end}}/{{.JobID}}/stop" data-jobid="{{.JobID}}"> | |||||
| <a id="ai-stop-{{.Cloudbrain.ID}}" class='ui basic ai_stop {{if eq .Status "STOPPED" "FAILED" "START_FAILED" "STOPPING" "CREATING" "STARTING" "SUCCEEDED"}}disabled {{else}}blue {{end}}button' data-repopath="{{$.RepoLink}}{{if eq .ComputeResource "CPU/GPU"}}/cloudbrain{{else}}/modelarts/notebook{{end}}/{{.Cloudbrain.ID}}/stop" data-jobid="{{.Cloudbrain.ID}}"> | |||||
| {{$.i18n.Tr "repo.stop"}} | {{$.i18n.Tr "repo.stop"}} | ||||
| </a> | </a> | ||||
| {{else}} | {{else}} | ||||
| @@ -359,11 +359,11 @@ | |||||
| {{end}} | {{end}} | ||||
| </form> | </form> | ||||
| <!-- 删除 --> | <!-- 删除 --> | ||||
| <form id="delForm-{{.JobID}}" action="{{if eq .ComputeResource "CPU/GPU"}}{{$.RepoLink}}/cloudbrain{{else}}{{$.RepoLink}}/modelarts/notebook{{end}}/{{.JobID}}/del" method="post"> | |||||
| <form id="delForm-{{.Cloudbrain.ID}}" action="{{if eq .ComputeResource "CPU/GPU"}}{{$.RepoLink}}/cloudbrain{{else}}{{$.RepoLink}}/modelarts/notebook{{end}}/{{.Cloudbrain.ID}}/del" method="post"> | |||||
| <input type="hidden" name="debugListType" value="{{$.ListType}}"> | <input type="hidden" name="debugListType" value="{{$.ListType}}"> | ||||
| {{$.CsrfTokenHtml}} | {{$.CsrfTokenHtml}} | ||||
| {{if .CanDel}} | {{if .CanDel}} | ||||
| <a id="ai-delete-{{.JobID}}" class='ui basic ai_delete {{if eq .Status "STOPPED" "FAILED" "START_FAILED"}}blue {{else}}disabled {{end}}button' style="border-radius: .28571429rem;"> | |||||
| <a id="ai-delete-{{.Cloudbrain.ID}}" class='ui basic ai_delete {{if eq .Status "STOPPED" "FAILED" "START_FAILED"}}blue {{else}}disabled {{end}}button' style="border-radius: .28571429rem;"> | |||||
| {{$.i18n.Tr "repo.delete"}} | {{$.i18n.Tr "repo.delete"}} | ||||
| </a> | </a> | ||||
| {{else}} | {{else}} | ||||
| @@ -382,7 +382,7 @@ | |||||
| <!-- 接收结果 --> | <!-- 接收结果 --> | ||||
| <iframe src="" frameborder="0" name="iframeContent" style="display: none;"></iframe> | <iframe src="" frameborder="0" name="iframeContent" style="display: none;"></iframe> | ||||
| {{if .CanDebug}} | {{if .CanDebug}} | ||||
| <a id="model-image-{{.JobID}}" class='imageBtn ui basic {{if ne .Status "RUNNING"}}disabled {{else}}blue {{end}}button'>{{$.i18n.Tr "repo.submit_image"}}</a> | |||||
| <a id="model-image-{{.Cloudbrain.ID}}" class='imageBtn ui basic {{if ne .Status "RUNNING"}}disabled {{else}}blue {{end}}button'>{{$.i18n.Tr "repo.submit_image"}}</a> | |||||
| {{else}} | {{else}} | ||||
| <a class="imageBtn ui basic disabled button">{{$.i18n.Tr "repo.submit_image"}}</a> | <a class="imageBtn ui basic disabled button">{{$.i18n.Tr "repo.submit_image"}}</a> | ||||
| {{end}} | {{end}} | ||||
| @@ -390,14 +390,14 @@ | |||||
| <div class="item" style="padding: 0 !important;"> | <div class="item" style="padding: 0 !important;"> | ||||
| <!-- 模型下载 --> | <!-- 模型下载 --> | ||||
| {{if .CanDebug}} | {{if .CanDebug}} | ||||
| <a class="ui basic blue button" href="{{$.RepoLink}}/cloudbrain/{{.JobID}}/models" target="_blank">{{$.i18n.Tr "repo.download"}}</a> | |||||
| <a class="ui basic blue button" href="{{$.RepoLink}}/cloudbrain/{{.Cloudbrain.ID}}/models" target="_blank">{{$.i18n.Tr "repo.download"}}</a> | |||||
| {{else}} | {{else}} | ||||
| <a class="ui basic disabled button">{{$.i18n.Tr "repo.download"}}</a> | <a class="ui basic disabled button">{{$.i18n.Tr "repo.download"}}</a> | ||||
| {{end}} | {{end}} | ||||
| </div> | </div> | ||||
| {{if and (ne .JobType "DEBUG") (eq .Cloudbrain.Type 0)}} | {{if and (ne .JobType "DEBUG") (eq .Cloudbrain.Type 0)}} | ||||
| <div class="item" style="padding: 0 !important;"> | <div class="item" style="padding: 0 !important;"> | ||||
| <a class="ui basic blue button" href="{{$.RepoLink}}/cloudbrain/{{.JobID}}/rate" target="_blank"> | |||||
| <a class="ui basic blue button" href="{{$.RepoLink}}/cloudbrain/{{.Cloudbrain.ID}}/rate" target="_blank"> | |||||
| 评分 | 评分 | ||||
| </a> | </a> | ||||
| </div> | </div> | ||||
| @@ -411,7 +411,7 @@ | |||||
| <div class="modal-content"> | <div class="modal-content"> | ||||
| <!-- 表格 --> | <!-- 表格 --> | ||||
| <div class="ui form"> | <div class="ui form"> | ||||
| <form id="commitImageForm" action="{{$.RepoLink}}/cloudbrain/{{.JobID}}/commit_image" method="post" target="iframeContent"> | |||||
| <form id="commitImageForm" action="{{$.RepoLink}}/cloudbrain/{{.Cloudbrain.ID}}/commit_image" method="post" target="iframeContent"> | |||||
| {{$.CsrfTokenHtml}} | {{$.CsrfTokenHtml}} | ||||
| <div class="row"> | <div class="row"> | ||||
| <p style="display: inline;">提交任务镜像</p> | <p style="display: inline;">提交任务镜像</p> | ||||
| @@ -3,52 +3,52 @@ export default async function initCloudrain() { | |||||
| $(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 ID = job.dataset.ID; | |||||
| const repoPath = job.dataset.repopath; | const repoPath = job.dataset.repopath; | ||||
| // const computeResource = job.dataset.resource | // const computeResource = job.dataset.resource | ||||
| const versionname = job.dataset.version | const versionname = job.dataset.version | ||||
| const status_text = $(`#${jobID}-text`).text() | |||||
| const status_text = $(`#${ID}-text`).text() | |||||
| const finalState = ['STOPPED','CREATE_FAILED','UNAVAILABLE','DELETED','RESIZE_FAILED','SUCCEEDED','IMAGE_FAILED','SUBMIT_FAILED','DELETE_FAILED','KILLED','COMPLETED','FAILED','CANCELED','LOST','START_FAILED','SUBMIT_MODEL_FAILED','DEPLOY_SERVICE_FAILED','CHECK_FAILED'] | const finalState = ['STOPPED','CREATE_FAILED','UNAVAILABLE','DELETED','RESIZE_FAILED','SUCCEEDED','IMAGE_FAILED','SUBMIT_FAILED','DELETE_FAILED','KILLED','COMPLETED','FAILED','CANCELED','LOST','START_FAILED','SUBMIT_MODEL_FAILED','DEPLOY_SERVICE_FAILED','CHECK_FAILED'] | ||||
| if (finalState.includes(status_text)) { | if (finalState.includes(status_text)) { | ||||
| return | return | ||||
| } | } | ||||
| // const diffResource = computeResource == "NPU" ? 'modelarts/notebook' : 'cloudbrain' | // const diffResource = computeResource == "NPU" ? 'modelarts/notebook' : 'cloudbrain' | ||||
| $.get(`/api/v1/repos/${repoPath}/${jobID}?version_name=${versionname}`, (data) => { | |||||
| const jobID = data.JobID | |||||
| $.get(`/api/v1/repos/${repoPath}/${ID}?version_name=${versionname}`, (data) => { | |||||
| const ID = data.ID | |||||
| const status = data.JobStatus | const status = data.JobStatus | ||||
| const duration = data.JobDuration | const duration = data.JobDuration | ||||
| $('#duration-'+jobID).text(duration) | |||||
| $('#duration-'+ID).text(duration) | |||||
| if (status != status_text) { | if (status != status_text) { | ||||
| $('#' + jobID+'-icon').removeClass().addClass(status) | |||||
| $('#' + jobID+ '-text').text(status) | |||||
| finalState.includes(status) && $('#' + jobID + '-stop').removeClass('blue').addClass('disabled') | |||||
| $('#' + ID+'-icon').removeClass().addClass(status) | |||||
| $('#' + ID+ '-text').text(status) | |||||
| finalState.includes(status) && $('#' + ID + '-stop').removeClass('blue').addClass('disabled') | |||||
| } | } | ||||
| if(status==="RUNNING"){ | if(status==="RUNNING"){ | ||||
| $('#ai-debug-'+jobID).removeClass('disabled').addClass('blue').text('调试').css("margin","0 1rem") | |||||
| $('#model-image-'+jobID).removeClass('disabled').addClass('blue') | |||||
| $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text('调试').css("margin","0 1rem") | |||||
| $('#model-image-'+ID).removeClass('disabled').addClass('blue') | |||||
| } | } | ||||
| if(status!=="RUNNING"){ | if(status!=="RUNNING"){ | ||||
| // $('#model-debug-'+jobID).removeClass('blue') | |||||
| // $('#model-debug-'+jobID).addClass('disabled') | |||||
| $('#model-image-'+jobID).removeClass('blue').addClass('disabled') | |||||
| // $('#model-debug-'+ID).removeClass('blue') | |||||
| // $('#model-debug-'+ID).addClass('disabled') | |||||
| $('#model-image-'+ID).removeClass('blue').addClass('disabled') | |||||
| } | } | ||||
| if(["CREATING","STOPPING","WAITING","STARTING"].includes(status)){ | if(["CREATING","STOPPING","WAITING","STARTING"].includes(status)){ | ||||
| $('#ai-debug-'+jobID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-debug-'+ID).removeClass('blue').addClass('disabled') | |||||
| } | } | ||||
| if(['STOPPED','FAILED','START_FAILED','CREATE_FAILED','SUCCEEDED'].includes(status)){ | if(['STOPPED','FAILED','START_FAILED','CREATE_FAILED','SUCCEEDED'].includes(status)){ | ||||
| $('#ai-debug-'+jobID).removeClass('disabled').addClass('blue').text('再次调试').css("margin","0") | |||||
| $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text('再次调试').css("margin","0") | |||||
| } | } | ||||
| if(["RUNNING","WAITING"].includes(status)){ | if(["RUNNING","WAITING"].includes(status)){ | ||||
| $('#ai-stop-'+jobID).removeClass('disabled').addClass('blue') | |||||
| $('#ai-stop-'+ID).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)){ | ||||
| $('#ai-stop-'+jobID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-stop-'+ID).removeClass('blue').addClass('disabled') | |||||
| } | } | ||||
| if(["STOPPED","FAILED","START_FAILED","KILLED","COMPLETED","SUCCEEDED"].includes(status)){ | if(["STOPPED","FAILED","START_FAILED","KILLED","COMPLETED","SUCCEEDED"].includes(status)){ | ||||
| $('#ai-delete-'+jobID).removeClass('disabled').addClass('blue') | |||||
| $('#ai-delete-'+ID).removeClass('disabled').addClass('blue') | |||||
| }else{ | }else{ | ||||
| $('#ai-delete-'+jobID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-delete-'+ID).removeClass('blue').addClass('disabled') | |||||
| } | } | ||||
| }).fail(function(err) { | }).fail(function(err) { | ||||
| console.log(err); | console.log(err); | ||||
| @@ -104,25 +104,25 @@ export default async function initCloudrain() { | |||||
| assertDelete(this) | assertDelete(this) | ||||
| } | } | ||||
| }) | }) | ||||
| function stopDebug(JobID,stopUrl){ | |||||
| function stopDebug(ID,stopUrl){ | |||||
| $.ajax({ | $.ajax({ | ||||
| type:"POST", | type:"POST", | ||||
| url:stopUrl, | url:stopUrl, | ||||
| data:$('#stopForm-'+JobID).serialize(), | |||||
| data:$('#stopForm-'+ID).serialize(), | |||||
| success:function(res){ | success:function(res){ | ||||
| if(res.result_code==="0"){ | if(res.result_code==="0"){ | ||||
| $('#' + JobID+'-icon').removeClass().addClass(res.status) | |||||
| $('#' + JobID+ '-text').text(res.status) | |||||
| $('#' + ID+'-icon').removeClass().addClass(res.status) | |||||
| $('#' + ID+ '-text').text(res.status) | |||||
| if(res.status==="STOPPED"){ | if(res.status==="STOPPED"){ | ||||
| $('#ai-debug-'+JobID).removeClass('disabled').addClass('blue').text("再次调试").css("margin","0") | |||||
| $('#ai-image-'+JobID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-model-debug-'+JobID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-delete-'+JobID).removeClass('disabled').addClass('blue') | |||||
| $('#ai-stop-'+JobID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text("再次调试").css("margin","0") | |||||
| $('#ai-image-'+ID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-model-debug-'+ID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-delete-'+ID).removeClass('disabled').addClass('blue') | |||||
| $('#ai-stop-'+ID).removeClass('blue').addClass('disabled') | |||||
| } | } | ||||
| else{ | else{ | ||||
| $('#ai-debug-'+JobID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-stop-'+JobID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-debug-'+ID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-stop-'+ID).removeClass('blue').addClass('disabled') | |||||
| } | } | ||||
| }else{ | }else{ | ||||
| @@ -136,39 +136,39 @@ export default async function initCloudrain() { | |||||
| }) | }) | ||||
| } | } | ||||
| $('.ui.basic.ai_stop').click(function() { | $('.ui.basic.ai_stop').click(function() { | ||||
| const jobID = this.dataset.jobid | |||||
| const ID = this.dataset.ID | |||||
| const repoPath = this.dataset.repopath | const repoPath = this.dataset.repopath | ||||
| stopDebug(jobID,repoPath) | |||||
| stopDebug(ID,repoPath) | |||||
| }) | }) | ||||
| function stopVersion(version_name,jobID,repoPath){ | |||||
| const url = `/api/v1/repos/${repoPath}/${jobID}/stop_version` | |||||
| function stopVersion(version_name,ID,repoPath){ | |||||
| const url = `/api/v1/repos/${repoPath}/${ID}/stop_version` | |||||
| $.post(url,{version_name:version_name},(data)=>{ | $.post(url,{version_name:version_name},(data)=>{ | ||||
| if(data.StatusOK===0){ | if(data.StatusOK===0){ | ||||
| $('#ai-stop-'+jobID).removeClass('blue') | |||||
| $('#ai-stop-'+jobID).addClass('disabled') | |||||
| refreshStatus(version_name,jobID,repoPath) | |||||
| $('#ai-stop-'+ID).removeClass('blue') | |||||
| $('#ai-stop-'+ID).addClass('disabled') | |||||
| refreshStatus(version_name,ID,repoPath) | |||||
| } | } | ||||
| }).fail(function(err) { | }).fail(function(err) { | ||||
| console.log(err); | console.log(err); | ||||
| }); | }); | ||||
| } | } | ||||
| function refreshStatus(version_name,jobID,repoPath){ | |||||
| function refreshStatus(version_name,ID,repoPath){ | |||||
| const url = `/api/v1/repos/${repoPath}/${jobID}/?version_name${version_name}` | |||||
| const url = `/api/v1/repos/${repoPath}/${ID}/?version_name${version_name}` | |||||
| $.get(url,(data)=>{ | $.get(url,(data)=>{ | ||||
| $(`#${jobID}-icon`).attr("class",data.JobStatus) | |||||
| $(`#${ID}-icon`).attr("class",data.JobStatus) | |||||
| // detail status and duration | // detail status and duration | ||||
| $(`#${jobID}-text`).text(data.JobStatus) | |||||
| $(`#${ID}-text`).text(data.JobStatus) | |||||
| }).fail(function(err) { | }).fail(function(err) { | ||||
| console.log(err); | console.log(err); | ||||
| }); | }); | ||||
| } | } | ||||
| $('.ui.basic.ai_stop_version').click(function() { | $('.ui.basic.ai_stop_version').click(function() { | ||||
| const jobID = this.dataset.jobid | |||||
| const ID = this.dataset.ID | |||||
| const repoPath = this.dataset.repopath | const repoPath = this.dataset.repopath | ||||
| const versionName = this.dataset.version | const versionName = this.dataset.version | ||||
| stopVersion(versionName,jobID,repoPath) | |||||
| stopVersion(versionName,ID,repoPath) | |||||
| }) | }) | ||||
| function getModelInfo(repoPath,modelName,versionName,jobName){ | function getModelInfo(repoPath,modelName,versionName,jobName){ | ||||
| console.log("getModelInfo") | console.log("getModelInfo") | ||||
| @@ -195,27 +195,27 @@ export default async function initCloudrain() { | |||||
| const jobName = this.dataset.jobname | const jobName = this.dataset.jobname | ||||
| getModelInfo(repoPath,modelName,versionName,jobName) | getModelInfo(repoPath,modelName,versionName,jobName) | ||||
| }) | }) | ||||
| function debugAgain(JobID,debugUrl,redirect_to){ | |||||
| if($('#' + JobID+ '-text').text()==="RUNNING"){ | |||||
| function debugAgain(ID,debugUrl,redirect_to){ | |||||
| if($('#' + ID+ '-text').text()==="RUNNING"){ | |||||
| window.open(debugUrl+'debug') | window.open(debugUrl+'debug') | ||||
| }else{ | }else{ | ||||
| $.ajax({ | $.ajax({ | ||||
| type:"POST", | type:"POST", | ||||
| url:debugUrl+'restart?redirect_to='+redirect_to, | url:debugUrl+'restart?redirect_to='+redirect_to, | ||||
| data:$('#debugAgainForm-'+JobID).serialize(), | |||||
| data:$('#debugAgainForm-'+ID).serialize(), | |||||
| success:function(res){ | success:function(res){ | ||||
| if(res['WechatRedirectUrl']){ | if(res['WechatRedirectUrl']){ | ||||
| window.location.href=res['WechatRedirectUrl'] | window.location.href=res['WechatRedirectUrl'] | ||||
| } | } | ||||
| else if(res.result_code==="0"){ | else if(res.result_code==="0"){ | ||||
| if(res.job_id!==JobID){ | |||||
| if(res.id!==ID){ | |||||
| location.reload() | location.reload() | ||||
| }else{ | }else{ | ||||
| $('#' + JobID+'-icon').removeClass().addClass(res.status) | |||||
| $('#' + JobID+ '-text').text(res.status) | |||||
| $('#ai-debug-'+JobID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-delete-'+JobID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-debug-'+JobID).text("调试").css("margin","0 1rem") | |||||
| $('#' + ID+'-icon').removeClass().addClass(res.status) | |||||
| $('#' + ID+ '-text').text(res.status) | |||||
| $('#ai-debug-'+ID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-delete-'+ID).removeClass('blue').addClass('disabled') | |||||
| $('#ai-debug-'+ID).text("调试").css("margin","0 1rem") | |||||
| } | } | ||||
| }else{ | }else{ | ||||
| $('.alert').html(res.error_msg).removeClass('alert-success').addClass('alert-danger').show().delay(2000).fadeOut(); | $('.alert').html(res.error_msg).removeClass('alert-success').addClass('alert-danger').show().delay(2000).fadeOut(); | ||||
| @@ -228,10 +228,10 @@ export default async function initCloudrain() { | |||||
| } | } | ||||
| } | } | ||||
| $('.ui.basic.ai_debug').click(function() { | $('.ui.basic.ai_debug').click(function() { | ||||
| const jobID = this.dataset.jobid | |||||
| const ID = this.dataset.ID | |||||
| const repoPath = this.dataset.repopath | const repoPath = this.dataset.repopath | ||||
| const redirect_to = this.dataset.linkpath | const redirect_to = this.dataset.linkpath | ||||
| debugAgain(jobID,repoPath,redirect_to) | |||||
| debugAgain(ID,repoPath,redirect_to) | |||||
| }) | }) | ||||
| } | } | ||||