Browse Source

feat: 自动机器学习实验结果添加模型下载

pull/149/head
cp3hnu 1 year ago
parent
commit
e7240031ff
5 changed files with 79 additions and 22 deletions
  1. +1
    -1
      react-ui/src/iconfont/iconfont.js
  2. +10
    -3
      react-ui/src/pages/AutoML/Instance/index.tsx
  3. +27
    -6
      react-ui/src/pages/AutoML/components/ExperimentResult/index.less
  4. +39
    -10
      react-ui/src/pages/AutoML/components/ExperimentResult/index.tsx
  5. +2
    -2
      react-ui/src/pages/Experiment/components/LogGroup/index.tsx

+ 1
- 1
react-ui/src/iconfont/iconfont.js
File diff suppressed because it is too large
View File


+ 10
- 3
react-ui/src/pages/AutoML/Instance/index.tsx View File

@@ -55,7 +55,10 @@ function AutoMLInstance() {
// 这个接口返回的状态有延时,SSE 返回的状态是最新的 // 这个接口返回的状态有延时,SSE 返回的状态是最新的
// SSE 调用时,不需要解析 node_status, 也不要重新建立 SSE // SSE 调用时,不需要解析 node_status, 也不要重新建立 SSE
if (isStatusDetermined) { if (isStatusDetermined) {
setInstanceInfo(info);
setInstanceInfo((prev) => ({
...info,
nodeStatus: prev!.nodeStatus,
}));
return; return;
} }


@@ -101,7 +104,7 @@ function AutoMLInstance() {
) as NodeStatus; ) as NodeStatus;
if (statusData) { if (statusData) {
setInstanceInfo((prev) => ({ setInstanceInfo((prev) => ({
...(prev as AutoMLInstanceData),
...prev!,
nodeStatus: statusData, nodeStatus: statusData,
})); }));


@@ -172,7 +175,11 @@ function AutoMLInstance() {
label: '实验结果', label: '实验结果',
icon: <KFIcon type="icon-shiyanjieguo1" />, icon: <KFIcon type="icon-shiyanjieguo1" />,
children: ( children: (
<ExperimentResult fileUrl={instanceInfo?.result_path} imageUrl={instanceInfo?.img_path} />
<ExperimentResult
fileUrl={instanceInfo?.result_path}
imageUrl={instanceInfo?.img_path}
modelPath={instanceInfo?.model_path}
/>
), ),
}, },
{ {


+ 27
- 6
react-ui/src/pages/AutoML/components/ExperimentResult/index.less View File

@@ -6,9 +6,25 @@
background-color: white; background-color: white;
border-radius: 10px; border-radius: 10px;


&__download {
display: flex;
align-items: center;
height: 34px;
margin-bottom: 16px;
padding-left: @content-padding;
color: @text-color;
font-size: 13px;
background-color: #f8f8f9;
border-radius: 4px;

&__btn {
margin-left: 22px;
}
}

&__text { &__text {
width: 100%; width: 100%;
height: 460px;
height: 420px;
padding: 20px @content-padding; padding: 20px @content-padding;
overflow: auto; overflow: auto;
white-space: pre-wrap; white-space: pre-wrap;
@@ -20,14 +36,19 @@
width: 100%; width: 100%;
overflow-x: auto; overflow-x: auto;


:global {
.ant-image {
margin-right: 20px;

&:last-child {
margin-right: 0;
}
}
}

&__item { &__item {
height: 248px; height: 248px;
margin-right: 20px;
border: 1px solid rgba(96, 107, 122, 0.3); border: 1px solid rgba(96, 107, 122, 0.3);

&:last-child {
margin-right: 0;
}
} }
} }
} }

+ 39
- 10
react-ui/src/pages/AutoML/components/ExperimentResult/index.tsx View File

@@ -1,15 +1,18 @@
import InfoGroup from '@/components/InfoGroup'; import InfoGroup from '@/components/InfoGroup';
import KFIcon from '@/components/KFIcon';
import { getFileReq } from '@/services/file'; import { getFileReq } from '@/services/file';
import { to } from '@/utils/promise'; import { to } from '@/utils/promise';
import { Button, Image } from 'antd';
import { useEffect, useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import styles from './index.less'; import styles from './index.less';


type ExperimentResultProps = { type ExperimentResultProps = {
fileUrl?: string; fileUrl?: string;
imageUrl?: string; imageUrl?: string;
modelPath?: string;
}; };


function ExperimentResult({ fileUrl, imageUrl }: ExperimentResultProps) {
function ExperimentResult({ fileUrl, imageUrl, modelPath }: ExperimentResultProps) {
const [result, setResult] = useState<string | undefined>(''); const [result, setResult] = useState<string | undefined>('');


const images = useMemo(() => { const images = useMemo(() => {
@@ -35,20 +38,46 @@ function ExperimentResult({ fileUrl, imageUrl }: ExperimentResultProps) {


return ( return (
<div className={styles['experiment-result']}> <div className={styles['experiment-result']}>
{modelPath && (
<div className={styles['experiment-result__download']}>
<span style={{ marginRight: '12px', color: '#606b7a' }}>文件名</span>
<span>save_model.joblib</span>
<Button
type="link"
className={styles['experiment-result__download__btn']}
icon={<KFIcon type="icon-a-xiazai1" />}
size="small"
iconPosition="end"
onClick={() => {
window.location.href = modelPath;
}}
>
模型下载
</Button>
</div>
)}
<InfoGroup title="实验结果" contentScroll> <InfoGroup title="实验结果" contentScroll>
<div className={styles['experiment-result__text']}>{result}</div> <div className={styles['experiment-result__text']}>{result}</div>
</InfoGroup> </InfoGroup>
<InfoGroup title="可视化结果" style={{ marginTop: '16px' }}> <InfoGroup title="可视化结果" style={{ marginTop: '16px' }}>
<div className={styles['experiment-result__images']}> <div className={styles['experiment-result__images']}>
{images.map((item, index) => (
<img
key={index}
className={styles['experiment-result__images__item']}
src={item}
draggable={false}
alt=""
/>
))}
<Image.PreviewGroup
preview={{
onChange: (current, prev) =>
console.log(`current index: ${current}, prev index: ${prev}`),
}}
>
{images.map((item) => (
<Image
key={item}
className={styles['experiment-result__images__item']}
src={item}
height={248}
draggable={false}
alt=""
/>
))}
</Image.PreviewGroup>
</div> </div>
</InfoGroup> </InfoGroup>
</div> </div>


+ 2
- 2
react-ui/src/pages/Experiment/components/LogGroup/index.tsx View File

@@ -52,7 +52,7 @@ function LogGroup({
const [_isMouseDown, setIsMouseDown, isMouseDownRef] = useStateRef(false); const [_isMouseDown, setIsMouseDown, isMouseDownRef] = useStateRef(false);
const preStatusRef = useRef<ExperimentStatus | undefined>(undefined); const preStatusRef = useRef<ExperimentStatus | undefined>(undefined);
const socketRef = useRef<WebSocket | undefined>(undefined); const socketRef = useRef<WebSocket | undefined>(undefined);
const retryRef = useRef(2); // 等待 2 秒,重试 2
const retryRef = useRef(2); // 等待 2 秒,重试 3


useEffect(() => { useEffect(() => {
scrollToBottom(false); scrollToBottom(false);
@@ -147,7 +147,7 @@ function LogGroup({


socket.addEventListener('close', (event) => { socket.addEventListener('close', (event) => {
console.log('WebSocket is closed:', event); console.log('WebSocket is closed:', event);
// 有时候会出现连接失败,重试 2
// 有时候会出现连接失败,重试 3
if (event.code !== 1000 && retryRef.current > 0) { if (event.code !== 1000 && retryRef.current > 0) {
retryRef.current -= 1; retryRef.current -= 1;
setTimeout(() => { setTimeout(() => {


Loading…
Cancel
Save