diff --git a/src/api/task/index.js b/src/api/task/index.js index 79f7823..be238a7 100644 --- a/src/api/task/index.js +++ b/src/api/task/index.js @@ -30,9 +30,21 @@ const addTask = (data) => { data: data }) } + +//创建推理任务 +const stopTask = (id) => { + return request({ + url: `/tasks/${id}/stop`, + method: 'post', + data: { + operation_id:0 + } + }) +} export default { tasks, availableDevices, running, - addTask + addTask, + stopTask } diff --git a/src/utils/request.ts b/src/utils/request.ts index c88f0ef..9ffee87 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -6,7 +6,7 @@ import { TOKEN_KEY } from "@/enums/CacheEnum"; // 创建 axios 实例 const service = axios.create({ baseURL: import.meta.env.VITE_APP_BASE_API, - timeout: 50000, + timeout: 5000000, headers: { "Content-Type": "application/json;charset=utf-8" }, }); diff --git a/src/views/simulationEvaluation/addTask.vue b/src/views/simulationEvaluation/addTask.vue index e1c0d3b..caaa802 100644 --- a/src/views/simulationEvaluation/addTask.vue +++ b/src/views/simulationEvaluation/addTask.vue @@ -12,11 +12,22 @@
- - - + + +
+ + 上一步 + + + 下一步 + 编译中... @@ -24,14 +35,7 @@ {{ state == 0 ? "开始推理" : "推理中..." }} - 上一步 - - - 下一步 + @@ -64,8 +68,8 @@ let info = reactive({ datas: null, taskId: 0, inferenceId: 0, - parameters:'', - latestTime:'', + parameters: '', + latestTime: '', }) //开始推理 const doStart = () => { @@ -87,10 +91,10 @@ const doAddTask = () => { model_id: modelInfo.model_id, connection_id: modelInfo.connection_id, data_set_id: info.datas.dataset_id, - task_params: info.parameters, - device_id:info.devices.device_id, - tool_params_id:info.devices.tool_params_id, - tool_id:info.devices.tool_id + task_params: info.parameters || {}, + device_id: info.devices.device_id, + tool_params_id: info.devices.tool_params_id, + tool_id: info.devices.tool_id } taskApi.addTask(postData).then(d => { info.taskId = d.data?.data?.task_id || 0; @@ -99,19 +103,26 @@ const doAddTask = () => { }; //开始推理 const startInference = (d) => { - //创建推理任务 - info.inferenceId = d.data?.data?.operation_id || 0; - if (info.inferenceId > 0) { - ElMessage.success("创建推理任务成功!"); - setTimeout(() => { - router.push({ path: "/simulationEvaluation/execution" }); - }, 1000); - } + //创建推理任务 + info.inferenceId = d.data?.data?.operation_id || 0; + if (info.inferenceId > 0) { + ElMessage.success("创建推理任务成功!"); + setTimeout(() => { + router.push({ path: "/simulationEvaluation/execution" }); + }, 1000); + } } -const step4Selection=row=>{ - info.devices=row; - state.value=3; +const step5Change = () => { + let tmp = step5.value.checkForm(); + info.datas = tmp; +} +function step3Change(data) { + info.parameters = data || ""; +} +const step4Selection = () => { + let tmp = step4.value.checkForm(); + info.devices = tmp; } const doCompile = (row) => { let tmp = row; @@ -120,19 +131,18 @@ const doCompile = (row) => { state.value = 1; step4.value.updateState(state.value); startComplie();//开始编译 - //ElMessage.success("开始编译部署!"); } else { ElMessage.error("请选择设备!"); } } //开始编译 const startComplie = () => { - let ajaxs =[ inferenceApi.doCompile({ - tool_params_id: info.devices.tool_params_id, - tool_id: info.devices.tool_id, - device_id: info.devices.device_id, - connection_id: modelInfo.connection_id - }) + let ajaxs = [inferenceApi.doCompile({ + tool_params_id: info.devices.tool_params_id, + tool_id: info.devices.tool_id, + device_id: info.devices.device_id, + connection_id: modelInfo.connection_id + }) ]; addLogs({ msg: "开始部署....", type: "info" }) request.all(ajaxs).then(d => { @@ -147,21 +157,23 @@ const startComplie = () => { }; const addLogs = msg => { - info.logs = [msg, ...info.logs]; - step4.value.updateLogs(info.logs); + if (info.logs.length == 0 || info.logs[0].msg != msg.msg) { + info.logs = [msg, ...info.logs]; + step4.value.updateLogs(info.logs); + } } //获取编译日志 const doGetComplieLogs = () => { let ajaxs = []; info.optIds.filter(d => d.state == 0).forEach(o => { ajaxs.push(logsApi.userOperation(o.id)); - ajaxs.push(logsApi.compileDeploy(o.id,info.latestTime)); + ajaxs.push(logsApi.compileDeploy(o.id, info.latestTime)); }) request.all(ajaxs).then(d => { d.forEach((it, idx) => { let msg = it.data.data; - info.latestTime=msg.update_time;//'2023-03-01T12:00:00Z';//new Date().toLocaleString(); + info.latestTime = msg.update_time;//'2023-03-01T12:00:00Z';//new Date().toLocaleString(); if (msg.operation_result) { addLogs({ msg: msg.operation_result }); info.optIds[idx].state = msg.operation_finished ? 1 : 0; @@ -180,30 +192,36 @@ const doGetComplieLogs = () => { } + const doPrev = () => { active.value--; if (active.value == 4) { state.value = 0; info.logs = []; info.optIds = []; - }else if(active.value==3){ - setTimeout(()=>{ - if(info.parameters){ + setTimeout(() => { + if (info.devices) { + step4.value.returnData(info.devices); + } + }, 400); + } else if (active.value == 3) { + setTimeout(() => { + if (info.parameters) { step3.value.returnData(info.parameters); } - },400); - }else if(active.value==2){ - setTimeout(()=>{ - if(modelInfo){ + }, 400); + } else if (active.value == 2) { + setTimeout(() => { + if (modelInfo) { step2.value.returnData(modelInfo); } - },400); - }else if(active.value==1){ - setTimeout(()=>{ - if(info.taskInfo){ + }, 400); + } else if (active.value == 1) { + setTimeout(() => { + if (info.taskInfo) { step1.value.returnData(info.taskInfo); } - },400); + }, 400); } } const doNext = () => { @@ -222,31 +240,46 @@ const doNext = () => { info.logs = []; info.optIds = []; active.value++; + setTimeout(() => { + if (info.parameters) { + step3.value.returnData(info.parameters); + } + }, 400); } else { ElMessage.error("请选择模型!"); } } else if (active.value == 3) { - let tmp = step3.value.checkForm(); - if (tmp) { - info.parameters=JSON.stringify(tmp); - active.value++; - } + active.value++; + setTimeout(() => { + if (info.devices) { + step4.value.returnData(info.devices); + } + }, 400); } else if (active.value == 4) { - let tmp=step4.value.checkForm(); - if(tmp){ + let tmp = step4.value.checkForm(); + if (tmp) { active.value++; - info.devices=tmp; + info.devices = tmp; state.value = 0; - }else{ + setTimeout(() => { + if (info.datas) { + step5.value.returnData(info.datas); + } + }, 400); + } else { ElMessage.error("请选择设备!"); } - + } else if (active.value == 5) { } else { active.value++; } } + +onMounted(() => { + window.toolCahce = {} +}) \ No newline at end of file diff --git a/src/views/simulationEvaluation/execution.vue b/src/views/simulationEvaluation/execution.vue index 6c8445f..d8c8f16 100644 --- a/src/views/simulationEvaluation/execution.vue +++ b/src/views/simulationEvaluation/execution.vue @@ -1,21 +1,24 @@