镜像
镜像
-
{
+ // 判断定时器是否存在,清除定时器
+ if (timer) {
+ clearTimeout(timer);
+ }
+
+ // 重新调用setTimeout
+ timer = setTimeout(() => {
+ fn.apply(this, args);
+ }, delay);
+ };
+ }
+
+ function logScroll(version_name) {
+ let container = document.querySelector(`#log${version_name}`);
+ console.log(container);
+ 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) &&
+ scrollLeft === 0
+ ) {
+ 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`,
+ (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("" + data.Content);
+ }
+ }
+ }
+ ).fail(function (err) {
+ console.log(err);
+ });
+ }
+ 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`,
+ (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("" + data.Content);
+ }
+ }
+ ).fail(function (err) {
+ console.log(err);
+ });
+ }
+ }
+ const fn = debounce(logScroll, 500);
+ $(".log-scroll").scroll(function () {
+ let version_name = $(this).data("version");
+ fn(version_name);
+ });
+ 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("" + 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("" + 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("" + data.Content);
+ }
+ }
+ }
+ ).fail(function (err) {
+ console.log(err);
+ });
+ scrollAnimation(
+ logContentDom,
+ logContentDom.scrollTop + 1,
+ logContentDom.scrollHeight - logContentDom.clientHeight
+ );
+ }
+ );
+ });
+
+ //
+ $(".content-pad").on("click", ".load-model-file", function () {
+ console.log("11111111111");
+ let version_name = $(this).data("version");
+ let parents = $(this).data("parents") || "";
+ let filename = $(this).data("filename") || "";
+ let init = $(this).data("init") || "";
+ let path = $(this).data("path");
+ let url = `/api/v1/repos${path}?version_name=${version_name}&parentDir=${parents}`;
+ console.log(url);
+ $.get(url, (data) => {
+ $(`#dir_list${version_name}`).empty();
+ renderDir(path, data, version_name);
+ if (init === "init") {
+ $(`input[name=model${version_name}]`).val("");
+ $(`input[name=modelback${version_name}]`).val(version_name);
+ $(`#file_breadcrumb${version_name}`).empty();
+ let htmlBread = "";
+ if (version_name) {
+ htmlBread += `${version_name}
`;
+ } else {
+ htmlBread += `result
`;
+ }
+ htmlBread += " /
";
+ $(`#file_breadcrumb${version_name}`).append(htmlBread);
+ } else {
+ renderBrend(path, version_name, parents, filename, init);
+ }
+ }).fail(function (err) {
+ console.log(err, version_name);
+ });
+ });
+ function renderSize(value) {
+ if (null == value || value == "") {
+ return "0 Bytes";
+ }
+ var unitArr = new Array(
+ "Bytes",
+ "KB",
+ "MB",
+ "GB",
+ "TB",
+ "PB",
+ "EB",
+ "ZB",
+ "YB"
+ );
+ var index = 0;
+ var srcsize = parseFloat(value);
+ index = Math.floor(Math.log(srcsize) / Math.log(1024));
+ var size = srcsize / Math.pow(1024, index);
+ size = size.toFixed(0); //保留的小数位数
+ return size + unitArr[index];
+ }
+ function renderBrend(path, version_name, parents, filename, init) {
+ if (init == "folder") {
+ let htmlBrend = "";
+ let sectionName = $(
+ `#file_breadcrumb${version_name} .active.section`
+ ).text();
+ let parents1 = $(`input[name=model${version_name}]`).val();
+ let filename1 = $(`input[name=modelback${version_name}]`).val();
+ if (parents1 === "") {
+ $(`#file_breadcrumb${version_name} .active.section`).replaceWith(
+ `${sectionName} `
+ );
+ } else {
+ $(`#file_breadcrumb${version_name} .active.section`).replaceWith(
+ `${sectionName} `
+ );
+ }
+
+ htmlBrend += `${filename}
`;
+ htmlBrend += " /
";
+ $(`#file_breadcrumb${version_name}`).append(htmlBrend);
+ $(`input[name=model${version_name}]`).val(parents);
+ $(`input[name=modelback${version_name}]`).val(filename);
+ } 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(`${filename}
`);
+ $(
+ `#file_breadcrumb${version_name} div.section:contains(${filename})`
+ ).append(" /
");
+ }
+ }
+
+ function renderDir(path, data, version_name) {
+ let html = "";
+ html += "";
+ html += "
";
+ html += "
";
+ html += "
";
+ html += "
";
+ html += "
";
+ html += "
";
+ html += "
";
+ html += "
";
+ $(`#dir_list${version_name}`).append(html);
+ }
+}
diff --git a/web_src/js/features/cloudrbanin.js b/web_src/js/features/cloudrbanin.js
index 95193a624..15cb47e97 100644
--- a/web_src/js/features/cloudrbanin.js
+++ b/web_src/js/features/cloudrbanin.js
@@ -1,335 +1,546 @@
export default async function initCloudrain() {
- let debug_button = $('.cloudbrain_debug').data('debug')
- let debug_again_button = $('.cloudbrain_debug').data('debug-again')
- let timeid = window.setInterval(loadJobStatus, 15000);
- let timeidShow = window.setInterval(loadShowJobStatus, 15000);
- $(document).ready(loadJobStatus);
- $(document).ready(loadShowJobStatus);
- function loadJobStatus() {
- $(".job-status").each((index, job) => {
- const ID = job.dataset.jobid;
- const repoPath = job.dataset.repopath;
- // const computeResource = job.dataset.resource
- const versionname = job.dataset.version
- 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']
- if (finalState.includes(status_text)) {
- return
- }
- // const diffResource = computeResource == "NPU" ? 'modelarts/notebook' : 'cloudbrain'
- $.get(`/api/v1/repos/${repoPath}/${ID}?version_name=${versionname}`, (data) => {
- const ID = data.ID || data.JobID
- const status = data.JobStatus
- const duration = data.JobDuration
- $('#duration-' + ID).text(duration)
- if (status != status_text) {
- $('#' + ID + '-icon').removeClass().addClass(status)
- $('#' + ID + '-text').text(status)
- finalState.includes(status) && $('#' + ID + '-stop').removeClass('blue').addClass('disabled')
- }
- if (status === "RUNNING") {
- $('#ai-debug-' + ID).removeClass('disabled').addClass('blue').text(debug_button).css("margin", "0 1rem")
- $('#model-image-' + ID).removeClass('disabled').addClass('blue')
- }
- if (status !== "RUNNING") {
- // $('#model-debug-'+ID).removeClass('blue')
- // $('#model-debug-'+ID).addClass('disabled')
- $('#model-image-' + ID).removeClass('blue').addClass('disabled')
- }
- if (["CREATING", "STOPPING", "WAITING", "STARTING"].includes(status)) {
- $('#ai-debug-' + ID).removeClass('blue').addClass('disabled')
- }
- if (['STOPPED', 'FAILED', 'START_FAILED', 'CREATE_FAILED', 'SUCCEEDED'].includes(status)) {
- $('#ai-debug-' + ID).removeClass('disabled').addClass('blue').text(debug_again_button).css("margin", "0")
- }
- if (["RUNNING", "WAITING"].includes(status)) {
- $('#ai-stop-' + ID).removeClass('disabled').addClass('blue')
- }
- if (["CREATING", "STOPPING", "STARTING", "STOPPED", "FAILED", "START_FAILED", "SUCCEEDED", "COMPLETED", "CREATE_FAILED"].includes(status)) {
- $('#ai-stop-' + ID).removeClass('blue').addClass('disabled')
- }
-
- if (["STOPPED", "FAILED", "START_FAILED", "KILLED", "COMPLETED", "SUCCEEDED"].includes(status)) {
- $('#ai-delete-' + ID).removeClass('disabled').addClass('blue')
- } else {
- $('#ai-delete-' + ID).removeClass('blue').addClass('disabled')
- }
- if (["COMPLETED", "SUCCEEDED"].includes(status)) {
- $('#ai-download-' + ID).removeClass('disabled').addClass('blue')
- } else {
- $('#ai-download-' + ID).removeClass('blue').addClass('disabled')
- }
- }).fail(function (err) {
- console.log(err);
- });
- });
- };
-
- function loadShowJobStatus() {
- $(".ui.accordion.border-according").each((index, job) => {
- const jobID = job.dataset.jobid;
- const repoPath = job.dataset.repopath;
- const versionname = job.dataset.version
- // ['IMAGE_FAILED','SUBMIT_FAILED','DELETE_FAILED','KILLED','COMPLETED','FAILED','CANCELED','LOST','START_FAILED']
- // if (job.textContent.trim() == 'IMAGE_FAILED' || job.textContent.trim() == 'SUBMIT_FAILED' || job.textContent.trim() == 'DELETE_FAILED'
- // || job.textContent.trim() == 'KILLED' || job.textContent.trim() == 'COMPLETED' || job.textContent.trim() == 'FAILED'
- // || job.textContent.trim() == 'CANCELED' || job.textContent.trim() == 'LOST') {
- // return
- // }
- let status = $(`#${versionname}-status-span`).text()
+ let debug_button = $(".cloudbrain_debug").data("debug");
+ let debug_again_button = $(".cloudbrain_debug").data("debug-again");
+ let timeid = window.setInterval(loadJobStatus, 15000);
+ let timeidShow = window.setInterval(loadShowJobStatus, 15000);
+ $(document).ready(loadJobStatus);
+ $(document).ready(loadShowJobStatus);
+ function loadJobStatus() {
+ $(".job-status").each((index, job) => {
+ const ID = job.dataset.jobid;
+ const repoPath = job.dataset.repopath;
+ // const computeResource = job.dataset.resource
+ const versionname = job.dataset.version;
+ 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",
+ ];
+ if (finalState.includes(status_text)) {
+ return;
+ }
+ // const diffResource = computeResource == "NPU" ? 'modelarts/notebook' : 'cloudbrain'
+ $.get(
+ `/api/v1/repos/${repoPath}/${ID}?version_name=${versionname}`,
+ (data) => {
+ const ID = data.ID || data.JobID;
+ const status = data.JobStatus;
+ const duration = data.JobDuration;
+ $("#duration-" + ID).text(duration);
+ if (status != status_text) {
+ $("#" + ID + "-icon")
+ .removeClass()
+ .addClass(status);
+ $("#" + ID + "-text").text(status);
+ finalState.includes(status) &&
+ $("#" + ID + "-stop")
+ .removeClass("blue")
+ .addClass("disabled");
+ }
+ if (status === "RUNNING") {
+ $("#ai-debug-" + ID)
+ .removeClass("disabled")
+ .addClass("blue")
+ .text(debug_button)
+ .css("margin", "0 1rem");
+ $("#model-image-" + ID)
+ .removeClass("disabled")
+ .addClass("blue");
+ }
+ if (status !== "RUNNING") {
+ // $('#model-debug-'+ID).removeClass('blue')
+ // $('#model-debug-'+ID).addClass('disabled')
+ $("#model-image-" + ID)
+ .removeClass("blue")
+ .addClass("disabled");
+ }
+ if (
+ ["CREATING", "STOPPING", "WAITING", "STARTING"].includes(status)
+ ) {
+ $("#ai-debug-" + ID)
+ .removeClass("blue")
+ .addClass("disabled");
+ }
+ if (
+ [
+ "STOPPED",
+ "FAILED",
+ "START_FAILED",
+ "CREATE_FAILED",
+ "SUCCEEDED",
+ ].includes(status)
+ ) {
+ $("#ai-debug-" + ID)
+ .removeClass("disabled")
+ .addClass("blue")
+ .text(debug_again_button)
+ .css("margin", "0");
+ }
+ if (["RUNNING", "WAITING"].includes(status)) {
+ $("#ai-stop-" + ID)
+ .removeClass("disabled")
+ .addClass("blue");
+ }
+ if (
+ [
+ "CREATING",
+ "STOPPING",
+ "STARTING",
+ "STOPPED",
+ "FAILED",
+ "START_FAILED",
+ "SUCCEEDED",
+ "COMPLETED",
+ "CREATE_FAILED",
+ ].includes(status)
+ ) {
+ $("#ai-stop-" + ID)
+ .removeClass("blue")
+ .addClass("disabled");
+ }
- if (['IMAGE_FAILED', 'SUBMIT_FAILED', 'DELETE_FAILED', 'KILLED', 'COMPLETED', 'FAILED', 'CANCELED', 'LOST', 'START_FAILED', 'SUCCEEDED', 'STOPPED'].includes(status)) {
- return
- }
- let stopArray = ["KILLED", "FAILED", "START_FAILED", "KILLING", "COMPLETED", "SUCCEEDED", "STOPPED"]
- $.get(`/api/v1/repos/${repoPath}/${jobID}?version_name=${versionname}`, (data) => {
- //$(`#${versionname}-duration-span`).text(data.JobDuration)
- $(`#${versionname}-status-span span`).text(data.JobStatus)
- $(`#${versionname}-status-span i`).attr("class", data.JobStatus)
- // detail status and duration
- //$('#'+versionname+'-duration').text(data.JobDuration)
- $('#' + versionname + '-status').text(data.JobStatus)
- if (stopArray.includes(data.JobStatus)) {
- $('#' + versionname + '-stop').addClass('disabled')
- }
- if (data.JobStatus === "COMPLETED") {
- $('#' + versionname + '-create-model').removeClass('disabled').addClass('blue')
- }
- }).fail(function (err) {
- console.log(err);
- });
- });
- };
+ if (
+ [
+ "STOPPED",
+ "FAILED",
+ "START_FAILED",
+ "KILLED",
+ "COMPLETED",
+ "SUCCEEDED",
+ ].includes(status)
+ ) {
+ $("#ai-delete-" + ID)
+ .removeClass("disabled")
+ .addClass("blue");
+ } else {
+ $("#ai-delete-" + ID)
+ .removeClass("blue")
+ .addClass("disabled");
+ }
+ }
+ ).fail(function (err) {
+ console.log(err);
+ });
+ });
+ }
+ function loadShowJobStatus() {
+ $(".ui.accordion.border-according").each((index, job) => {
+ const jobID = job.dataset.jobid;
+ const repoPath = job.dataset.repopath;
+ const versionname = job.dataset.version;
+ // ['IMAGE_FAILED','SUBMIT_FAILED','DELETE_FAILED','KILLED','COMPLETED','FAILED','CANCELED','LOST','START_FAILED']
+ // if (job.textContent.trim() == 'IMAGE_FAILED' || job.textContent.trim() == 'SUBMIT_FAILED' || job.textContent.trim() == 'DELETE_FAILED'
+ // || job.textContent.trim() == 'KILLED' || job.textContent.trim() == 'COMPLETED' || job.textContent.trim() == 'FAILED'
+ // || job.textContent.trim() == 'CANCELED' || job.textContent.trim() == 'LOST') {
+ // return
+ // }
+ let status = $(`#${versionname}-status-span`).text();
- function assertDelete(obj, versionName, repoPath) {
- if (obj.style.color == "rgb(204, 204, 204)") {
- return
- } else {
- const delId = obj.parentNode.id
- let flag = 1;
- $('.ui.basic.modal')
- .modal({
- onDeny: function () {
- flag = false
- },
- onApprove: function () {
- if (!versionName) {
- document.getElementById(delId).submit()
- }
- else {
- deleteVersion(versionName, repoPath)
- }
- flag = true
- },
- onHidden: function () {
- if (flag == false) {
- $('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
- }
- }
- })
- .modal('show')
- }
- }
- function deleteVersion(versionName, repoPath) {
- const url = `/api/v1/repos/${repoPath}`
- $.post(url, { version_name: versionName }, (data) => {
- if (data.StatusOK === 0) {
- location.reload()
- }
- }).fail(function (err) {
- console.log(err);
- });
- }
- $('.ui.basic.ai_delete').click(function () {
- const repoPath = this.dataset.repopath
- const versionName = this.dataset.version
- if (repoPath && versionName) {
- assertDelete(this, versionName, repoPath)
+ if (
+ [
+ "IMAGE_FAILED",
+ "SUBMIT_FAILED",
+ "DELETE_FAILED",
+ "KILLED",
+ "COMPLETED",
+ "FAILED",
+ "CANCELED",
+ "LOST",
+ "START_FAILED",
+ "SUCCEEDED",
+ "STOPPED",
+ ].includes(status)
+ ) {
+ return;
+ }
+ let stopArray = [
+ "KILLED",
+ "FAILED",
+ "START_FAILED",
+ "KILLING",
+ "COMPLETED",
+ "SUCCEEDED",
+ "STOPPED",
+ ];
+ $.get(
+ `/api/v1/repos/${repoPath}/${jobID}?version_name=${versionname}`,
+ (data) => {
+ $(`#${versionname}-duration-span`).text(data.JobDuration);
+ $(`#${versionname}-status-span span`).text(data.JobStatus);
+ $(`#${versionname}-status-span i`).attr("class", data.JobStatus);
+ // detail status and duration
+ $("#" + versionname + "-duration").text(data.JobDuration);
+ $("#" + versionname + "-status").text(data.JobStatus);
+ if (stopArray.includes(data.JobStatus)) {
+ $("#" + versionname + "-stop").addClass("disabled");
+ }
+ if (data.JobStatus === "COMPLETED") {
+ $("#" + versionname + "-create-model")
+ .removeClass("disabled")
+ .addClass("blue");
+ }
}
- else {
- assertDelete(this)
- }
- })
- function stopDebug(ID, stopUrl) {
- $.ajax({
- type: "POST",
- url: stopUrl,
- data: $('#stopForm-' + ID).serialize(),
- success: function (res) {
- if (res.result_code === "0") {
- $('#' + ID + '-icon').removeClass().addClass(res.status)
- $('#' + ID + '-text').text(res.status)
- if (res.status === "STOPPED") {
- $('#ai-debug-' + ID).removeClass('disabled').addClass('blue').text(debug_again_button).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 {
- $('#ai-debug-' + ID).removeClass('blue').addClass('disabled')
- $('#ai-stop-' + ID).removeClass('blue').addClass('disabled')
- }
-
- } else {
- $('.alert').html(res.error_msg).removeClass('alert-success').addClass('alert-danger').show().delay(2000).fadeOut();
- }
- },
- error: function (res) {
- console.log(res)
+ ).fail(function (err) {
+ console.log(err);
+ });
+ });
+ }
+ function assertDelete(obj, versionName, repoPath) {
+ if (obj.style.color == "rgb(204, 204, 204)") {
+ return;
+ } else {
+ const delId = obj.parentNode.id;
+ let flag = 1;
+ $(".ui.basic.modal")
+ .modal({
+ onDeny: function () {
+ flag = false;
+ },
+ onApprove: function () {
+ if (!versionName) {
+ document.getElementById(delId).submit();
+ } else {
+ deleteVersion(versionName, repoPath);
}
+ flag = true;
+ },
+ onHidden: function () {
+ if (flag == false) {
+ $(".alert")
+ .html("您已取消操作")
+ .removeClass("alert-success")
+ .addClass("alert-danger")
+ .show()
+ .delay(1500)
+ .fadeOut();
+ }
+ },
})
+ .modal("show");
}
- $('.ui.basic.ai_stop').click(function () {
- const ID = this.dataset.jobid
- const repoPath = this.dataset.repopath
- stopDebug(ID, repoPath)
- })
-
- function stopVersion(version_name, ID, repoPath) {
- const url = `/api/v1/repos/${repoPath}/${ID}/stop_version`
- $.post(url, { version_name: version_name }, (data) => {
- if (data.StatusOK === 0) {
- $('#ai-stop-' + ID).removeClass('blue')
- $('#ai-stop-' + ID).addClass('disabled')
- refreshStatus(version_name, ID, repoPath)
- }
- }).fail(function (err) {
- console.log(err);
- });
+ }
+ function deleteVersion(versionName, repoPath) {
+ const url = `/api/v1/repos/${repoPath}`;
+ $.post(url, { version_name: versionName }, (data) => {
+ if (data.StatusOK === 0 || data.Code === 0) {
+ location.reload();
+ }
+ }).fail(function (err) {
+ console.log(err);
+ });
+ }
+ $(".ui.basic.ai_delete").click(function () {
+ const repoPath = this.dataset.repopath;
+ const versionName = this.dataset.version;
+ if (repoPath && versionName) {
+ assertDelete(this, versionName, repoPath);
+ } else {
+ assertDelete(this);
}
- function refreshStatus(version_name, ID, repoPath) {
+ });
+ function stopDebug(ID, stopUrl) {
+ $.ajax({
+ type: "POST",
+ url: stopUrl,
+ data: $("#stopForm-" + ID).serialize(),
+ success: function (res) {
+ if (res.result_code === "0") {
+ $("#" + ID + "-icon")
+ .removeClass()
+ .addClass(res.status);
+ $("#" + ID + "-text").text(res.status);
+ if (res.status === "STOPPED") {
+ $("#ai-debug-" + ID)
+ .removeClass("disabled")
+ .addClass("blue")
+ .text(debug_again_button)
+ .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 {
+ $("#ai-debug-" + ID)
+ .removeClass("blue")
+ .addClass("disabled");
+ $("#ai-stop-" + ID)
+ .removeClass("blue")
+ .addClass("disabled");
+ }
+ } else {
+ $(".alert")
+ .html(res.error_msg)
+ .removeClass("alert-success")
+ .addClass("alert-danger")
+ .show()
+ .delay(2000)
+ .fadeOut();
+ }
+ },
+ error: function (res) {
+ console.log(res);
+ },
+ });
+ }
+ $(".ui.basic.ai_stop").click(function () {
+ const ID = this.dataset.jobid;
+ const repoPath = this.dataset.repopath;
+ stopDebug(ID, repoPath);
+ });
- const url = `/api/v1/repos/${repoPath}/${ID}/?version_name${version_name}`
- $.get(url, (data) => {
- $(`#${ID}-icon`).attr("class", data.JobStatus)
- // detail status and duration
- $(`#${ID}-text`).text(data.JobStatus)
- if (["STOPPED", "FAILED", "START_FAILED", "KILLED", "COMPLETED", "SUCCEEDED"].includes(data.JobStatus)) {
- $('#ai-delete-' + ID).removeClass('disabled').addClass('blue')
- }
- }).fail(function (err) {
- console.log(err);
- });
- }
- $('.ui.basic.ai_stop_version').click(function () {
- const ID = this.dataset.jobid
- const repoPath = this.dataset.repopath
- const versionName = this.dataset.version
- stopVersion(versionName, ID, repoPath)
- })
- function getModelInfo(repoPath, modelName, versionName, jobName) {
- $.get(`${repoPath}/modelmanage/show_model_info_api?name=${modelName}`, (data) => {
- if (data.length === 0) {
- $(`#${jobName}`).popup('toggle')
+ function stopVersion(version_name, ID, repoPath) {
+ const url = `/api/v1/repos/${repoPath}/${ID}/stop_version`;
+ $.post(url, { version_name: version_name }, (data) => {
+ if (data.StatusOK === 0) {
+ $("#ai-stop-" + ID).removeClass("blue");
+ $("#ai-stop-" + ID).addClass("disabled");
+ refreshStatus(version_name, ID, repoPath);
+ }
+ }).fail(function (err) {
+ 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);
+ e.stopPropagation();
+ });
+
+ function refreshStatusShow(version_name, ID, repoPath) {
+ $.get(
+ `/api/v1/repos/${repoPath}/${ID}?version_name=${version_name}`,
+ (data) => {
+ $(`#${version_name}-status-span span`).text(data.JobStatus);
+ $(`#${version_name}-status-span i`).attr("class", data.JobStatus);
+ $(`#${version_name}-duration-span`).text(data.JobDuration);
+ $("#" + versionname + "-duration").text(data.JobDuration);
+ $("#" + versionname + "-status").text(data.JobStatus);
+ }
+ ).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) => {
+ $(`#${ID}-icon`).attr("class", data.JobStatus);
+ // detail status and duration
+ $(`#${ID}-text`).text(data.JobStatus);
+ if (
+ [
+ "STOPPED",
+ "FAILED",
+ "START_FAILED",
+ "KILLED",
+ "COMPLETED",
+ "SUCCEEDED",
+ ].includes(data.JobStatus)
+ ) {
+ $("#ai-delete-" + ID)
+ .removeClass("disabled")
+ .addClass("blue");
+ }
+ }).fail(function (err) {
+ console.log(err);
+ });
+ }
+ $(".ui.basic.ai_stop_version").click(function () {
+ const ID = this.dataset.jobid;
+ const repoPath = this.dataset.repopath;
+ const versionName = this.dataset.version;
+ stopVersion(versionName, ID, repoPath);
+ });
+ function getModelInfo(repoPath, modelName, versionName, jobName) {
+ $.get(
+ `${repoPath}/modelmanage/show_model_info_api?name=${modelName}`,
+ (data) => {
+ if (data.length === 0) {
+ $(`#${jobName}`).popup("toggle");
+ } else {
+ let versionData = data.filter((item) => {
+ return item.Version === versionName;
+ });
+ if (versionData.length == 0) {
+ $(`#${jobName}`).popup("toggle");
+ } else {
+ location.href = `${repoPath}/modelmanage/show_model_info?name=${modelName}`;
+ }
+ }
+ }
+ );
+ }
+ $(".goto_modelmanage").click(function () {
+ const repoPath = this.dataset.repopath;
+ const modelName = this.dataset.modelname;
+ const versionName = this.dataset.version;
+ const jobName = this.dataset.jobname;
+ getModelInfo(repoPath, modelName, versionName, jobName);
+ });
+ function debugAgain(ID, debugUrl, redirect_to) {
+ if ($("#" + ID + "-text").text() === "RUNNING") {
+ window.open(debugUrl + "debug");
+ } else {
+ $.ajax({
+ type: "POST",
+ url: debugUrl + "restart?redirect_to=" + redirect_to,
+ data: $("#debugAgainForm-" + ID).serialize(),
+ success: function (res) {
+ if (res["WechatRedirectUrl"]) {
+ window.location.href = res["WechatRedirectUrl"];
+ } else if (res.result_code === "0") {
+ if (res.id !== ID) {
+ location.reload();
} else {
- let versionData = data.filter((item) => {
- return item.Version === versionName
- })
- if (versionData.length == 0) {
- $(`#${jobName}`).popup('toggle')
- }
- else {
- location.href = `${repoPath}/modelmanage/show_model_info?name=${modelName}`
- }
+ $("#" + 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(debug_button)
+ .css("margin", "0 1rem");
}
- })
+ } else {
+ $(".alert")
+ .html(res.error_msg)
+ .removeClass("alert-success")
+ .addClass("alert-danger")
+ .show()
+ .delay(2000)
+ .fadeOut();
+ }
+ },
+ error: function (res) {
+ console.log(res);
+ },
+ });
}
- $('.goto_modelmanage').click(function () {
- const repoPath = this.dataset.repopath
- const modelName = this.dataset.modelname
- const versionName = this.dataset.version
- const jobName = this.dataset.jobname
- getModelInfo(repoPath, modelName, versionName, jobName)
- })
- function debugAgain(ID, debugUrl, redirect_to) {
- if ($('#' + ID + '-text').text() === "RUNNING") {
- window.open(debugUrl + 'debug')
- } else {
- $.ajax({
- type: "POST",
- url: debugUrl + 'restart?redirect_to=' + redirect_to,
- data: $('#debugAgainForm-' + ID).serialize(),
- success: function (res) {
- if (res['WechatRedirectUrl']) {
- window.location.href = res['WechatRedirectUrl']
- }
- else if (res.result_code === "0") {
- if (res.id !== ID) {
- location.reload()
- } else {
- $('#' + 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(debug_button).css("margin", "0 1rem")
- }
- } else {
- $('.alert').html(res.error_msg).removeClass('alert-success').addClass('alert-danger').show().delay(2000).fadeOut();
- }
- },
- error: function (res) {
- console.log(res)
- }
- })
- }
+ }
+ $(".ui.basic.ai_debug").click(function () {
+ const ID = this.dataset.jobid;
+ const repoPath = this.dataset.repopath;
+ const redirect_to = this.dataset.linkpath;
+ debugAgain(ID, repoPath, redirect_to);
+ });
+
+ function setWaitNums() {
+ console.log($(".cloudbrain-type"));
+ if ($(".cloudbrain-type").length === 0 && $(".gpu-type").length === 0) {
+ return;
}
- $('.ui.basic.ai_debug').click(function () {
- const ID = this.dataset.jobid
- const repoPath = this.dataset.repopath
- const redirect_to = this.dataset.linkpath
- debugAgain(ID, repoPath, redirect_to)
- })
+ let waitNums = $(".cloudbrain-type").data("queue").split("map")[1];
+ let test = new Map();
+ let waitNumsArray = waitNums.split(" ");
+ waitNumsArray.forEach((element, index) => {
+ if (index === 0) {
+ test.set(element.slice(1, -2), parseInt(element.slice(-1)));
+ } else if (index === waitNumsArray.length - 1) {
+ test.set(element.slice(0, -3), parseInt(element.slice(-2, -1)));
+ } else {
+ test.set(element.slice(0, -2), parseInt(element.slice(-1)));
+ }
+ });
+ $(".ui.search.dropdown.gpu-type").dropdown({
+ onChange: function (value, text, $selectedItem) {
+ let gpuTypeNums = test.get(value);
+ let gpuTypeNumString =
+ $(".cloudbrain-type").data("queue-start") +
+ " " +
+ gpuTypeNums +
+ " " +
+ $(".cloudbrain-type").data("queue-end");
+ $("#gpu-nums").text(gpuTypeNumString);
+ },
+ });
+ }
+ setWaitNums();
}
function userSearchControll() {
- if ($('#userCloud').length === 0) {
- return
+ if ($("#userCloud").length === 0) {
+ return;
+ }
+ const params = new URLSearchParams(window.location.search);
+ let jobType;
+ if ($(".cloudbrain_debug").length === 1) {
+ if (!params.get("jobType")) {
+ jobType = $(".cloudbrain_debug").data("allTask");
+ } else {
+ if (params.get("jobType") === "DEBUG") {
+ jobType = $(".cloudbrain_debug").data("debug-task");
+ } else if (params.get("jobType") === "TRAIN") {
+ jobType = $(".cloudbrain_debug").data("train-task");
+ } else if (params.get("jobType") === "INFERENCE") {
+ jobType = $(".cloudbrain_debug").data("inference-task");
+ } else {
+ jobType = $(".cloudbrain_debug").data("benchmark-task");
+ }
}
- const params = new URLSearchParams(window.location.search)
- let jobType
- if ($('.cloudbrain_debug').length === 1) {
- if (!params.get('jobType')) {
- jobType = $('.cloudbrain_debug').data('allTask')
- } else {
- if (params.get('jobType') === 'DEBUG') {
- jobType = $('.cloudbrain_debug').data('debug-task')
- } else if (params.get('jobType') === 'TRAIN') {
- jobType = $('.cloudbrain_debug').data('train-task')
- }
- else if (params.get('jobType') === 'INFERENCE') {
- jobType = $('.cloudbrain_debug').data('inference-task')
- }
- else {
- jobType = $('.cloudbrain_debug').data('benchmark-task')
- }
- }
- }
- let listType = !params.get('listType') ? $('.cloudbrain_debug').data('all-compute') : params.get('listType')
- let jobStatus = !params.get('jobStatus') ? $('.cloudbrain_debug').data('all-status') : params.get('jobStatus').toUpperCase()
- const dropdownValueArray = [jobType, listType, jobStatus]
- $('#userCloud .default.text ').each(function (index, e) {
- $(e).text(dropdownValueArray[index])
- })
+ }
+ let listType = !params.get("listType")
+ ? $(".cloudbrain_debug").data("all-compute")
+ : params.get("listType");
+ let jobStatus = !params.get("jobStatus")
+ ? $(".cloudbrain_debug").data("all-status")
+ : params.get("jobStatus").toUpperCase();
+ const dropdownValueArray = [jobType, listType, jobStatus];
+ $("#userCloud .default.text ").each(function (index, e) {
+ $(e).text(dropdownValueArray[index]);
+ });
}
function AdaminSearchControll() {
- if ($('#adminCloud').length === 0) {
- return
- }
- const params = new URLSearchParams(window.location.search)
- let jobType = !params.get('jobType') ? $('.cloudbrain_debug').data('all-task') : params.get('jobType')
- let listType = !params.get('listType') ? $('.cloudbrain_debug').data('all-compute') : params.get('listType')
- let jobStatus = !params.get('jobStatus') ? $('.cloudbrain_debug').data('all-status') : params.get('jobStatus').toUpperCase()
- const dropdownValueArray = [jobType, listType, jobStatus]
- $('#adminCloud .default.text ').each(function (index, e) {
- $(e).text(dropdownValueArray[index])
- })
+ if ($("#adminCloud").length === 0) {
+ return;
+ }
+ const params = new URLSearchParams(window.location.search);
+ let jobType = !params.get("jobType")
+ ? $(".cloudbrain_debug").data("all-task")
+ : params.get("jobType");
+ let listType = !params.get("listType")
+ ? $(".cloudbrain_debug").data("all-compute")
+ : params.get("listType");
+ let jobStatus = !params.get("jobStatus")
+ ? $(".cloudbrain_debug").data("all-status")
+ : params.get("jobStatus").toUpperCase();
+ const dropdownValueArray = [jobType, listType, jobStatus];
+ $("#adminCloud .default.text ").each(function (index, e) {
+ $(e).text(dropdownValueArray[index]);
+ });
}
-userSearchControll()
-AdaminSearchControll()
-
-
-
+userSearchControll();
+AdaminSearchControll();
diff --git a/web_src/js/index.js b/web_src/js/index.js
index 754d6ca76..53dba8a88 100755
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -43,6 +43,7 @@ import Contributors from "./components/Contributors.vue";
import Model from "./components/Model.vue";
import WxAutorize from "./components/WxAutorize.vue";
import initCloudrain from "./features/cloudrbanin.js";
+import initCloudrainSow from "./features/cloudbrainShow.js";
import initImage from "./features/images.js";
import selectDataset from "./components/dataset/selectDataset.vue";
// import $ from 'jquery.js'
@@ -2917,6 +2918,7 @@ $(document).ready(async () => {
initTribute();
initDropDown();
initCloudrain();
+ initCloudrainSow();
initImage();
initContextMenu();
@@ -3711,9 +3713,9 @@ function initVueDataset() {
if (!el) {
return;
}
- let link = $('#square-link').data('link')
- let repolink = $('.dataset-repolink').data('repolink')
- let datasetType = $('.dataset-repolink').data('dataset-type')
+ let link = $("#square-link").data("link");
+ let repolink = $(".dataset-repolink").data("repolink");
+ let datasetType = $(".dataset-repolink").data("dataset-type");
const clearBtn = document.getElementsByClassName("clear_dataset_value");
const params = new URLSearchParams(location.search);
for (let i = 0; i < clearBtn.length; i++) {
@@ -3873,10 +3875,10 @@ function initVueDataset() {
mounted() {
this.getTypeList();
- if (!!document.getElementById('dataset-repolink-init')) {
+ if (!!document.getElementById("dataset-repolink-init")) {
// this.datasetType = location.href.indexOf('cloudbrain') !== -1 ? 0 : 1
- this.datasetType = $('#dataset-repolink-init').data("dataset-type")
- this.getCurrentRepoDataset(this.repolink, this.datasetType)
+ this.datasetType = $("#dataset-repolink-init").data("dataset-type");
+ this.getCurrentRepoDataset(this.repolink, this.datasetType);
}
const params = new URLSearchParams(location.search);
@@ -3897,13 +3899,13 @@ function initVueDataset() {
this.ruleForm1 = ruleForm;
// this.getEditInit()
- this.starItems = starItems
- this.starActives = starActives
- this.taskLists = taskLists
- this.licenseLists = licenseLists
- this.descfile = dataset_file_desc
- this.repolink = repolink
- this.datasetType = datasetType
+ this.starItems = starItems;
+ this.starActives = starActives;
+ this.taskLists = taskLists;
+ this.licenseLists = licenseLists;
+ this.descfile = dataset_file_desc;
+ this.repolink = repolink;
+ this.datasetType = datasetType;
},
methods: {
copyUrl(url) {
@@ -3924,18 +3926,18 @@ function initVueDataset() {
handleCurrentChange(val) {
this.page = val;
switch (this.activeName) {
- case 'first':
- this.getCurrentRepoDataset(this.repolink, this.datasetType)
- break
- case 'second':
- this.getMyDataset(this.repolink, this.datasetType)
- break
- case 'third':
- this.getPublicDataset(this.repolink, this.datasetType)
- break
- case 'fourth':
- this.getStarDataset(this.repolink, this.datasetType)
- break
+ case "first":
+ this.getCurrentRepoDataset(this.repolink, this.datasetType);
+ break;
+ case "second":
+ this.getMyDataset(this.repolink, this.datasetType);
+ break;
+ case "third":
+ this.getPublicDataset(this.repolink, this.datasetType);
+ break;
+ case "fourth":
+ this.getStarDataset(this.repolink, this.datasetType);
+ break;
}
},
handleCheckedChange(val) {
@@ -4276,18 +4278,18 @@ function initVueDataset() {
},
refreshStatusDataset() {
switch (this.activeName) {
- case 'first':
- this.getCurrentRepoDataset(this.repolink, this.datasetType)
- break
- case 'second':
- this.getMyDataset(this.repolink, this.datasetType)
- break
- case 'third':
- this.getPublicDataset(this.repolink, this.datasetType)
- break
- case 'fourth':
- this.getStarDataset(this.repolink, this.datasetType)
- break
+ case "first":
+ this.getCurrentRepoDataset(this.repolink, this.datasetType);
+ break;
+ case "second":
+ this.getMyDataset(this.repolink, this.datasetType);
+ break;
+ case "third":
+ this.getPublicDataset(this.repolink, this.datasetType);
+ break;
+ case "fourth":
+ this.getStarDataset(this.repolink, this.datasetType);
+ break;
}
},
getCurrentRepoDataset(repoLink, type) {
@@ -4398,44 +4400,44 @@ function initVueDataset() {
},
searchDataset() {
switch (this.activeName) {
- case 'first':
- this.page = 1
- this.getCurrentRepoDataset(this.repolink, this.datasetType)
- break
- case 'second':
- this.page = 1
- this.getMyDataset(this.repolink, this.datasetType)
- break
- case 'third':
- this.page = 1
- this.getPublicDataset(this.repolink, this.datasetType)
- break
- case 'fourth':
- this.page = 1
- this.getStarDataset(this.repolink, this.datasetType)
- break
+ case "first":
+ this.page = 1;
+ this.getCurrentRepoDataset(this.repolink, this.datasetType);
+ break;
+ case "second":
+ this.page = 1;
+ this.getMyDataset(this.repolink, this.datasetType);
+ break;
+ case "third":
+ this.page = 1;
+ this.getPublicDataset(this.repolink, this.datasetType);
+ break;
+ case "fourth":
+ this.page = 1;
+ this.getStarDataset(this.repolink, this.datasetType);
+ break;
}
},
},
watch: {
searchDataItem() {
switch (this.activeName) {
- case 'first':
- this.page = 1
- this.getCurrentRepoDataset(this.repolink, this.datasetType)
- break
- case 'second':
- this.page = 1
- this.getMyDataset(this.repolink, this.datasetType)
- break
- case 'third':
- this.page = 1
- this.getPublicDataset(this.repolink, this.datasetType)
- break
- case 'fourth':
- this.page = 1
- this.getStarDataset(this.repolink, this.datasetType)
- break
+ case "first":
+ this.page = 1;
+ this.getCurrentRepoDataset(this.repolink, this.datasetType);
+ break;
+ case "second":
+ this.page = 1;
+ this.getMyDataset(this.repolink, this.datasetType);
+ break;
+ case "third":
+ this.page = 1;
+ this.getPublicDataset(this.repolink, this.datasetType);
+ break;
+ case "fourth":
+ this.page = 1;
+ this.getStarDataset(this.repolink, this.datasetType);
+ break;
}
},
},
diff --git a/web_src/less/openi.less b/web_src/less/openi.less
index 9325f6a74..0c30d1c92 100644
--- a/web_src/less/openi.less
+++ b/web_src/less/openi.less
@@ -1210,12 +1210,27 @@ i.SUCCEEDED {
max-width: 6.38px;
visibility: hidden;
}
+.label-fix-width {
+ width: 140px !important;
+ text-align: right;
+ font-family: SourceHanSansSC-medium !important;
+ color: rgba(16, 16, 16, 100) !important;
+ font-size: 14px !important;
+}
.inline.min_title.fields.required .label-fix-width:after {
margin: -0.2em 0 0 0.2em;
content: "*";
max-width: 6.38px;
visibility: hidden;
}
+
+.tooltip-wati-count {
+ display: flex;
+ align-items: center;
+ margin-left: 260px;
+ color: #f2711c;
+ margin-top: 0.5rem;
+}
#dir_list {
max-height: 500px;
overflow: auto;