From fddb63d2937410ee7022f7109eb9e15aa85ba4d6 Mon Sep 17 00:00:00 2001 From: zhaowei Date: Thu, 5 Jun 2025 09:27:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B5=81=E6=B0=B4=E7=BA=BF=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=8C=E5=8E=86=E5=8F=B2=E5=AE=9E=E9=AA=8C=E5=AE=9E=E4=BE=8B?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0=E5=8F=98=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/src/pages/Experiment/Info/index.jsx | 79 +++++++++++-------- .../components/ServerLog/index.less | 4 + 2 files changed, 51 insertions(+), 32 deletions(-) diff --git a/react-ui/src/pages/Experiment/Info/index.jsx b/react-ui/src/pages/Experiment/Info/index.jsx index 1e96c34c..84b0d2ef 100644 --- a/react-ui/src/pages/Experiment/Info/index.jsx +++ b/react-ui/src/pages/Experiment/Info/index.jsx @@ -3,7 +3,6 @@ import { ExperimentStatus } from '@/enums'; import { useStateRef } from '@/hooks/useStateRef'; import { useVisible } from '@/hooks/useVisible'; import { getExperimentIns } from '@/services/experiment/index.js'; -import { getWorkflowById } from '@/services/pipeline/index.js'; import themes from '@/styles/theme.less'; import { fittingString, parseJsonText } from '@/utils'; import { formatDate } from '@/utils/date'; @@ -40,7 +39,7 @@ function ExperimentText() { useEffect(() => { initGraph(); - getWorkflow(); + getExperimentInstance(); return () => { if (evtSourceRef.current) { @@ -66,38 +65,54 @@ function ExperimentText() { }, []); // 获取流水线模版 - const getWorkflow = async () => { - const [res] = await to(getWorkflowById(locationParams.workflowId)); - if (res && res.data && res.data.dag) { - try { - const dag = JSON.parse(res.data.dag); - dag.nodes.forEach((item) => { - item.in_parameters = JSON.parse(item.in_parameters); - item.out_parameters = JSON.parse(item.out_parameters); - item.control_strategy = JSON.parse(item.control_strategy); - item.imgName = item.img.slice(0, item.img.length - 4); - }); - workflowRef.current = dag; - getExperimentInstance(); - } catch (error) { - // JSON.parse 错误 - console.error('JSON.parse error: ', error); - } - } - }; + // const getWorkflow = async () => { + // const [res] = await to(getWorkflowById(locationParams.workflowId)); + // if (res && res.data && res.data.dag) { + // try { + // const dag = JSON.parse(res.data.dag); + // dag.nodes.forEach((item) => { + // item.in_parameters = JSON.parse(item.in_parameters); + // item.out_parameters = JSON.parse(item.out_parameters); + // item.control_strategy = JSON.parse(item.control_strategy); + // item.imgName = item.img.slice(0, item.img.length - 4); + // }); + // workflowRef.current = dag; + // getExperimentInstance(); + // } catch (error) { + // // JSON.parse 错误 + // console.error('JSON.parse error: ', error); + // } + // } + // }; // 获取实验实例 const getExperimentInstance = async () => { const [res] = await to(getExperimentIns(locationParams.id)); - if (res && res.data && workflowRef.current) { + if (res && res.data) { setExperimentIns(res.data); - const { status, nodes_status, argo_ins_ns, argo_ins_name, finish_time } = res.data; - const workflowData = workflowRef.current; + const { status, nodes_status, argo_ins_ns, argo_ins_name, finish_time, dag } = res.data; + if (!dag) { + return; + } + + const workflow = parseJsonText(dag); const experimentStatusObjs = parseJsonText(nodes_status); + if (!workflow || !workflow.nodes) { + return; + } + + workflow.nodes.forEach((item) => { + item.in_parameters = parseJsonText(item.in_parameters); + item.out_parameters = parseJsonText(item.out_parameters); + item.control_strategy = parseJsonText(item.control_strategy); + item.imgName = item.img.slice(0, item.img.length - 4); + }); + workflowRef.current = workflow; + if (experimentStatusObjs) { // 更新各个节点 - workflowData.nodes.forEach((item) => { - const experimentNode = experimentStatusObjs?.[item.id]; + workflow.nodes.forEach((item) => { + const experimentNode = experimentStatusObjs[item.id]; updateWorkflowNode(item, experimentNode); }); @@ -113,11 +128,11 @@ function ExperimentText() { } // 绘制图 - getGraphData(workflowData, true); + getGraphData(workflow, true); if (status === ExperimentStatus.Pending) { // 如果状态是 Pending, 打开第一个节点 - const node = workflowData.nodes[0]; + const node = workflow.nodes[0]; if (node) { setExperimentNodeData(node); openPropsDrawer(); @@ -125,8 +140,8 @@ function ExperimentText() { } else if (status === ExperimentStatus.Running) { // 如果状态是 Running,打开第一个运行中的节点,如果没有运行中的节点,则打开第一个节点 const node = - workflowData.nodes.find((item) => item.experimentStatus === ExperimentStatus.Running) ?? - workflowData.nodes[0]; + workflow.nodes.find((item) => item.experimentStatus === ExperimentStatus.Running) ?? + workflow.nodes[0]; if (node) { setExperimentNodeData(node); openPropsDrawer(); @@ -153,13 +168,13 @@ function ExperimentText() { return; } try { - const dataJson = JSON.parse(data); + const dataJson = parseJsonText(data); const statusData = dataJson?.result?.object?.status; if (!statusData) { return; } const { finishedAt, phase, nodes = {} } = statusData; - + // 更新实验实例状态和结束时间 // setExperimentIns((prev) => ({ // ...prev, diff --git a/react-ui/src/pages/ModelDeployment/components/ServerLog/index.less b/react-ui/src/pages/ModelDeployment/components/ServerLog/index.less index 11f3bf34..4b7f5762 100644 --- a/react-ui/src/pages/ModelDeployment/components/ServerLog/index.less +++ b/react-ui/src/pages/ModelDeployment/components/ServerLog/index.less @@ -20,5 +20,9 @@ &__more { padding: 20px 0; } + + &::-webkit-scrollbar-thumb { + background: rgba(255, 255, 255, 0.5); + } } }