Browse Source

Merge branch 'V20220830' into fix-2546

pull/2736/head
chenshihai 2 years ago
parent
commit
28fd24a5e0
5 changed files with 69 additions and 32 deletions
  1. +10
    -1
      routers/api/v1/repo/modelarts.go
  2. +10
    -0
      routers/repo/modelarts.go
  3. +7
    -31
      templates/repo/modelarts/trainjob/show.tmpl
  4. +29
    -0
      web_src/js/features/cloudbrainShow.js
  5. +13
    -0
      web_src/js/features/cloudrbanin.js

+ 10
- 1
routers/api/v1/repo/modelarts.go View File

@@ -6,13 +6,14 @@
package repo

import (
"code.gitea.io/gitea/modules/notification"
"encoding/json"
"net/http"
"path"
"strconv"
"strings"

"code.gitea.io/gitea/modules/notification"

"code.gitea.io/gitea/modules/grampus"
"code.gitea.io/gitea/modules/setting"

@@ -352,6 +353,14 @@ func DelTrainJobVersion(ctx *context.APIContext) {
return
}

if task.Status != string(models.ModelArtsTrainJobImageFailed) && task.Status != string(models.ModelArtsTrainJobSubmitFailed) && task.Status != string(models.ModelArtsTrainJobDeleteFailed) &&
task.Status != string(models.ModelArtsTrainJobCompleted) && task.Status != string(models.ModelArtsTrainJobFailed) &&
task.Status != string(models.ModelArtsTrainJobKilled) && task.Status != string(models.ModelArtsTrainJobCanceled) && task.Status != string(models.ModelArtsTrainJobLost) {
log.Error("the job(%s) version has not been stopped", task.JobName)
ctx.NotFound(err)
return
}

//删除modelarts上的记录
_, err = modelarts.DelTrainJobVersion(jobID, strconv.FormatInt(task.VersionID, 10))
if err != nil {


+ 10
- 0
routers/repo/modelarts.go View File

@@ -1845,6 +1845,16 @@ func TrainJobDel(ctx *context.Context) {
return
}

for _, task := range VersionListTasks {
if task.Status != string(models.ModelArtsTrainJobImageFailed) && task.Status != string(models.ModelArtsTrainJobSubmitFailed) && task.Status != string(models.ModelArtsTrainJobDeleteFailed) &&
task.Status != string(models.ModelArtsTrainJobCompleted) && task.Status != string(models.ModelArtsTrainJobFailed) &&
task.Status != string(models.ModelArtsTrainJobKilled) && task.Status != string(models.ModelArtsTrainJobCanceled) && task.Status != string(models.ModelArtsTrainJobLost) {
log.Error("the job(%s) version has not been stopped", task.JobName)
ctx.RenderWithErr("the job version has not been stopped", tplModelArtsTrainJobIndex, nil)
return
}
}

//删除modelarts上的任务记录
_, err = modelarts.DelTrainJob(jobID)
if err != nil {


+ 7
- 31
templates/repo/modelarts/trainjob/show.tmpl View File

@@ -274,10 +274,14 @@


{{if .CanDel}}
<a class="ti-action-menu-item" onclick="deleteVersion({{.VersionName}})"
<a class='ti-action-menu-item delete-show-version {{if eq .Status "CREATING" "STOPPING" "WAITING" "STARTING" "RUNNING" "KILLING" "INIT"}}disabled {{end}}'
id="{{.VersionName}}-delete"
data-jobid="{{.JobID}}"
data-repopath="{{$.RepoRelPath}}/modelarts/train-job"
data-version = "{{.VersionName}}"
style="color: #FF4D4F;">{{$.i18n.Tr "repo.delete"}}</a>
{{else}}
<a class="ti-action-menu-item disabled" onclick="deleteVersion({{.VersionName}})"
<a class="ti-action-menu-item disabled"
style="color: #FF4D4F;">{{$.i18n.Tr "repo.delete"}}</a>
{{end}}
</div>
@@ -899,35 +903,7 @@
$('#name').val(modelName)
$('#version').val("0.0.1")
}
function deleteVersion(version_name) {
stopBubbling(arguments.callee.caller.arguments[0])
let flag = 1;
$('.ui.basic.modal').modal({
onDeny: function () {
flag = false
},
onApprove: function () {
$.post(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/del_version`, { version_name: version_name }, (data) => {
if (data.VersionListCount === 0) {
location.href = `/${userName}/${repoPath}/modelarts/train-job`
} else {
$('#accordion' + version_name).remove()
}

}).fail(function (err) {
console.log(err);
});
flag = true
},
onHidden: function () {
if (flag == false) {
$('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
}
}
})
.modal('show')

}




+ 29
- 0
web_src/js/features/cloudbrainShow.js View File

@@ -213,6 +213,35 @@ export default async function initCloudrainSow() {
});
e.stopPropagation();
});
$(".delete-show-version").click(function (e) {
const ID = this.dataset.jobid;
const repoPath = this.dataset.repopath;
const version_name = this.dataset.version;
const url = `/api/v1/repos/${repoPath}/${ID}/del_version`;
$(".ui.basic.modal")
.modal({
onApprove: function () {
$.post(url, { version_name: version_name }, (data) => {
console.log(data);
if (data.StatusOK === 0) {
if (data.VersionListCount === 0) {
location.href = `/${repoPath}`;
} else {
$("#accordion" + version_name).remove();
}
refreshStatusShow(version_name, ID, repoPath);
} else {
return;
}
}).fail(function (err) {
console.log(err);
});
},
})
.modal("show");

e.stopPropagation();
});
function refreshStatusShow(version_name, ID, repoPath) {
$.get(
`/api/v1/repos/${repoPath}/${ID}?version_name=${version_name}`,


+ 13
- 0
web_src/js/features/cloudrbanin.js View File

@@ -182,6 +182,15 @@ export default async function initCloudrain() {
"CREATE_FAILED",
"STOPPED",
];
let deleteArray = [
"KILLED",
"FAILED",
"START_FAILED",
"COMPLETED",
"SUCCEEDED",
"CREATE_FAILED",
"STOPPED",
];
$.get(
`/api/v1/repos/${repoPath}/${jobID}?version_name=${versionname}`,
(data) => {
@@ -194,6 +203,10 @@ export default async function initCloudrain() {
if (stopArray.includes(data.JobStatus)) {
$("#" + versionname + "-stop").addClass("disabled");
}
if (deleteArray.includes(data.JobStatus)) {
$(`#${versionname}-delete`).removeClass("disabled");
$(`#${versionname}-delete`).addClass("blue");
}
if (data.JobStatus === "COMPLETED") {
$("#" + versionname + "-create-model")
.removeClass("disabled")


Loading…
Cancel
Save