Browse Source

feat: 完成流水线全局参数

pull/14/head
cp3hnu 1 year ago
parent
commit
88cca25b4a
43 changed files with 278 additions and 70 deletions
  1. +1
    -0
      react-ui/config/config.ts
  2. BIN
      react-ui/public/assets/images/component-icon-3-Failed.png
  3. BIN
      react-ui/public/assets/images/component-icon-3-Omitted.png
  4. BIN
      react-ui/public/assets/images/component-icon-3-Pending.png
  5. BIN
      react-ui/public/assets/images/component-icon-3-Running.png
  6. BIN
      react-ui/public/assets/images/component-icon-3-Skipped.png
  7. BIN
      react-ui/public/assets/images/component-icon-3-Succeeded.png
  8. BIN
      react-ui/public/assets/images/component-icon-3.png
  9. BIN
      react-ui/public/assets/images/component-icon-4-Failed.png
  10. BIN
      react-ui/public/assets/images/component-icon-4-Omitted.png
  11. BIN
      react-ui/public/assets/images/component-icon-4-Pending.png
  12. BIN
      react-ui/public/assets/images/component-icon-4-Running.png
  13. BIN
      react-ui/public/assets/images/component-icon-4-Skipped.png
  14. BIN
      react-ui/public/assets/images/component-icon-4-Succeeded.png
  15. BIN
      react-ui/public/assets/images/component-icon-4.png
  16. BIN
      react-ui/public/assets/images/component-icon-5-Failed.png
  17. BIN
      react-ui/public/assets/images/component-icon-5-Omitted.png
  18. BIN
      react-ui/public/assets/images/component-icon-5-Pending.png
  19. BIN
      react-ui/public/assets/images/component-icon-5-Running.png
  20. BIN
      react-ui/public/assets/images/component-icon-5-Skipped.png
  21. BIN
      react-ui/public/assets/images/component-icon-5-Succeeded.png
  22. BIN
      react-ui/public/assets/images/component-icon-5.png
  23. BIN
      react-ui/public/assets/images/component-icon-6-Failed.png
  24. BIN
      react-ui/public/assets/images/component-icon-6-Omitted.png
  25. BIN
      react-ui/public/assets/images/component-icon-6-Pending.png
  26. BIN
      react-ui/public/assets/images/component-icon-6-Running.png
  27. BIN
      react-ui/public/assets/images/component-icon-6-Skipped.png
  28. BIN
      react-ui/public/assets/images/component-icon-6-Succeeded.png
  29. BIN
      react-ui/public/assets/images/component-icon-6.png
  30. BIN
      react-ui/public/assets/images/component-icon-7-Skipped.png
  31. +28
    -1
      react-ui/src/hooks/index.ts
  32. +8
    -10
      react-ui/src/pages/Dataset/datasetIntro.jsx
  33. +1
    -1
      react-ui/src/pages/Experiment/experimentText/LogList.tsx
  34. +1
    -1
      react-ui/src/pages/Experiment/experimentText/logGroup.tsx
  35. +11
    -0
      react-ui/src/pages/Experiment/status.ts
  36. +0
    -10
      react-ui/src/pages/Experiment/types.ts
  37. +8
    -5
      react-ui/src/pages/Model/modelIntro.jsx
  38. +14
    -0
      react-ui/src/pages/Pipeline/editPipeline/globalParamsDrawer.less
  39. +133
    -0
      react-ui/src/pages/Pipeline/editPipeline/globalParamsDrawer.tsx
  40. +60
    -38
      react-ui/src/pages/Pipeline/editPipeline/index.jsx
  41. +1
    -1
      react-ui/src/services/dataset/index.js
  42. +3
    -3
      react-ui/src/services/experiment/index.js
  43. +9
    -0
      react-ui/src/types.ts

+ 1
- 0
react-ui/config/config.ts View File

@@ -154,4 +154,5 @@ export default defineConfig({
strategy: 'normal', strategy: 'normal',
}, },
requestRecord: {}, requestRecord: {},
icons: {},
}); });

BIN
react-ui/public/assets/images/component-icon-3-Failed.png View File

Before After
Width: 108  |  Height: 108  |  Size: 5.1 kB Width: 108  |  Height: 108  |  Size: 3.5 kB

BIN
react-ui/public/assets/images/component-icon-3-Omitted.png View File

Before After
Width: 108  |  Height: 108  |  Size: 5.1 kB Width: 108  |  Height: 108  |  Size: 3.4 kB

BIN
react-ui/public/assets/images/component-icon-3-Pending.png View File

Before After
Width: 108  |  Height: 108  |  Size: 5.1 kB Width: 108  |  Height: 108  |  Size: 3.6 kB

BIN
react-ui/public/assets/images/component-icon-3-Running.png View File

Before After
Width: 108  |  Height: 108  |  Size: 5.0 kB Width: 108  |  Height: 108  |  Size: 3.4 kB

BIN
react-ui/public/assets/images/component-icon-3-Skipped.png View File

Before After
Width: 108  |  Height: 108  |  Size: 3.4 kB

BIN
react-ui/public/assets/images/component-icon-3-Succeeded.png View File

Before After
Width: 108  |  Height: 108  |  Size: 5.2 kB Width: 108  |  Height: 108  |  Size: 3.7 kB

BIN
react-ui/public/assets/images/component-icon-3.png View File

Before After
Width: 72  |  Height: 72  |  Size: 3.2 kB Width: 72  |  Height: 72  |  Size: 1.7 kB

BIN
react-ui/public/assets/images/component-icon-4-Failed.png View File

Before After
Width: 108  |  Height: 108  |  Size: 4.2 kB Width: 108  |  Height: 108  |  Size: 4.6 kB

BIN
react-ui/public/assets/images/component-icon-4-Omitted.png View File

Before After
Width: 108  |  Height: 108  |  Size: 4.1 kB Width: 108  |  Height: 108  |  Size: 4.6 kB

BIN
react-ui/public/assets/images/component-icon-4-Pending.png View File

Before After
Width: 108  |  Height: 108  |  Size: 4.2 kB Width: 108  |  Height: 108  |  Size: 4.7 kB

BIN
react-ui/public/assets/images/component-icon-4-Running.png View File

Before After
Width: 108  |  Height: 108  |  Size: 4.1 kB Width: 108  |  Height: 108  |  Size: 4.5 kB

BIN
react-ui/public/assets/images/component-icon-4-Skipped.png View File

Before After
Width: 108  |  Height: 108  |  Size: 4.6 kB

BIN
react-ui/public/assets/images/component-icon-4-Succeeded.png View File

Before After
Width: 108  |  Height: 108  |  Size: 4.4 kB Width: 108  |  Height: 108  |  Size: 4.8 kB

BIN
react-ui/public/assets/images/component-icon-4.png View File

Before After
Width: 72  |  Height: 72  |  Size: 2.8 kB Width: 72  |  Height: 72  |  Size: 2.8 kB

BIN
react-ui/public/assets/images/component-icon-5-Failed.png View File

Before After
Width: 108  |  Height: 108  |  Size: 2.9 kB Width: 108  |  Height: 108  |  Size: 4.5 kB

BIN
react-ui/public/assets/images/component-icon-5-Omitted.png View File

Before After
Width: 108  |  Height: 108  |  Size: 2.8 kB Width: 108  |  Height: 108  |  Size: 4.5 kB

BIN
react-ui/public/assets/images/component-icon-5-Pending.png View File

Before After
Width: 108  |  Height: 108  |  Size: 3.0 kB Width: 108  |  Height: 108  |  Size: 4.7 kB

BIN
react-ui/public/assets/images/component-icon-5-Running.png View File

Before After
Width: 108  |  Height: 108  |  Size: 2.9 kB Width: 108  |  Height: 108  |  Size: 4.4 kB

BIN
react-ui/public/assets/images/component-icon-5-Skipped.png View File

Before After
Width: 108  |  Height: 108  |  Size: 4.5 kB

BIN
react-ui/public/assets/images/component-icon-5-Succeeded.png View File

Before After
Width: 108  |  Height: 108  |  Size: 3.2 kB Width: 108  |  Height: 108  |  Size: 4.8 kB

BIN
react-ui/public/assets/images/component-icon-5.png View File

Before After
Width: 72  |  Height: 72  |  Size: 1.2 kB Width: 72  |  Height: 72  |  Size: 3.0 kB

BIN
react-ui/public/assets/images/component-icon-6-Failed.png View File

Before After
Width: 108  |  Height: 108  |  Size: 3.2 kB Width: 108  |  Height: 108  |  Size: 4.2 kB

BIN
react-ui/public/assets/images/component-icon-6-Omitted.png View File

Before After
Width: 108  |  Height: 108  |  Size: 3.2 kB Width: 108  |  Height: 108  |  Size: 4.1 kB

BIN
react-ui/public/assets/images/component-icon-6-Pending.png View File

Before After
Width: 108  |  Height: 108  |  Size: 3.2 kB Width: 108  |  Height: 108  |  Size: 4.2 kB

BIN
react-ui/public/assets/images/component-icon-6-Running.png View File

Before After
Width: 108  |  Height: 108  |  Size: 3.1 kB Width: 108  |  Height: 108  |  Size: 4.1 kB

BIN
react-ui/public/assets/images/component-icon-6-Skipped.png View File

Before After
Width: 108  |  Height: 108  |  Size: 4.1 kB

BIN
react-ui/public/assets/images/component-icon-6-Succeeded.png View File

Before After
Width: 108  |  Height: 108  |  Size: 3.3 kB Width: 108  |  Height: 108  |  Size: 4.3 kB

BIN
react-ui/public/assets/images/component-icon-6.png View File

Before After
Width: 31  |  Height: 31  |  Size: 716 B Width: 72  |  Height: 72  |  Size: 2.4 kB

BIN
react-ui/public/assets/images/component-icon-7-Skipped.png View File

Before After
Width: 108  |  Height: 108  |  Size: 3.1 kB

+ 28
- 1
react-ui/src/hooks/index.ts View File

@@ -1,4 +1,11 @@
import { useEffect, useRef, useState } from 'react';
import { useCallback, useEffect, useRef, useState } from 'react';

/**
* Generates a state reference with the initial value.
*
* @param initialValue - The initial value for the state
* @return An array containing the state value, state setter function, and a mutable reference object
*/
export function useStateRef<T>(initialValue: T) { export function useStateRef<T>(initialValue: T) {
const [value, setValue] = useState(initialValue); const [value, setValue] = useState(initialValue);


@@ -10,3 +17,23 @@ export function useStateRef<T>(initialValue: T) {


return [value, setValue, ref] as const; return [value, setValue, ref] as const;
} }

/**
* Generates a custom hook for managing the visibility state of a modal.
*
* @param initialValue - The initial visibility state of the modal.
* @return An array containing the visibility state and functions to open and close the modal.
*/
export function useModal(initialValue: boolean) {
const [visible, setVisible] = useState(initialValue);

const open = useCallback(() => {
setVisible(true);
}, []);

const close = useCallback(() => {
setVisible(false);
}, []);

return [visible, open, close];
}

+ 8
- 10
react-ui/src/pages/Dataset/datasetIntro.jsx View File

@@ -54,7 +54,7 @@ const Dataset = () => {
const [dialogTitle, setDialogTitle] = useState('新建版本'); const [dialogTitle, setDialogTitle] = useState('新建版本');
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
const [datasetDetailObj, setDatasetDetailObj] = useState({}); const [datasetDetailObj, setDatasetDetailObj] = useState({});
const [version, setVersion] = useState('');
const [version, setVersion] = useState(null);
const [versionList, setVersionList] = useState([]); const [versionList, setVersionList] = useState([]);
const locationParams = useParams(); //新版本获取路由参数接口 const locationParams = useParams(); //新版本获取路由参数接口
const [wordList, setWordList] = useState([]); const [wordList, setWordList] = useState([]);
@@ -109,27 +109,24 @@ const Dataset = () => {


onOk: () => { onOk: () => {
deleteDatasetVersion({ dataset_id: locationParams.id, version }).then((ret) => { deleteDatasetVersion({ dataset_id: locationParams.id, version }).then((ret) => {
message.success('删除成功');
setVersion(null);
getDatasetVersionList();
getDatasetVersions({ version, dataset_id: locationParams.id }); getDatasetVersions({ version, dataset_id: locationParams.id });
message.success('删除成功');
}); });
}, },
}); });
}; };
const onFinish = (values) => { const onFinish = (values) => {
addDatasetVersionDetail(formList).then((ret) => { addDatasetVersionDetail(formList).then((ret) => {
console.log(ret);
getDatasetVersionList(); getDatasetVersionList();
setIsModalOpen(false); setIsModalOpen(false);
message.success('创建成功');
}); });
}; };
const getDatasetVersions = (params) => { const getDatasetVersions = (params) => {
getDatasetVersionIdList(params).then((res) => { getDatasetVersionIdList(params).then((res) => {
setWordList(
res.data.map((v) => ({
...v,
key: v.id,
})),
);
setWordList(res.data);
}); });
}; };
const handleChange = (value) => { const handleChange = (value) => {
@@ -242,6 +239,7 @@ const Dataset = () => {
width: 160, width: 160,
}} }}
allowClear allowClear
value={version}
onChange={handleChange} onChange={handleChange}
options={versionList} options={versionList}
/> />
@@ -281,7 +279,7 @@ const Dataset = () => {
<div style={{ marginBottom: '10px', fontSize: '14px' }}> <div style={{ marginBottom: '10px', fontSize: '14px' }}>
{wordList.length > 0 ? wordList[0].description : null} {wordList.length > 0 ? wordList[0].description : null}
</div> </div>
<Table columns={columns} dataSource={wordList} pagination={false} />
<Table columns={columns} dataSource={wordList} pagination={false} rowKey="id" />
</div> </div>
</TabPane> </TabPane>
</Tabs> </Tabs>


+ 1
- 1
react-ui/src/pages/Experiment/experimentText/LogList.tsx View File

@@ -1,4 +1,4 @@
import { ExperimentStatus } from '../types';
import { ExperimentStatus } from '../status';
import LogGroup, { type LogGroupProps } from './logGroup'; import LogGroup, { type LogGroupProps } from './logGroup';


type LogListProps = { type LogListProps = {


+ 1
- 1
react-ui/src/pages/Experiment/experimentText/logGroup.tsx View File

@@ -3,7 +3,7 @@ import { getExperimentPodsLog } from '@/services/experiment/index.js';
import { DoubleRightOutlined, DownOutlined, UpOutlined } from '@ant-design/icons'; import { DoubleRightOutlined, DownOutlined, UpOutlined } from '@ant-design/icons';
import { Button } from 'antd'; import { Button } from 'antd';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { ExperimentStatus } from '../types';
import { ExperimentStatus } from '../status';
import styles from './logGroup.less'; import styles from './logGroup.less';


export type LogGroupProps = { export type LogGroupProps = {


+ 11
- 0
react-ui/src/pages/Experiment/status.ts View File

@@ -4,6 +4,17 @@ export interface StatusInfo {
icon: string; icon: string;
} }


export enum ExperimentStatus {
Running = 'Running',
Succeeded = 'Succeeded',
Pending = 'Pending',
Failed = 'Failed',
Error = 'Error',
Terminated = 'Terminated',
Skipped = 'Skipped',
Omitted = 'Omitted',
}

export const experimentStatusInfo: Record<string, StatusInfo | undefined> = { export const experimentStatusInfo: Record<string, StatusInfo | undefined> = {
Running: { Running: {
label: '运行中', label: '运行中',


+ 0
- 10
react-ui/src/pages/Experiment/types.ts View File

@@ -1,10 +0,0 @@
export enum ExperimentStatus {
Running = 'Running',
Succeeded = 'Succeeded',
Pending = 'Pending',
Failed = 'Failed',
Error = 'Error',
Terminated = 'Terminated',
Skipped = 'Skipped',
Omitted = 'Omitted',
}

+ 8
- 5
react-ui/src/pages/Model/modelIntro.jsx View File

@@ -54,7 +54,7 @@ const Dataset = () => {
const [dialogTitle, setDialogTitle] = useState('新建版本'); const [dialogTitle, setDialogTitle] = useState('新建版本');
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
const [datasetDetailObj, setDatasetDetailObj] = useState({}); const [datasetDetailObj, setDatasetDetailObj] = useState({});
const [version, setVersion] = useState('');
const [version, setVersion] = useState(null);
const [versionList, setVersionList] = useState([]); const [versionList, setVersionList] = useState([]);
const locationParams = useParams(); //新版本获取路由参数接口 const locationParams = useParams(); //新版本获取路由参数接口
console.log(locationParams); console.log(locationParams);
@@ -104,17 +104,19 @@ const Dataset = () => {


onOk: () => { onOk: () => {
deleteModelVersion({ models_id: locationParams.id, version }).then((ret) => { deleteModelVersion({ models_id: locationParams.id, version }).then((ret) => {
message.success('删除成功');
setVersion(null);
getModelVersionsList();
getModelVersions({ version, models_id: locationParams.id }); getModelVersions({ version, models_id: locationParams.id });
message.success('删除成功');
}); });
}, },
}); });
}; };
const onFinish = () => { const onFinish = () => {
addModelsVersionDetail(formList).then((ret) => { addModelsVersionDetail(formList).then((ret) => {
console.log(ret);
getModelVersionsList(); getModelVersionsList();
setIsModalOpen(false); setIsModalOpen(false);
message.success('创建成功');
}); });
}; };
const getModelVersions = (params) => { const getModelVersions = (params) => {
@@ -140,7 +142,7 @@ const Dataset = () => {
getModelVersions({ version: value, models_id: locationParams.id }); getModelVersions({ version: value, models_id: locationParams.id });
setVersion(value); setVersion(value);
} else { } else {
setVersion(null);
setVersion('');
} }
}; };
const onFinishFailed = (errorInfo) => { const onFinishFailed = (errorInfo) => {
@@ -237,6 +239,7 @@ const Dataset = () => {
style={{ style={{
width: 160, width: 160,
}} }}
value={version}
allowClear allowClear
onChange={handleChange} onChange={handleChange}
options={versionList} options={versionList}
@@ -277,7 +280,7 @@ const Dataset = () => {
<div style={{ marginBottom: '10px', fontSize: '14px' }}> <div style={{ marginBottom: '10px', fontSize: '14px' }}>
{wordList.length > 0 ? wordList[0].description : null} {wordList.length > 0 ? wordList[0].description : null}
</div> </div>
<Table columns={columns} dataSource={wordList} pagination={false} />
<Table columns={columns} dataSource={wordList} pagination={false} rowKey="id" />
</div> </div>
</TabPane> </TabPane>
</Tabs> </Tabs>


+ 14
- 0
react-ui/src/pages/Pipeline/editPipeline/globalParamsDrawer.less View File

@@ -0,0 +1,14 @@
.form_item_block {
position: relative;
padding-top: 40px;
border-bottom: 1px dashed rgba(20, 49, 179, 0.12);
}
.delete_button {
position: absolute;
top: 5px;
right: 0;
}
.add_button {
margin-top: 15px;
padding: 0;
}

+ 133
- 0
react-ui/src/pages/Pipeline/editPipeline/globalParamsDrawer.tsx View File

@@ -0,0 +1,133 @@
import { type PipelineGlobalParam } from '@/types';
import { to } from '@/utils/promise';
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons';
import { Button, Drawer, Form, Input, Radio } from 'antd';
import { forwardRef, useImperativeHandle } from 'react';
import styles from './globalParamsDrawer.less';

type GlobalParamsDrawerProps = {
open: boolean;
onClose: () => void;
globalParam: PipelineGlobalParam[];
};

const GlobalParamsDrawer = forwardRef(
({ open = false, onClose, globalParam = [] }: GlobalParamsDrawerProps, ref) => {
const [form] = Form.useForm();

useImperativeHandle(ref, () => ({
getFieldsValue: async () => {
const [res, error] = await to(form.validateFields());
if (res && !error) {
const values = form.getFieldsValue();
return values;
} else {
return Promise.reject(error);
}
},
}));
return (
<Drawer
rootStyle={{ marginTop: '45px' }}
title="全局参数"
placement="right"
closeIcon={false}
getContainer={false}
onClose={onClose}
open={open}
width={420}
>
<Form
name="global_params_form"
autoComplete="off"
form={form}
labelCol={{ span: 7 }}
wrapperCol={{ span: 17 }}
initialValues={{ global_param: globalParam }}
labelAlign="left"
>
<Form.List name="global_param">
{(fields, { add, remove }) => (
<>
{fields.map(({ key, name, ...restField }) => (
<div key={key} className={styles.form_item_block}>
<Form.Item
{...restField}
name={[name, 'param_name']}
label="参数名称"
rules={[{ required: true, message: '请输入参数名称' }]}
>
<Input placeholder="请输入参数名称" allowClear />
</Form.Item>
<Form.Item
{...restField}
name={[name, 'description']}
label="参数描述"
rules={[{ required: true, message: '请输入参数描述' }]}
>
<Input.TextArea
placeholder="请输入参数描述"
autoSize={{ minRows: 2, maxRows: 4 }}
allowClear
/>
</Form.Item>
<Form.Item
{...restField}
name={[name, 'param_type']}
label="类  型"
rules={[{ required: true, message: '请选择类型' }]}
>
<Radio.Group>
<Radio value={1}>字符串</Radio>
<Radio value={2}>整型</Radio>
<Radio value={3}>布尔类型</Radio>
</Radio.Group>
</Form.Item>
<Form.Item
{...restField}
name={[name, 'param_value']}
label="值"
rules={[{ required: true, message: '请输入值' }]}
>
<Input placeholder="请输入值" allowClear />
</Form.Item>
<Form.Item
{...restField}
name={[name, 'is_sensitive']}
label="脱敏显示"
rules={[{ required: true, message: '请选择' }]}
tooltip="脱敏后的参数以*****显示"
>
<Radio.Group>
<Radio value={1}>是</Radio>
<Radio value={0}>否</Radio>
</Radio.Group>
</Form.Item>
<Button
className={styles.delete_button}
type="link"
onClick={() => remove(name)}
icon={<DeleteOutlined />}
></Button>
</div>
))}
<Form.Item>
<Button
className={styles.add_button}
type="link"
onClick={add}
icon={<PlusOutlined />}
>
流水线参数
</Button>
</Form.Item>
</>
)}
</Form.List>
</Form>
</Drawer>
);
},
);

export default GlobalParamsDrawer;

+ 60
- 38
react-ui/src/pages/Pipeline/editPipeline/index.jsx View File

@@ -1,21 +1,27 @@
import { useModal } from '@/hooks';
import { getWorkflowById, saveWorkflow } from '@/services/pipeline/index.js'; import { getWorkflowById, saveWorkflow } from '@/services/pipeline/index.js';
import { to } from '@/utils/promise';
import { SaveOutlined } from '@ant-design/icons'; import { SaveOutlined } from '@ant-design/icons';
import { useEmotionCss } from '@ant-design/use-emotion-css'; import { useEmotionCss } from '@ant-design/use-emotion-css';
import G6 from '@antv/g6'; import G6 from '@antv/g6';
import { Button, message } from 'antd'; import { Button, message } from 'antd';
import React, { useEffect, useRef } from 'react';
import { useEffect, useRef, useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom'; import { useNavigate, useParams } from 'react-router-dom';
import { Icon } from 'umi';
import { s8 } from '../../../utils'; import { s8 } from '../../../utils';
import Styles from './editPipeline.less'; import Styles from './editPipeline.less';
import GlobalParamsDrawer from './globalParamsDrawer';
import ModelMenus from './modelMenus'; import ModelMenus from './modelMenus';
import Props from './props'; import Props from './props';
const editPipeline = (React.FC = () => {

let graph = null;

const EditPipeline = () => {
const propsRef = useRef(); const propsRef = useRef();
const navgite = useNavigate(); const navgite = useNavigate();
// const [contextMenu,setContextMenu]=useState({}) // const [contextMenu,setContextMenu]=useState({})
let contextMenu = {}; let contextMenu = {};
const locationParams = useParams(); //新版本获取路由参数接口 const locationParams = useParams(); //新版本获取路由参数接口
let graph = null;
let sourceAnchorIdx, targetAnchorIdx; let sourceAnchorIdx, targetAnchorIdx;
const pipelineContainer = useEmotionCss(() => { const pipelineContainer = useEmotionCss(() => {
return { return {
@@ -53,6 +59,9 @@ const editPipeline = (React.FC = () => {
}; };
}); });
const graphRef = useRef(); const graphRef = useRef();
const paramsDrawerRef = useRef();
const [paramsDrawerVisible, openParamsDrawer, closeParamsDrawer] = useModal(false);
const [globalParam, setGlobalParam] = useState([]);


const onDragEnd = (val) => { const onDragEnd = (val) => {
console.log(val, 'eee'); console.log(val, 'eee');
@@ -74,35 +83,37 @@ const editPipeline = (React.FC = () => {
console.log(graph); console.log(graph);
}; };
const formChange = (val) => { const formChange = (val) => {
const data = graph.save();
const index = data.nodes.findIndex((item) => {
return item.id === val.id;
});
data.nodes[index] = val;
graph.changeData(data);
graph.render();
if (graph) {
const data = graph.save();
const index = data.nodes.findIndex((item) => {
return item.id === val.id;
});
data.nodes[index] = val;
graph.changeData(data);
graph.render();
}
}; };
const savePipeline = (val) => {
const savePipeline = async (val) => {
const [res, error] = await to(paramsDrawerRef.current.getFieldsValue());
if (error) {
message.error('全局参数配置有误');
return;
}
const data = graph.save(); const data = graph.save();
console.log(data); console.log(data);
let params = { let params = {
...locationParams, ...locationParams,
dag: JSON.stringify(data), dag: JSON.stringify(data),
global_param: JSON.stringify(res.global_param),
}; };
saveWorkflow(params).then((ret) => { saveWorkflow(params).then((ret) => {
console.log(ret);
if (ret.code == 200) {
message.success('保存成功');
setTimeout(() => {
if (val) {
navgite({ pathname: `/pipeline` });
}
}, 500);
} else {
message.error('保存失败');
}
message.success('保存成功');
setTimeout(() => {
if (val) {
navgite({ pathname: `/pipeline` });
}
}, 500);
}); });
console.log(params);
}; };
const handlerClick = (e) => { const handlerClick = (e) => {
e.stopPropagation(); e.stopPropagation();
@@ -258,13 +269,12 @@ const editPipeline = (React.FC = () => {
}; };
const getFirstWorkflow = (val) => { const getFirstWorkflow = (val) => {
getWorkflowById(val).then((ret) => { getWorkflowById(val).then((ret) => {
console.log(ret);
if (ret.code == 200) {
if (graph && ret.data && ret.data.dag) {
getGraphData(JSON.parse(ret.data.dag));
}
if (ret && ret.data) {
setGlobalParam(ret.data.global_param);
}
if (graph && ret.data && ret.data.dag) {
getGraphData(JSON.parse(ret.data.dag));
} }

// graph&&graph.data(JSON.parse(ret.dag)) // graph&&graph.data(JSON.parse(ret.dag))
// graph.render() // graph.render()
}); });
@@ -334,7 +344,6 @@ const editPipeline = (React.FC = () => {
}); });
graph.off('dblclick', handlerClick); graph.off('dblclick', handlerClick);
}; };
console.log(contextMenu);
}, []); }, []);
const initGraph = () => { const initGraph = () => {
const fittingString = (str, maxWidth, fontSize) => { const fittingString = (str, maxWidth, fontSize) => {
@@ -601,8 +610,10 @@ const editPipeline = (React.FC = () => {
}); });
graph.on('dblclick', (e) => { graph.on('dblclick', (e) => {
console.log(e.item); console.log(e.item);
graph.setItemState(e.item, 'nodeClicked', true);
handlerClick(e);
if (e.item) {
graph.setItemState(e.item, 'nodeClicked', true);
handlerClick(e);
}
}); });
graph.on('click', (e) => { graph.on('click', (e) => {
console.log(e.item); console.log(e.item);
@@ -690,11 +701,18 @@ const editPipeline = (React.FC = () => {
<ModelMenus onParDragEnd={onDragEnd}></ModelMenus> <ModelMenus onParDragEnd={onDragEnd}></ModelMenus>
<div className={Styles.centerContainer}> <div className={Styles.centerContainer}>
<div className={Styles.buttonList}> <div className={Styles.buttonList}>
<Button
type="default"
icon={<Icon icon="local:parameter" style={{ verticalAlign: '-2px' }} />}
style={{ marginRight: '20px' }}
onClick={openParamsDrawer}
>
全局参数
</Button>
<Button <Button
type="primary" type="primary"
shape="round"
icon={<SaveOutlined />} icon={<SaveOutlined />}
style={{ marginRight: '20px', background: '#1664ff' }}
style={{ marginRight: '20px' }}
onClick={() => { onClick={() => {
savePipeline(false); savePipeline(false);
}} }}
@@ -703,9 +721,7 @@ const editPipeline = (React.FC = () => {
</Button> </Button>
<Button <Button
type="primary" type="primary"
shape="round"
icon={<SaveOutlined />} icon={<SaveOutlined />}
style={{ background: '#1664ff' }}
onClick={() => { onClick={() => {
savePipeline(true); savePipeline(true);
}} }}
@@ -716,7 +732,13 @@ const editPipeline = (React.FC = () => {
<div className={graphStyle} ref={graphRef} id={Styles.graphStyle}></div> <div className={graphStyle} ref={graphRef} id={Styles.graphStyle}></div>
</div> </div>
<Props ref={propsRef} onParentChange={formChange}></Props> <Props ref={propsRef} onParentChange={formChange}></Props>
<GlobalParamsDrawer
ref={paramsDrawerRef}
open={paramsDrawerVisible}
globalParam={globalParam}
onClose={closeParamsDrawer}
></GlobalParamsDrawer>
</div> </div>
); );
});
export default editPipeline;
};
export default EditPipeline;

+ 1
- 1
react-ui/src/services/dataset/index.js View File

@@ -94,7 +94,7 @@ export function deleteModelVersion(params) {
} }
// 新增数据集版本 // 新增数据集版本
export function addDatasetVersionDetail(data) { export function addDatasetVersionDetail(data) {
return request(`/api/mmp//datasetVersion/addDatasetVersions`, {
return request(`/api/mmp/datasetVersion/addDatasetVersions`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json;charset=UTF-8', 'Content-Type': 'application/json;charset=UTF-8',


+ 3
- 3
react-ui/src/services/experiment/index.js View File

@@ -53,10 +53,10 @@ export function getQueryByExperimentLog(data) {
}); });
} }
// 查询实例节点结果 // 查询实例节点结果
export function getNodeResult(params) {
export function getNodeResult(data) {
return request(`/api/mmp/experimentIns/nodeResult/`, { return request(`/api/mmp/experimentIns/nodeResult/`, {
method: 'GET',
params,
method: 'POST',
data,
}); });
} }




+ 9
- 0
react-ui/src/types.ts View File

@@ -0,0 +1,9 @@
// 流水线全局参数
export type PipelineGlobalParam = {
workflow_id: number;
param_name: string;
description: string;
param_type: number;
param_value: number | string | boolean;
is_sensitive: number;
};

Loading…
Cancel
Save