Skip to content

Commit e53691a

Browse files
yinrouni霓君
authored andcommitted
repo-sync-2024-05-17T11:12:15+0800
1 parent 5d7adf6 commit e53691a

File tree

120 files changed

+3351
-1970
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+3351
-1970
lines changed

apps/platform/config/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default defineConfig({
4444
// apps: [
4545
// {
4646
// name: 'secretpad', // 后端应用名
47-
// tag: 'release/0.6.0b0_cml', // 分支 tag
47+
// tag: 'feature/0.7.0b0', // 分支 tag
4848
// source: 'ZAPPINFO', // 应用来源,默认 ZAPPINFO,其他来源可在官网的应用信息中查看
4949
// },
5050
// ],
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Model } from '@/util/valtio-helper';
2+
3+
import API from '@/services/secretpad';
4+
import { message } from 'antd';
5+
6+
interface GlobalConfig {
7+
maxParallelism: number;
8+
}
9+
export class advancedConfigService extends Model {
10+
loading = false;
11+
12+
config: GlobalConfig = {
13+
maxParallelism: 1,
14+
};
15+
16+
getSetting = async (graphId: string, projectId: string) => {
17+
if (!graphId || !projectId) return;
18+
this.loading = true;
19+
const { status, data } = await API.GraphController.getGraphDetail({
20+
graphId,
21+
projectId,
22+
});
23+
this.loading = false;
24+
if (status && status.code === 0) {
25+
this.config.maxParallelism = data?.maxParallelism || 1;
26+
}
27+
};
28+
29+
setting = async (params: API.FullUpdateGraphRequest) => {
30+
const { status } = await API.GraphController.fullUpdateGraph(params);
31+
if (status && status.code === 0) {
32+
message.success('配置成功');
33+
} else {
34+
message.error(status?.msg);
35+
}
36+
};
37+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import { getModel, useModel } from '@/util/valtio-helper';
2+
import { DefaultModalManager } from '@/modules/dag-modal-manager';
3+
import { advancedConfigService } from './advanced-config-service';
4+
import { Button, Drawer, Form, InputNumber, Space, Spin } from 'antd';
5+
import { useCallback, useEffect } from 'react';
6+
import dagLayoutStyle from '@/modules/layout/dag-layout/index.less';
7+
8+
import styles from './index.less';
9+
import { CloseOutlined } from '@ant-design/icons';
10+
import { useLocation } from 'umi';
11+
import { parse } from 'query-string';
12+
13+
export const AdvancedConfig = () => {
14+
const modalManager = useModel(DefaultModalManager);
15+
const service = useModel(advancedConfigService);
16+
17+
const { search } = useLocation();
18+
const { dagId, projectId } = parse(search);
19+
20+
const [form] = Form.useForm();
21+
22+
const { visible } = modalManager.modals[AdvancedConfigDrawer.id];
23+
24+
const onClose = () => {
25+
modalManager.closeModal(AdvancedConfigDrawer.id);
26+
form.resetFields();
27+
};
28+
29+
const getConfig = useCallback(async () => {
30+
await service.getSetting(dagId as string, projectId as string);
31+
}, [dagId]);
32+
33+
useEffect(() => {
34+
if (visible) {
35+
getConfig();
36+
}
37+
}, [visible]);
38+
39+
useEffect(() => {
40+
if (visible) {
41+
form.setFieldsValue({
42+
maxParallelism: service.config?.maxParallelism,
43+
});
44+
}
45+
}, [service.config.maxParallelism, visible]);
46+
47+
const handleOk = () => {
48+
form.validateFields().then(async (value) => {
49+
const params = {
50+
maxParallelism: value.maxParallelism,
51+
graphId: dagId as string,
52+
projectId: projectId as string,
53+
};
54+
await service.setting(params);
55+
onClose();
56+
});
57+
};
58+
59+
return (
60+
<Drawer
61+
title={'全局配置'}
62+
placement="right"
63+
width={320}
64+
destroyOnClose
65+
closable={false}
66+
onClose={onClose}
67+
open={visible}
68+
rootClassName={styles.configDrawer}
69+
getContainer={() => {
70+
return document.querySelector(`.${dagLayoutStyle.center}`) as Element;
71+
}}
72+
mask={false}
73+
extra={
74+
<CloseOutlined
75+
style={{ fontSize: 12 }}
76+
onClick={() => {
77+
onClose();
78+
}}
79+
/>
80+
}
81+
>
82+
<Spin spinning={service.loading}>
83+
<Form form={form}>
84+
<Form.Item
85+
name={'maxParallelism'}
86+
label={<div className={styles.task}>任务并发数</div>}
87+
tooltip="单个任务流的并发组件数"
88+
labelCol={{ span: 8 }}
89+
wrapperCol={{ offset: 4, span: 12 }}
90+
>
91+
<InputNumber
92+
defaultValue={1}
93+
step={1}
94+
min={1}
95+
max={100}
96+
style={{ width: '100%' }}
97+
precision={0}
98+
/>
99+
</Form.Item>
100+
<div className={styles.footer}>
101+
<Space>
102+
<Button type="primary" size="small" onClick={handleOk}>
103+
保存配置
104+
</Button>
105+
</Space>
106+
</div>
107+
</Form>
108+
</Spin>
109+
</Drawer>
110+
);
111+
};
112+
113+
export const AdvancedConfigDrawer = {
114+
id: 'AdvancedConfig',
115+
visible: false,
116+
data: {},
117+
};
118+
119+
getModel(DefaultModalManager).registerModal(AdvancedConfigDrawer);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.configDrawer {
2+
position: absolute;
3+
4+
:global {
5+
.ant-drawer-content-wrapper {
6+
box-shadow: 0 1px 4px 0 rgb(0 0 0 / 15%);
7+
}
8+
9+
.ant-drawer-title {
10+
font-size: 14px;
11+
}
12+
13+
.ant-drawer-body {
14+
padding: 0 12px;
15+
}
16+
17+
.ant-drawer-header {
18+
padding: 10px 12px 20px;
19+
border-bottom-color: transparent;
20+
}
21+
22+
.ant-form-item {
23+
margin-bottom: 16px;
24+
}
25+
26+
.ant-alert-message {
27+
color: rgb(0 0 0 / 45%);
28+
font-size: 12px;
29+
}
30+
}
31+
32+
&:focus {
33+
outline: none;
34+
}
35+
36+
.footer {
37+
position: sticky;
38+
bottom: 0;
39+
left: 0;
40+
height: 52px;
41+
background-color: white;
42+
}
43+
44+
.task {
45+
color: rgb(0 0 0 / 88%);
46+
font-size: 12px !important;
47+
line-height: 20px;
48+
}
49+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { SettingOutlined } from '@ant-design/icons';
2+
import {
3+
AdvancedConfig,
4+
AdvancedConfigDrawer,
5+
} from './advanced-config-drawer/advanced-config-view';
6+
import { useModel } from '@/util/valtio-helper';
7+
import { DefaultModalManager } from '@/modules/dag-modal-manager';
8+
9+
import styles from './index.less';
10+
import { Tooltip } from 'antd';
11+
12+
export const AdvancedConfigComponent: React.FC = () => {
13+
const modalManager = useModel(DefaultModalManager);
14+
15+
const handleClick = () => {
16+
modalManager.openModal(AdvancedConfigDrawer.id);
17+
};
18+
19+
return (
20+
<div>
21+
<Tooltip title="全局配置">
22+
<SettingOutlined onClick={handleClick} className={styles.settingContent} />
23+
</Tooltip>
24+
<AdvancedConfig />
25+
</div>
26+
);
27+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.settingContent {
2+
color: rgb(0 0 0 / 65%);
3+
4+
&:hover {
5+
color: #0068fa;
6+
}
7+
}

apps/platform/src/modules/component-config/component-config-protocol.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type AtomicConfigNode = {
1111
type: AtomicParameterType;
1212
fromInputIndex?: number;
1313
docString: string;
14-
isRequired: boolean;
14+
isRequired?: boolean;
1515
prefixes?: string[];
1616
value?: Attribute; //Record<string, any>;
1717
render?: string; // key in ConfigRenderRegistry for custom render
@@ -33,11 +33,12 @@ export type StructConfigNode = {
3333
domain?: string;
3434
version?: string;
3535
children: ConfigItem[];
36+
type?: 'AT_STRUCT_GROUP' | 'AT_UNION_GROUP';
3637
};
3738

3839
// 叶子结点:AtomicConfigNode
3940
// 非叶子结点:StructConfigNode
40-
export type ConfigItem = StructConfigNode | AtomicConfigNode;
41+
export type ConfigItem = StructConfigNode | AtomicConfigNode | CustomConfigNode;
4142

4243
export type ConfigPrefix = string;
4344

@@ -57,6 +58,15 @@ export const codeNameRenderKey = {
5758

5859
export const codeNameRenderIndex = {
5960
'preprocessing/binary_op': [0, 2, 1, 3, 4],
61+
'data_prep/psi': [0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 14, 11, 12, 13, 3, 15, 16],
62+
};
63+
64+
export const hideCodeNameIndex = {
65+
'data_prep/psi': [7],
66+
};
67+
68+
export const advancedConfigIndex = {
69+
'data_prep/psi': [3, 15, 16],
6070
};
6171

6272
export interface ComponentConfig {
@@ -121,7 +131,10 @@ export const getUpstreamKey = {
121131
const { inputs = [] } = graphNode || {};
122132
return upstreamNodes.map((n, index) => {
123133
const { codeName, nodeDef } = n || {};
124-
if (codeName !== 'read_data/datatable') return inputs[index];
134+
135+
if (!['read_data/datatable'].includes(codeName)) {
136+
return inputs[index];
137+
}
125138
const { attrs } = nodeDef;
126139
if (!attrs) return inputs[index];
127140
return attrs[0]?.s;
@@ -145,7 +158,7 @@ export const getUpstreamKey = {
145158
export const getInputTables = (inputNodes: GraphNode[]) => {
146159
return inputNodes?.map((n) => {
147160
const { codeName, nodeDef } = n || {};
148-
if (codeName !== 'read_data/datatable') return;
161+
if (!['read_data/datatable'].includes(codeName)) return;
149162
const { attrs } = nodeDef;
150163
if (!attrs) return;
151164
return attrs[0]?.s;

apps/platform/src/modules/component-config/component-config-registry.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class ComponentConfigRegistry extends Model {
2525

2626
registerConfigNode(component: Component, mode: ComputeMode) {
2727
if (this.hasConfigNode(component, mode)) return;
28-
const { name, domain, version, attrs = [], inputs } = component;
28+
const { name, domain, version, attrs = [], inputs, outputs } = component;
2929
const parent: StructConfigNode = {
3030
name: `${domain}/${name}`,
3131
domain,
@@ -42,7 +42,7 @@ export class ComponentConfigRegistry extends Model {
4242
for (const param of attrs) {
4343
const { prefixes } = param;
4444
if (prefixes) {
45-
this.getNodeByPath(prefixes, parent, param);
45+
this.getNodeByPath(prefixes, parent, param, 0);
4646
} else {
4747
parent.children.push(this.createNode(param));
4848
}
@@ -60,15 +60,19 @@ export class ComponentConfigRegistry extends Model {
6060
prefixes: string[],
6161
root: StructConfigNode,
6262
param: ParameterNode,
63+
depth: number,
6364
): ConfigItem | undefined {
6465
if (prefixes.length === 0) return;
65-
const prefix = prefixes[0];
66+
67+
const prefix = prefixes[depth];
6668
const child = root.children.find(({ name }) => name === prefix) as StructConfigNode;
69+
6770
if (!child) {
6871
root.children.push(this.createNode(param));
6972
return;
7073
}
71-
return this.getNodeByPath(prefixes, child, param);
74+
75+
return this.getNodeByPath(prefixes, child, param, depth + 1);
7276
}
7377

7478
private createInputConfigNode(input: IoDef[]) {
@@ -121,7 +125,7 @@ export class ComponentConfigRegistry extends Model {
121125
prefixes,
122126
children: [],
123127
docString,
124-
// isRequired: false,
128+
isRequired: false,
125129
selectedName: (param as UnionParameterNode)?.union?.default_selection,
126130
type: 'AT_UNION_GROUP',
127131
};
@@ -144,7 +148,10 @@ export class ComponentConfigRegistry extends Model {
144148
docString,
145149
};
146150
default:
151+
// is_optional:undefined,默认为必填
152+
// is_optional: true,不必填
147153
isRequired = (param as AtomicParameterNode).atomic?.is_optional !== true;
154+
148155
return {
149156
type,
150157
prefixes,

0 commit comments

Comments
 (0)