Browse Source

fix issue

tags/v1.22.11.3^2
zhoupzh 2 years ago
parent
commit
9c6a1b6e2e
4 changed files with 163 additions and 54 deletions
  1. +5
    -0
      templates/repo/home.tmpl
  2. +23
    -25
      web_src/vuepages/apis/modules/notobook.js
  3. +0
    -1
      web_src/vuepages/apis/service.js
  4. +135
    -28
      web_src/vuepages/pages/notebook/debug/index.vue

+ 5
- 0
templates/repo/home.tmpl View File

@@ -402,6 +402,7 @@

</div>
<div id="__vue-root"></div>
<div id="__vue-self-data" data-branch="{{.BranchName}}" data-owner="{{.Repository.OwnerName}}" data-project="{{.Repository.Name}}" data-file="{{.TreePath}}"></div>
</div>

<script type="text/javascript">
@@ -410,6 +411,10 @@
// $("#contributorInfo > a:nth-child(n+25)").show();
// });
// });
console.log({{.Repository}})
console.log({{ .BaseRepo}})

console.log({{.TreePath}})
</script>
<script src="{{StaticUrlPrefix}}/js/vp-notebook-debug.js?v={{MD5 AppVer}}"></script>
{{template "base/footer" .}}

+ 23
- 25
web_src/vuepages/apis/modules/notobook.js View File

@@ -1,41 +1,39 @@
import service from '../service';
import service from "../service";

// Notebook新建页面需要的信息
export const getFileNotebook = () => {
return service({
url: '/api/v1/file_notebook',
method: 'get',
url: "/api/v1/file_notebook",
method: "get",
params: {},
});
}
};

// 算力积分获取、消耗明细
// operate-INCREASE 表示获取明细 DECREASE表示消耗明细, page-当前页, pageSize-每页条数
export const getPointList = (params) => {
// Notebook新建调试任务
// type, file, branch_name, owner_name, project_name
export const createNotebook = (data) => {
return service({
url: '/reward/point/record/list',
method: 'get',
params,
url: "/api/v1/file_notebook/create",
method: "post",
data,
params: {},
});
}
};

// 管理员充值、扣减用户积分
// TargetUserId, OperateType-INCREASE,DECREASE, Amount, Remark, RewardType-POINT
export const setPointOperate = (data) => {
// Notebook新建页面需要的信息
export const getCb1Notebook = (jobid) => {
return service({
url: '/operation/reward/point/account/operate',
method: 'post',
data,
params: {}
url: `/api/v1/cloudbrain/${jobid}`,
method: "get",
params: {},
});
}
};

// 算力积分页面
export const getPoint = () => {
// Notebook新建页面需要的信息
export const getCb2Notebook = (jobid) => {
return service({
url: '/reward/point',
method: 'get',
url: `/api/v1/modelarts/notebook/${jobid}`,
method: "get",
params: {},
data: {},
});
}
};

+ 0
- 1
web_src/vuepages/apis/service.js View File

@@ -2,7 +2,6 @@ import axios from 'axios';

const service = axios.create({
baseURL: '/',
timeout: 20000,
});

service.interceptors.request.use((config) => {


+ 135
- 28
web_src/vuepages/pages/notebook/debug/index.vue View File

@@ -5,12 +5,13 @@
:visible.sync="dialogVisible"
width="50%"
:close-on-click-modal="false"
@closed="handleClose"
>
<div class="wrapper">
<div
class="three-resource-type"
:class="{ active: selectIndex == 0 }"
@click="selectResource(0)"
@click="selectResource(0,'waitCountGpu')"
>
<div class="resource-child-node">
<div class="resource-type-icon background-C">
@@ -19,14 +20,14 @@
<div class="resource-type-detail">
<div class="detail-title"><span>CPU 环境</span></div>
<div class="detail-spec">
<span>规格:CPU: 4,内存: 32GB,共享内存: 16GB</span>
<span>{{cpuSpec}}</span>
</div>
<div class="detail-spec">
<span>镜像: ubuntuxx. xx-py37-torch1.9.1</span>
<span>镜像:{{notebookInfo.imageCpuDescription}}</span>
</div>
</div>
<div class="resource-select">
<i v-if="selectIndex===0" :class="[slideActive ?'slide-in-top':'slide-in-bottom']" class="ri-checkbox-circle-line green"></i>
<i v-if="selectIndex===0" :class="{'slide-in-bottom': !slideActive && !initSelect }" class="ri-checkbox-circle-line green"></i>
<i
class="ri-checkbox-blank-circle-line gray"
:class="{'fade-out':selectIndex===0}"
@@ -37,23 +38,24 @@
<div
class="three-resource-type"
:class="{ active: selectIndex == 1 }"
@click="selectResource(1)"
@click="selectResource(1,'waitCountGpu')"
>
<div class="resource-child-node">
<div class="resource-type-icon background-N">
<span class="text">N</span>
<div class="resource-type-icon background-G">
<span class="text">G</span>
</div>
<div class="resource-type-detail">
<div class="detail-title"><span>CPU 环境</span></div>
<div class="detail-title"><span>GPU 环境</span></div>
<div class="detail-spec">
<span>规格:CPU: 4,内存: 32GB,共享内存: 16GB</span>
<span>{{gpuSpec}}</span>
</div>
<div class="detail-spec">
<span>镜像: ubuntuxx. xx-py37-torch1.9.1</span>
<span>镜像:{{notebookInfo.imageGpuDescription}}</span>
</div>
</div>
<div class="resource-select">
<i v-if="selectIndex===1" :class="[slideActive ?'slide-in-top':'slide-in-bottom']" class="ri-checkbox-circle-line green"></i>
<i v-if="selectIndex===1 && !initSelect" :class="[slideActive && !initSelect ?'slide-in-top':'slide-in-bottom']" class="ri-checkbox-circle-line green"></i>
<i v-if="selectIndex===1 && initSelect" class="ri-checkbox-circle-line green"></i>
<i
class="ri-checkbox-blank-circle-line gray"
:class="{'fade-out':selectIndex===1}"
@@ -64,23 +66,23 @@
<div
class="three-resource-type"
:class="{ active: selectIndex == 2 }"
@click="selectResource(2)"
@click="selectResource(2,'waitCountNpu')"
>
<div class="resource-child-node">
<div class="resource-type-icon background-G">
<span class="text">G</span>
<div class="resource-type-icon background-N">
<span class="text">N</span>
</div>
<div class="resource-type-detail">
<div class="detail-title"><span>CPU 环境</span></div>
<div class="detail-title"><span>NPU 环境</span></div>
<div class="detail-spec">
<span>规格:CPU: 4,内存: 32GB,共享内存: 16GB</span>
<span>{{npuSpec}}</span>
</div>
<div class="detail-spec">
<span>镜像: ubuntuxx. xx-py37-torch1.9.1</span>
<span>镜像:{{notebookInfo.imageCpuDescription}}</span>
</div>
</div>
<div class="resource-select">
<i v-if="selectIndex===2" :class="[slideActive ?'slide-in-top':'slide-in-bottom']" class="ri-checkbox-circle-line green"></i>
<i v-if="selectIndex===2" :class="{'slide-in-top': slideActive && !initSelect}" class="ri-checkbox-circle-line green"></i>
<i
class="ri-checkbox-blank-circle-line gray"
:class="{'fade-out':selectIndex===2}"
@@ -89,8 +91,26 @@
</div>
</div>
<div class="resource-footer">
<div class="resource-operate">
<button class="ui green button">新建任务</button>
<div class="resource-operate" v-if="selectIndex==0">
<button v-if="btnStatus[0]===0" class="ui green small button" @click="createTask(0)"></i>新建任务1</button>
<button v-else-if="btnStatus[0]===1"class="ui disabled small button" style="background-color: #888;"><i class="loading spinner icon" style="color: #fff;"></i>新建任务</button>
<button v-else>aaaa</button>
<span>当前有个<span style="color: red;">{{waitCount}}</span>任务在排队</span>
</div>
<div class="resource-operate" v-if="selectIndex==1">
<button v-if="btnStatus[1]===0" class="ui green small button" @click="createTask(1)"></i>新建任务2</button>
<button v-else-if="btnStatus[1]===1"class="ui disabled small button" style="background-color: #888;"><i class="loading spinner icon" style="color: #fff;"></i>新建任务</button>
<button v-else>aaaa</button>
<span>当前有个<span style="color: red;">{{waitCount}}</span>任务在排队</span>
</div>
<div class="resource-operate" v-if="selectIndex==2">
<button v-if="btnStatus[2]===0" class="ui green small button" @click="createTask(2)"></i>新建任务3</button>
<button v-else-if="btnStatus[2]===1"class="ui disabled small button" style="background-color: #888;"><i class="loading spinner icon" style="color: #fff;"></i>新建任务</button>
<div v-else>
<button class="ui small button" style="background-color: #1684fc;">调试</button>
<button class="ui small button">停止</button>
</div>
<span>当前有个<span style="color: red;">{{waitCount}}</span>任务在排队</span>
</div>
</div>
</div>
@@ -98,24 +118,35 @@
</div>
</template>
<script>
import { getFileNotebook } from "~/apis/modules/notobook";
import { getFileNotebook,createNotebook,getCb1Notebook,getCb2Notebook } from "~/apis/modules/notobook";
let timerCb1,timerCb2
export default {
data() {
return {
dialogVisible: false,
selectIndex: 0,
slideActive:true,
initSelect:true,
notebookInfo:{specCpu:{acc_cards_num:0},specGpu:{acc_cards_num:0},specNpu:{acc_cards_num:0}},
waitCount:0,
fileInfo:{
file:'',
branch_name:'',
owner_name:'',
project_name:'',
},
btnStatus:{0:0,1:0,2:0},
firtstStatus:0,
secondStatus:0,
thirdStatus:0,
};
},
methods: {
handleClose(done) {
this.$confirm("确认关闭?")
.then((_) => {
done();
})
.catch((_) => {});
console.log("close")
this.initSelect = true
},
selectResource(index) {
selectResource(index,type) {
if(index==this.selectIndex){
return
}
@@ -125,17 +156,92 @@ export default {
this.slideActive = false
}
this.selectIndex = index;
this.initSelect = false
this.waitCount += this.notebookInfo[type] +1
},
getNotebookInfo(){
getFileNotebook().then((res)=>{
console.log(res)
if(res.data.code==0){
this.notebookInfo = res.data
this.waitCount = res.data.waitCountGpu
}else{
console.log(res.data.message)
}
}).catch((err)=>{
console.log(err)
})
},
getCb1NotebookInfo(id){
getCb1Notebook(id).then((res)=>{
console.log(res)
})
},
getCb2NotebookInfo(id){
getCb2Notebook(id).then((res)=>{
console.log(res)
})
},
createTask(index){
this.btnStatus[index]=1
const data = {type:index,...this.fileInfo}
createNotebook(data).then((res)=>{
console.log("=========",res)
if(res.data.code===0 && res.status===200){
// this.btnStatus[index]=2
if(index===2){
timerCb2 = setInterval(() => {
setTimeout(this.getCb2NotebookInfo(res.data.message), 0)
}, 3000)
}else{
timerCb1 = setInterval(() => {
setTimeout(this.getCb1NotebookInfo(res.data.message), 0)
}, 3000)
}
}else if(res.data.code===1 && res.status===403){
this.btnStatus[index]=0
}else{
this.btnStatus[index]=0
}
}).catch((err)=>{
this.btnStatus[index]=0
console.log(err)
})
}
},
computed: {
cpuSpec(){
return `规格:GPU: ${this.notebookInfo.specCpu.acc_cards_num}*${this.notebookInfo.specCpu.acc_card_type},
CPU: ${this.notebookInfo.specCpu.cpu_cores}, 显存: ${this.notebookInfo.specCpu.gpu_mem_gi_b}GB,
内存: ${this.notebookInfo.specCpu.mem_gi_b}GB, 共享内存: ${this.notebookInfo.specCpu.share_mem_gi_b}GB`
},
npuSpec(){
return `规格:NPU: ${this.notebookInfo.specNpu.acc_cards_num}*${this.notebookInfo.specNpu.acc_card_type},
CPU: ${this.notebookInfo.specNpu.cpu_cores}, 显存: ${this.notebookInfo.specNpu.gpu_mem_gi_b}GB,
内存: ${this.notebookInfo.specNpu.mem_gi_b}GB, 共享内存: ${this.notebookInfo.specNpu.share_mem_gi_b}GB`
},
gpuSpec(){
return `规格:NPU: ${this.notebookInfo.specGpu.acc_cards_num}*${this.notebookInfo.specGpu.acc_card_type},
CPU: ${this.notebookInfo.specGpu.cpu_cores}, 显存: ${this.notebookInfo.specGpu.gpu_mem_gi_b}GB,
内存: ${this.notebookInfo.specGpu.mem_gi_b}GB, 共享内存: ${this.notebookInfo.specGpu.share_mem_gi_b}GB`
}
},
beforeDestroy() {
clearInterval(timerCb1)
clearInterval(timerCb2)
},
mounted() {
this.getNotebookInfo()
// this.dialogVisible = true
console.log("-------------");
console.log("-----------aaaaa--");
const selfData = document.querySelector('#__vue-self-data')
this.fileInfo.file = selfData.getAttribute('data-file')
this.fileInfo.branch_name = selfData.getAttribute('data-branch')
this.fileInfo.owner_name = selfData.getAttribute('data-owner')
this.fileInfo.project_name = selfData.getAttribute('data-project')
console.log(this.fileInfo)
let that = this;
document
.querySelector("#notebook-debug")
@@ -284,6 +390,7 @@ export default {
align-items: center;
.resource-operate {
display: flex;
align-items: center;
}
}
.slide-in-top {


Loading…
Cancel
Save