Browse Source

fix issue

tags/v1.22.8.1^2
zhoupzh 3 years ago
parent
commit
751626af08
7 changed files with 112 additions and 218 deletions
  1. +2
    -2
      templates/repo/attachment/upload.tmpl
  2. +2
    -0
      templates/repo/cloudbrain/trainjob/show.tmpl
  3. +15
    -18
      templates/repo/grampus/trainjob/show.tmpl
  4. +4
    -1
      templates/repo/modelarts/inferencejob/show.tmpl
  5. +5
    -149
      templates/repo/modelarts/trainjob/show.tmpl
  6. +83
    -21
      web_src/js/features/cloudbrainShow.js
  7. +1
    -27
      web_src/js/features/cloudrbanin.js

+ 2
- 2
templates/repo/attachment/upload.tmpl View File

@@ -3,7 +3,7 @@
{{template "repo/header" .}}
<div class="ui container">
<input type="hidden" id="postPath" value="{{.Link}}">
<div style="width: 80%;margin: auto;">
<div>
<h4 class="ui top attached header">
{{$.i18n.Tr "dataset.upload_dataset_file"}}
</h4>
@@ -54,7 +54,7 @@
</div>
</div>
</div>
<div style="width: 80%;margin: auto;padding-top: 2em;">
<div style="padding-top: 2em;">
<!-- <p>说明:<br>
- 只有<span class="text blue">zip格式</span>zip格式的数据集才能发起云脑任务;<br>
- 云脑1提供 <span class="text blue">CPU / GPU</span> 资源,云脑2提供 <span class="text blue">Ascend NPU</span> 资源;调试使用的数据集也需要上传到对应的环境。


+ 2
- 0
templates/repo/cloudbrain/trainjob/show.tmpl View File

@@ -272,6 +272,8 @@
class="cti-mgRight-sm">{{$.i18n.Tr "repo.modelarts.train_job.dura_time"}}:</span>
<span class="cti-mgRight-sm uc-accordionTitle-black"
id="{{.VersionName}}-duration-span">{{$.duration}}</span>
<span id="refresh-status" data-tooltip="刷新" style="cursor: pointer;" data-inverted="" data-version="{{.VersionName}}"><i
class="redo icon redo-color"></i></span>

</div>
</span>


+ 15
- 18
templates/repo/grampus/trainjob/show.tmpl View File

@@ -289,10 +289,8 @@
<div class="content-pad">
<div class="ui pointing secondary menu" style="border-bottom: 1px solid rgba(34,36,38,.15);">

<a class="active item"
data-tab="first{{$k}}">{{$.i18n.Tr "repo.modelarts.train_job.config"}}</a>
<a class="item" data-tab="second{{$k}}"
onclick="loadLog({{.VersionName}})">{{$.i18n.Tr "repo.modelarts.log"}}</a>
<a class="active item" data-tab="first{{$k}}">{{$.i18n.Tr "repo.modelarts.train_job.config"}}</a>
<a class="item log_bottom" data-tab="second{{$k}}" data-version="{{.VersionName}}">{{$.i18n.Tr "repo.modelarts.log"}}</a>
<a class="item load-model-file" data-tab="third{{$k}}" data-download-flag="{{$.canDownload}}" data-path="{{$.RepoLink}}/modelarts/train-job/{{.JobID}}/model_list" data-version="{{.VersionName}}" data-parents="" data-filename="" data-init="init" >{{$.i18n.Tr "repo.model_download"}}</a>
</div>
<div class="ui tab active" data-tab="first{{$k}}">
@@ -477,11 +475,23 @@
</div>
<div class="ui tab" data-tab="second{{$k}}">
<div style="position: relative;">
<span>
<a title="滚动到顶部" style="position: absolute; right: -32px;cursor: pointer;"
class="log_top" data-version="{{.VersionName}}"><i class="icon-to-top"></i></a>
</span>
<span class="log-info">
<a title="滚动到底部" style="position: absolute; bottom: 10px;right: -32px;cursor: pointer;"
class="log_bottom" data-version="{{.VersionName}}"><i
class="icon-to-bottom"></i></a>
</span>
<div class="ui message message{{.VersionName}}" style="display: none;">
<div id="header"></div>
</div>
<div class="ui attached log" id="log{{.VersionName}}"
<div class="ui attached log" id="log{{.VersionName}}"
style="height: 300px !important; overflow: auto;">
<div class="ui inverted active dimmer">
<div class="ui loader"></div>
</div>
<input type="hidden" name="end_line" value>
<input type="hidden" name="start_line" value>
<pre id="log_file{{.VersionName}}"></pre>
@@ -866,17 +876,4 @@
size = size.toFixed(0);//保留的小数位数
return size + unitArr[index];
}

function loadLog(version_name) {
document.getElementById("mask").style.display = "block"
$.get(`/api/v1/repos/${userName}/${repoPath}/grampus/train-job/${jobID}/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)
document.getElementById("mask").style.display = "none"
}).fail(function (err) {
document.getElementById("mask").style.display = "none"
console.log(err);
});
}
</script>

+ 4
- 1
templates/repo/modelarts/inferencejob/show.tmpl View File

@@ -463,7 +463,7 @@ td, th {
<a title="滚动到顶部" style="position: absolute; right: -32px;cursor: pointer;"
class="log_top" data-version="{{.VersionName}}"><i class="icon-to-top"></i></a>
</span>
<span>
<span class="log-info">
<a title="滚动到底部" style="position: absolute; bottom: 10px;right: -32px;cursor: pointer;"
class="log_bottom" data-version="{{.VersionName}}"><i
class="icon-to-bottom"></i></a>
@@ -472,6 +472,9 @@ td, th {
<div id="header"></div>
</div>
<div class="ui attached log log-scroll" data-version="{{.VersionName}}" id="log{{.VersionName}}" style="height: 300px !important; overflow: auto;">
<div class="ui inverted active dimmer">
<div class="ui loader"></div>
</div>
<input type="hidden" name="end_line" value>
<input type="hidden" name="start_line" value>
<pre id="log_file{{.VersionName}}"></pre>


+ 5
- 149
templates/repo/modelarts/trainjob/show.tmpl View File

@@ -512,7 +512,7 @@
<a title="滚动到顶部" style="position: absolute; right: -32px;cursor: pointer;"
class="log_top" data-version="{{.VersionName}}"><i class="icon-to-top"></i></a>
</span>
<span>
<span class="log-info">
<a title="滚动到底部" style="position: absolute; bottom: 10px;right: -32px;cursor: pointer;"
class="log_bottom" data-version="{{.VersionName}}"><i
class="icon-to-bottom"></i></a>
@@ -522,6 +522,9 @@
</div>
<div class="ui attached log log-scroll" id="log{{.VersionName}}" data-version="{{.VersionName}}"
style="height: 300px !important; overflow: auto;">
<div class="ui inverted active dimmer">
<div class="ui loader"></div>
</div>
<input type="hidden" name="end_line" value>
<input type="hidden" name="start_line" value>
<pre id="log_file{{.VersionName}}"></pre>
@@ -905,154 +908,7 @@

}

function loadLog(version_name) {
$.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/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)
if(!data.CanLogDownload){
$(`#${version_name}-log-down`).removeClass('ti-download-file').addClass('disabled')
}
}).fail(function (err) {
console.log(err);
});
}
function debounce(fn, delay) {
let timer;
return (...args) => {
// 判断定时器是否存在,清除定时器
if (timer) {
clearTimeout(timer);
}

// 重新调用setTimeout
timer = setTimeout(() => {
fn.apply(this, args);
}, delay);
};
}
const fn = debounce(logScroll, 500)
function logScroll(version_name) {
let container = document.querySelector(`#log${version_name}`)
let scrollTop = container.scrollTop
let scrollHeight = container.scrollHeight
let clientHeight = container.clientHeight
let scrollLeft = container.scrollLeft
if (((parseInt(scrollTop) + clientHeight == scrollHeight || parseInt(scrollTop) + clientHeight + 1 == scrollHeight || parseInt(scrollTop) + clientHeight - 1 == scrollHeight)) && parseInt(scrollTop) !== 0 && scrollLeft == 0) {
let end_line = $(`#log${version_name} input[name=end_line]`).val()
$.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?version_name=${version_name}&base_line=${end_line}&lines=50&order=desc`, (data) => {
if (data.Lines == 0) {
$(`.message${version_name} #header`).text('您已翻阅至日志底部')
$(`.message${version_name}`).css('display', 'block')
setTimeout(function () {
$(`.message${version_name}`).css('display', 'none')
}, 1000)
} else {
if (end_line === data.EndLine) {
return
}
else {
$(`#log${version_name} input[name=end_line]`).val(data.EndLine)
$(`#log${version_name}`).append('<pre>' + data.Content)
}

}
}).fail(function (err) {
console.log(err);
});
}
if ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].includes(scrollTop) && scrollLeft == 0) {
let start_line = $(`#log${version_name} input[name=start_line]`).val()
$.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?version_name=${version_name}&base_line=${start_line}&lines=50&order=asc`, (data) => {
if (data.Lines == 0) {
$(`.message${version_name} #header`).text('您已翻阅至日志顶部')
$(`.message${version_name}`).css('display', 'block')
setTimeout(function () {
$(`.message${version_name}`).css('display', 'none')
}, 1000)
} else {
$(`#log${version_name} input[name=start_line]`).val(data.StartLine) //如果变动就改变所对应的值
$(`#log${version_name}`).prepend('<pre>' + data.Content)
}
}).fail(function (err) {
console.log(err);
});
}
}
function scrollAnimation(dom, currentY, targetY, currentX) {
let needScrollTop = targetY - currentY;
let _currentY = currentY;
setTimeout(() => {
// 一次调用滑动帧数,每次调用会不一样
//取总距离的十分之一
const dist = Math.ceil(needScrollTop / 10);
_currentY += dist;
//移动一个十分之一
dom.scrollTo(currentX || 0, _currentY, 'smooth');
// 如果移动幅度小于十个像素,直接移动,否则递归调用,实现动画效果
if (needScrollTop > 10 || needScrollTop < -10) {
scrollAnimation(dom, _currentY, targetY)
} else {
dom.scrollTo(0, targetY, 'smooth')
}
}, 1)
}

$('.log_top').click(function () {
// let logContentDom = document.querySelector('.log')
// if(!logContentDom)
// return
// let version_name = $('.log_top').data('version')
let version_name = $(this).data('version')
let logContentDom = document.querySelector(`#log${version_name}`)

$(`#log_file${version_name}`).siblings('pre').remove()
$.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?version_name=${version_name}&base_line=&lines=50&order=asc`, (data) => {

$(`#log${version_name} input[name=end_line]`).val(data.EndLine) //如果变动就改变所对应的值
$(`#log${version_name} input[name=start_line]`).val(data.StartLine)
$(`#log${version_name}`).prepend('<pre>' + data.Content)
$(`.message${version_name} #header`).text('您已翻阅至日志顶部')
$(`.message${version_name}`).css('display', 'block')
setTimeout(function () {
$(`.message${version_name}`).css('display', 'none')
}, 1000)
scrollAnimation(logContentDom, logContentDom.scrollTop, 0);
})

})
$('.log_bottom').click(function (e) {
let version_name = $(this).data('version')
let logContentDom = document.querySelector(`#log${version_name}`)
$(`#log_file${version_name}`).siblings('pre').remove()
$.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?version_name=${version_name}&base_line=&lines=50&order=desc`, (data) => {

$(`#log${version_name} input[name=end_line]`).val(data.EndLine) //如果变动就改变所对应的值
$(`#log${version_name} input[name=start_line]`).val(data.StartLine)
$(`#log${version_name}`).append('<pre>' + data.Content)
$.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?version_name=${version_name}&base_line=${data.EndLine}&lines=50&order=desc`, (data) => {
if (data.Lines == 0) {
$(`.message${version_name} #header`).text('您已翻阅至日志底部')
$(`.message${version_name}`).css('display', 'block')
setTimeout(function () {
$(`.message${version_name}`).css('display', 'none')
}, 1000)
} else {
if (end_line === data.EndLine) {
return
}
else {
$(`#log${version_name} input[name=end_line]`).val(data.EndLine)
$(`#log${version_name}`).append('<pre>' + data.Content)
}

}
}).fail(function (err) {
console.log(err);
});
scrollAnimation(logContentDom, logContentDom.scrollTop + 1, logContentDom.scrollHeight - logContentDom.clientHeight);
})
})



+ 83
- 21
web_src/js/features/cloudbrainShow.js View File

@@ -14,7 +14,7 @@ export default async function initCloudrainSow() {
};
}

function logScroll(version_name) {
function logScroll(version_name, repoPath, ID) {
let container = document.querySelector(`#log${version_name}`);
let scrollTop = container.scrollTop;
let scrollHeight = container.scrollHeight;
@@ -28,7 +28,7 @@ export default async function initCloudrainSow() {
) {
let end_line = $(`#log${version_name} input[name=end_line]`).val();
$.get(
`/api/v1/repos/${userName}/${repoPath}/modelarts/inference-job/${jobID}/log?version_name=${version_name}&base_line=${end_line}&lines=50&order=desc`,
`/api/v1/repos/${repoPath}/${ID}/log?version_name=${version_name}&base_line=${end_line}&lines=50&order=desc`,
(data) => {
if (data.Lines == 0) {
$(`.message${version_name} #header`).text("您已翻阅至日志底部");
@@ -52,7 +52,7 @@ export default async function initCloudrainSow() {
if (scrollTop == 0 && scrollLeft == 0) {
let start_line = $(`#log${version_name} input[name=start_line]`).val();
$.get(
`/api/v1/repos/${userName}/${repoPath}/modelarts/inference-job/${jobID}/log?version_name=${version_name}&base_line=${start_line}&lines=50&order=asc`,
`/api/v1/repos/${repoPath}/${ID}/log?version_name=${version_name}&base_line=${start_line}&lines=50&order=asc`,
(data) => {
if (data.Lines == 0) {
$(`.message${version_name} #header`).text("您已翻阅至日志顶部");
@@ -73,7 +73,9 @@ export default async function initCloudrainSow() {
const fn = debounce(logScroll, 500);
$(".log-scroll").scroll(function () {
let version_name = $(this).data("version");
fn(version_name);
let ID = $(`#accordion${version_name}`).data("jobid");
let repoPath = $(`#accordion${version_name}`).data("repopath");
fn(version_name, repoPath, ID);
});
function scrollAnimation(dom, currentY, targetY, currentX) {
let needScrollTop = targetY - currentY;
@@ -101,11 +103,14 @@ export default async function initCloudrainSow() {
// let version_name = $('.log_top').data('version')
let version_name = $(this).data("version");
let logContentDom = document.querySelector(`#log${version_name}`);

let ID = $(`#accordion${version_name}`).data("jobid");
let repoPath = $(`#accordion${version_name}`).data("repopath");
$(`#log_file${version_name}`).siblings("pre").remove();
$(".ui.inverted.active.dimmer").css("display", "block");
$.get(
`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?version_name=${version_name}&base_line=&lines=50&order=asc`,
`/api/v1/repos/${repoPath}/${ID}/log?version_name=${version_name}&base_line=&lines=50&order=asc`,
(data) => {
$(".ui.inverted.active.dimmer").css("display", "none");
$(`#log${version_name} input[name=end_line]`).val(data.EndLine); //如果变动就改变所对应的值
$(`#log${version_name} input[name=start_line]`).val(data.StartLine);
$(`#log${version_name}`).prepend("<pre>" + data.Content);
@@ -121,10 +126,15 @@ export default async function initCloudrainSow() {
$(".log_bottom").click(function (e) {
let version_name = $(this).data("version");
let logContentDom = document.querySelector(`#log${version_name}`);
let ID = $(`#accordion${version_name}`).data("jobid");
let repoPath = $(`#accordion${version_name}`).data("repopath");
$(`#log_file${version_name}`).siblings("pre").remove();
let end_line = $(`#log${version_name} input[name=end_line]`).val();
$(".ui.inverted.active.dimmer").css("display", "block");
$.get(
`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?version_name=${version_name}&base_line=&lines=50&order=desc`,
`/api/v1/repos/${repoPath}/${ID}/log?version_name=${version_name}&base_line=&lines=50&order=desc`,
(data) => {
$(".ui.inverted.active.dimmer").css("display", "none");
if (!data.CanLogDownload) {
$(`#${version_name}-log-down`)
.removeClass("ti-download-file")
@@ -134,8 +144,9 @@ export default async function initCloudrainSow() {
$(`#log${version_name} input[name=start_line]`).val(data.StartLine);
$(`#log${version_name}`).append("<pre>" + data.Content);
$.get(
`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?version_name=${version_name}&base_line=${data.EndLine}&lines=50&order=desc`,
`/api/v1/repos/${repoPath}/${ID}/log?version_name=${version_name}&base_line=${data.EndLine}&lines=50&order=desc`,
(data) => {
$(".ui.inverted.active.dimmer").css("display", "none");
if (data.Lines == 0) {
$(`.message${version_name} #header`).text("您已翻阅至日志底部");
$(`.message${version_name}`).css("display", "block");
@@ -143,7 +154,7 @@ export default async function initCloudrainSow() {
$(`.message${version_name}`).css("display", "none");
}, 1000);
} else {
if (end_line === data.EndLine) {
if (end_line === data.EndLine || end_line === "") {
return;
} else {
$(`#log${version_name} input[name=end_line]`).val(data.EndLine);
@@ -163,6 +174,49 @@ export default async function initCloudrainSow() {
);
});

function loadLog(version_name) {
document.getElementById("mask").style.display = "block";
$.get(
`/api/v1/repos/${userName}/${repoPath}/grampus/train-job/${jobID}/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);
document.getElementById("mask").style.display = "none";
}
).fail(function (err) {
document.getElementById("mask").style.display = "none";
console.log(err);
});
}
$("#refresh-status").click(function (e) {
let version_name = $(this).data("version");
let ID = $(`#accordion${version_name}`).data("jobid");
let repoPath = $(`#accordion${version_name}`).data("repopath");
refreshStatusShow(version_name, ID, repoPath);
$(".log-info .log_bottom").trigger("click");
e.stopPropagation();
});

function refreshStatusShow(version_name, ID, repoPath) {
$.get(
`/api/v1/repos/${repoPath}/${ID}?version_name=${version_name}`,
(data) => {
//accroding下的状态
$(`#${version_name}-status-span span`).text(data.JobStatus);
//accroding下的状态图标
$(`#${version_name}-status-span i`).attr("class", data.JobStatus);
//accroding下的运行时长
$(`#${version_name}-duration-span`).text(data.JobDuration);
//配置信息详情页的状态
$(`#${version_name}-status`).text(data.JobStatus);
//配置信息详情页的状态
$(`#${version_name}-duration`).text(data.JobDuration);
}
).fail(function (err) {
console.log(err);
});
}
//
$(".content-pad").on("click", ".load-model-file", function () {
let downloadFlag = $(this).data("download-flag") || "";
@@ -175,8 +229,8 @@ export default async function initCloudrainSow() {
let url = `/api/v1/repos${path}?version_name=${version_name}&parentDir=${parents}`;
$.get(url, (data) => {
$(`#dir_list${version_name}`).empty();
if(data.Dirs){
renderDir(path, data, version_name, downloadFlag, gpuFlag);
if (data.Dirs) {
renderDir(path, data, version_name, downloadFlag, gpuFlag);
}
if (init === "init") {
$(`input[name=model${version_name}]`).val("");
@@ -191,7 +245,15 @@ export default async function initCloudrainSow() {
htmlBread += "<div class='divider'> / </div>";
$(`#file_breadcrumb${version_name}`).append(htmlBread);
} else {
renderBrend(path, version_name, parents, filename, init, downloadFlag,gpuFlag);
renderBrend(
path,
version_name,
parents,
filename,
init,
downloadFlag,
gpuFlag
);
}
}).fail(function (err) {
console.log(err, version_name);
@@ -253,15 +315,15 @@ export default async function initCloudrainSow() {
} else {
$(`input[name=model${version_name}]`).val(parents);
$(`input[name=modelback${version_name}]`).val(filename);
$(`#file_breadcrumb${version_name} a.section:contains(${filename})`)
.nextAll()
.remove();
$(
`#file_breadcrumb${version_name} a.section:contains(${filename})`
).replaceWith(`<div class='active section'>${filename}</div>`);
$(
`#file_breadcrumb${version_name} div.section:contains(${filename})`
).append("<div class='divider'> / </div>");
let selectEle = $(`#file_breadcrumb${version_name} a.section`).filter(
(index, item) => {
return item.text == filename;
}
);
selectEle.nextAll().remove();
selectEle.replaceWith(`<div class='active section'>${filename}</div>`);
selectEle.append("<div class='divider'> / </div>");
}
}



+ 1
- 27
web_src/js/features/cloudrbanin.js View File

@@ -347,33 +347,7 @@ export default async function initCloudrain() {
e.stopPropagation();
});

$("#refresh-status").click(function (e) {
let version_name = $(this).data("version");
let ID = $(`#accordion${version_name}`).data("jobid");
let repoPath = $(`#accordion${version_name}`).data("repopath");
refreshStatusShow(version_name, ID, repoPath);
e.stopPropagation();
});

function refreshStatusShow(version_name, ID, repoPath) {
$.get(
`/api/v1/repos/${repoPath}/${ID}?version_name=${version_name}`,
(data) => {
//accroding下的状态
$(`#${version_name}-status-span span`).text(data.JobStatus);
//accroding下的状态图标
$(`#${version_name}-status-span i`).attr("class", data.JobStatus);
//accroding下的运行时长
$(`#${version_name}-duration-span`).text(data.JobDuration);
//配置信息详情页的状态
$(`#${version_name}-status`).text(data.JobStatus);
//配置信息详情页的状态
$(`#${version_name}-duration`).text(data.JobDuration);
}
).fail(function (err) {
console.log(err);
});
}
function refreshStatus(version_name, ID, repoPath) {
const url = `/api/v1/repos/${repoPath}/${ID}/?version_name${version_name}`;
$.get(url, (data) => {


Loading…
Cancel
Save