Skip to content

Commit 4315e3e

Browse files
authored
Merge pull request #29 from secretflow/release/0.9.x
chore: 7月更新迭代
2 parents 48d1c30 + cfd166c commit 4315e3e

File tree

15 files changed

+140
-35
lines changed

15 files changed

+140
-35
lines changed

apps/platform/src/modules/advanced-config/advanced-config-drawer/advanced-config-service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ export class advancedConfigService extends Model {
5252
};
5353

5454
getSetting = async (graphId: string, projectId: string) => {
55-
if (!graphId || !projectId) return;
55+
if (!graphId || !projectId) {
56+
this.config = {
57+
maxParallelism: 1,
58+
dataSourceConfig: [],
59+
};
60+
return;
61+
}
5662
this.loading = true;
5763
const { status, data } = await getGraphDetail({
5864
graphId,

apps/platform/src/modules/advanced-config/advanced-config-drawer/advanced-config-view.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import { getModel, useModel } from '@/util/valtio-helper';
1212

1313
import { advancedConfigService } from './advanced-config-service';
1414
import styles from './index.less';
15+
import { ProjectEditService } from '@/modules/layout/header-project-list/project-edit.service';
1516

1617
export const AdvancedConfig = () => {
1718
const modalManager = useModel(DefaultModalManager);
19+
const projectEditService = useModel(ProjectEditService);
1820
const service = useModel(advancedConfigService);
1921
const loginService = useModel(LoginService);
2022

@@ -183,7 +185,12 @@ export const AdvancedConfig = () => {
183185
</Form.List>
184186
<div className={styles.footer}>
185187
<Space>
186-
<Button type="primary" size="small" onClick={handleOk}>
188+
<Button
189+
type="primary"
190+
size="small"
191+
onClick={handleOk}
192+
disabled={projectEditService.canEdit.advancedConfigDisabled}
193+
>
187194
保存配置
188195
</Button>
189196
</Space>

apps/platform/src/modules/component-config/config-item-render/custom-render/linear-model-parameters-modification/index.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@ import { Button, Space, Tooltip } from 'antd';
44
import React, { useEffect } from 'react';
55

66
import type { GraphNodeDetail } from '@/modules/component-config/component-config-protocol';
7-
import mainDag from '@/modules/main-dag/dag';
8-
import { Model, getModel, useModel } from '@/util/valtio-helper';
7+
import { getModel, useModel } from '@/util/valtio-helper';
98

10-
import type { NodeAllInfo } from '../../config-render-protocol';
119
import { ParamsModificationsRenderView } from '../parameters-modification/parameters-modification-view';
1210
import { DefaultRedoUndoService } from '../redo-undo/redo-undo-service';
1311

1412
import { ParametersResultDrawerView } from './drawer';
1513
import { ModelParametersModificationService } from './model-parameters-modification-service';
16-
import { SourceTypeEnum } from './types';
17-
import type { CurrOperationEnum, ParametersData, ParametersDatum } from './types';
14+
import type { ParametersData, ParametersDatum } from './types';
1815

1916
/** 2. 把表单格式,serializer 序列化,转换成 node info */
2017
export const modelModificationsSerializer = (data: ParametersData) => {

apps/platform/src/modules/component-config/config-item-render/custom-render/observations-quantiles-render/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ const QuatitiesWrapper = (props: { children: React.ReactNode }) => {
2929
采样方式
3030
<Tooltip
3131
placement={'top'}
32-
title={
33-
'下采样时可选择采样方式;当上采样时,如选择不放回采样时,系统还是按照放回采样进行。'
34-
}
32+
title={'如采样倍率>1,但选择不放回采样则会报错处理。'}
3533
>
3634
<QuestionCircleOutlined />
3735
</Tooltip>
@@ -95,7 +93,9 @@ const ObservationsQuantilesRender: React.FC<RenderProp<string>> = (prop) => {
9593
<Form.Item
9694
name={quantilesStringFieldName}
9795
tooltip={translation[node.docString!] || node.docString}
98-
label={<span className={styles.font}>观测值分位点</span>}
96+
label={
97+
<span className={styles.font}>{translation[node.name] || node.name}</span>
98+
}
9999
labelCol={{ span: 12 }}
100100
rules={[
101101
{ required: true, message: '请输入观测值分位点' },

apps/platform/src/modules/component-config/config-item-render/default-render-template.tsx

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,28 +119,51 @@ export const DefaultInputNumber: React.FC<RenderProp<number>> = (config) => {
119119
},
120120
{
121121
validator: (_, value) => {
122+
let errorText = '取值应该';
122123
if (value === null || value === undefined) return Promise.resolve();
123124
if (minVal !== null && minVal !== undefined) {
124125
if (minInclusive) {
125-
if (value < minVal)
126-
return Promise.reject(new Error(`取值应该大于等于${minVal}`));
126+
errorText += `大于等于${minVal}`;
127127
} else {
128-
if (value <= minVal)
129-
return Promise.reject(new Error(`取值应该大于${minVal}`));
128+
errorText +=
129+
(errorText.replace('取值应该', '') ? `且` : '') + `大于${minVal}`;
130+
}
131+
}
132+
133+
if (maxVal !== null && maxVal !== undefined) {
134+
if (maxInclusive) {
135+
errorText +=
136+
(errorText.replace('取值应该', '') ? `且` : '') + `小于等于${maxVal}`;
137+
} else {
138+
errorText +=
139+
(errorText.replace('取值应该', '') ? `且` : '') + `小于${maxVal}`;
140+
}
141+
}
142+
143+
if (minVal !== null && minVal !== undefined) {
144+
if (minInclusive) {
145+
if (value < minVal) {
146+
return Promise.reject(new Error(errorText));
147+
}
148+
} else {
149+
if (value <= minVal) {
150+
return Promise.reject(new Error(errorText));
151+
}
130152
}
131153
}
132154

133155
if (maxVal !== null && maxVal !== undefined) {
134156
if (maxInclusive) {
135157
if (value > maxVal) {
136-
return Promise.reject(new Error(`取值应该小于等于${maxVal}`));
158+
return Promise.reject(new Error(errorText));
137159
}
138160
} else {
139161
if (value >= maxVal) {
140-
return Promise.reject(new Error(`取值应该小于${maxVal}`));
162+
return Promise.reject(new Error(errorText));
141163
}
142164
}
143165
}
166+
144167
return Promise.resolve();
145168
},
146169
},

apps/platform/src/modules/data-table-tree/datatable-tree.view.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ import { getModel, Model, useModel } from '@/util/valtio-helper';
2424
import { DatatableTreeService } from './datatable-tree.service';
2525
import styles from './index.less';
2626
import { openNewTab } from '@/util/path';
27+
import { ProjectEditService } from '../layout/header-project-list/project-edit.service';
2728

2829
const { Text } = Typography;
2930

3031
export const DatatableTreeComponent = () => {
3132
const viewInstance = useModel(DatatableTreeView);
33+
const projectEditService = useModel(ProjectEditService);
34+
3235
const ref1 = useRef(null);
3336
const { pathname, search } = useLocation();
3437
const { projectId } = parse(search);
@@ -191,7 +194,8 @@ export const DatatableTreeComponent = () => {
191194
</EdgeAuthWrapper>
192195
)}
193196
{item.nodeId === currentLoginNodeId &&
194-
hasAccess({ type: [Platform.AUTONOMY] }) && (
197+
hasAccess({ type: [Platform.AUTONOMY] }) &&
198+
!projectEditService.canEdit.gotoDataManagerDisabled && (
195199
<Button
196200
type="link"
197201
onClick={() => {

apps/platform/src/modules/layout/header-project-list/project-edit.service.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export class ProjectEditService extends Model {
1616
recordStoptaskDisabled: false,
1717
pipelineEditDisabled: false,
1818
submitModelDisabled: false,
19+
advancedConfigDisabled: false,
20+
gotoDataManagerDisabled: false,
1921
};
2022

2123
changeCanEditTrue = () => {
@@ -30,6 +32,8 @@ export class ProjectEditService extends Model {
3032
recordStoptaskDisabled: true,
3133
pipelineEditDisabled: true,
3234
submitModelDisabled: true,
35+
advancedConfigDisabled: true,
36+
gotoDataManagerDisabled: true,
3337
};
3438
};
3539

@@ -45,6 +49,8 @@ export class ProjectEditService extends Model {
4549
recordStoptaskDisabled: false,
4650
pipelineEditDisabled: false,
4751
submitModelDisabled: false,
52+
advancedConfigDisabled: false,
53+
gotoDataManagerDisabled: false,
4854
};
4955
};
5056

@@ -85,4 +91,8 @@ type CanEditType = {
8591
pipelineEditDisabled: boolean;
8692
/** 画布提交模型 */
8793
submitModelDisabled: boolean;
94+
/** 全局配置保存配置 */
95+
advancedConfigDisabled: boolean;
96+
/** 画布数据集展示去节点管理添加数据按钮 */
97+
gotoDataManagerDisabled: boolean;
8898
};

apps/platform/src/modules/layout/header-project-list/project-list.view.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { Model, getModel, useModel } from '@/util/valtio-helper';
1515

1616
import styles from './index.less';
1717
import { ProjectEditService } from './project-edit.service';
18+
import { DefaultModalManager } from '@/modules/dag-modal-manager';
19+
import { AdvancedConfigDrawer } from '@/modules/advanced-config/advanced-config-drawer/advanced-config-view';
1820

1921
export type ProjectVO = API.ProjectVO;
2022

@@ -80,6 +82,7 @@ export const ProjectListComponent: React.FC = () => {
8082
export class HeaderProjectListView extends Model {
8183
projectEditService = getModel(ProjectEditService);
8284
dagLayoutView = getModel(DagLayoutView);
85+
modalManager = getModel(DefaultModalManager);
8386

8487
projectList: ProjectVO[] = [];
8588

@@ -130,7 +133,7 @@ export class HeaderProjectListView extends Model {
130133
},
131134
{ origin },
132135
);
133-
136+
this.modalManager.closeModal(AdvancedConfigDrawer.id);
134137
this.dagLayoutView.setActiveKey('pipeline');
135138
};
136139
}

apps/platform/src/modules/main-dag/graph-request-service.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ export class GraphRequestService extends DefaultRequestService {
220220

221221
async saveDag(dagId: string, model: GraphModel) {
222222
const { nodes: n, edges: e } = model;
223+
this.graphData = model;
224+
223225
const { mode } = parse(window.location.search);
224226
const nodes = await Promise.all(
225227
n.map(async (i) => {

apps/platform/src/modules/main-dag/graph-service.ts

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import type { Edge, Graph } from '@antv/x6';
22
import { ActionType, NodeStatus } from '@secretflow/dag';
3-
import type { GraphNode, Node, GraphEventHandlerProtocol } from '@secretflow/dag';
3+
import type {
4+
GraphNode,
5+
Node,
6+
GraphEventHandlerProtocol,
7+
GraphModel,
8+
} from '@secretflow/dag';
49
import { Emitter } from '@secretflow/utils';
510
import { message } from 'antd';
611
import { parse } from 'query-string';
@@ -12,7 +17,10 @@ import {
1217
import { updateGraphNode } from '@/services/secretpad/GraphController';
1318
import { getModel } from '@/util/valtio-helper';
1419

15-
import type { ComponentConfig } from '../component-config/component-config-protocol';
20+
import type {
21+
ComponentConfig,
22+
StructConfigNode,
23+
} from '../component-config/component-config-protocol';
1624
import { ComponentConfigRegistry } from '../component-config/component-config-registry';
1725
import { DefaultComponentConfigService } from '../component-config/component-config-service';
1826
import { componentConfigDrawer } from '../component-config/config-modal';
@@ -250,7 +258,8 @@ export class GraphService implements GraphEventHandlerProtocol {
250258
CUSTOM_COMPONENT.ModelParamModification,
251259
].includes(node?.codeName)
252260
) {
253-
const { attrs, attrPaths, ...restNodeDef } = node.nodeDef || {};
261+
const defaultNodeDef = this.getDefaultNodeDef(node);
262+
const { attrs, attrPaths, ...restNodeDef } = node.nodeDef || defaultNodeDef;
254263
const updatedNode = {
255264
...node,
256265
inputs: [sourcePortId],
@@ -264,7 +273,7 @@ export class GraphService implements GraphEventHandlerProtocol {
264273
node: updatedNode,
265274
});
266275

267-
mainDag.dataService.fetch();
276+
await mainDag.dataService.fetch();
268277
}
269278
}
270279
}
@@ -289,8 +298,25 @@ export class GraphService implements GraphEventHandlerProtocol {
289298
].includes(node?.codeName),
290299
)
291300
.map((node) => node.id);
301+
await this.cleanNodeDef(binningModificationNodeIds);
302+
}
292303

293-
this.cleanNodeDef(binningModificationNodeIds);
304+
getDefaultNodeDef(node: GraphNode) {
305+
const { mode } = parse(window.location.search);
306+
const { codeName } = node;
307+
const config = this.componentConfigRegistry.getComponentConfig(
308+
codeName,
309+
mode as ComputeMode,
310+
);
311+
const { version, domain } = config as StructConfigNode;
312+
313+
const [, name] = codeName.split('/');
314+
315+
return {
316+
version,
317+
domain,
318+
name,
319+
};
294320
}
295321

296322
async cleanNodeDef(nodeIds: string[]) {
@@ -301,11 +327,13 @@ export class GraphService implements GraphEventHandlerProtocol {
301327
const { search } = window.location;
302328
const { dagId } = parse(search);
303329

304-
const dataNodes = mainDag.dataService.nodes;
330+
const dataNodes = (mainDag.requestService.graphData as GraphModel).nodes;
331+
332+
const nodes = dataNodes.map((node: GraphNode) => {
333+
const defaultNodeDef = this.getDefaultNodeDef(node);
305334

306-
const nodes = dataNodes.map((node) => {
307335
if (nodeIds.includes(node?.id)) {
308-
const { attrs, attrPaths, ...restNodeDef } = node?.nodeDef || {};
336+
const { attrs, attrPaths, ...restNodeDef } = node?.nodeDef || defaultNodeDef;
309337
return {
310338
...node,
311339
nodeDef: {
@@ -323,7 +351,7 @@ export class GraphService implements GraphEventHandlerProtocol {
323351
});
324352

325353
// 更新最新的 nodes
326-
mainDag.dataService.fetch();
354+
await mainDag.dataService.fetch();
327355
}
328356

329357
saveTemplateQuickConfig = async (quickConfig: {
@@ -401,7 +429,7 @@ export class GraphService implements GraphEventHandlerProtocol {
401429
)
402430
.map((node) => node.id);
403431

404-
this.cleanNodeDef(binningModificationNodeIds);
432+
await this.cleanNodeDef(binningModificationNodeIds);
405433
} else {
406434
message.error(status?.msg || '操作失败');
407435
}

0 commit comments

Comments
 (0)