Skip to content

Commit

Permalink
Merge pull request #29 from secretflow/release/0.9.x
Browse files Browse the repository at this point in the history
chore: 7月更新迭代
  • Loading branch information
yinrouni authored Jul 16, 2024
2 parents 48d1c30 + cfd166c commit 4315e3e
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ export class advancedConfigService extends Model {
};

getSetting = async (graphId: string, projectId: string) => {
if (!graphId || !projectId) return;
if (!graphId || !projectId) {
this.config = {
maxParallelism: 1,
dataSourceConfig: [],
};
return;
}
this.loading = true;
const { status, data } = await getGraphDetail({
graphId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import { getModel, useModel } from '@/util/valtio-helper';

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

export const AdvancedConfig = () => {
const modalManager = useModel(DefaultModalManager);
const projectEditService = useModel(ProjectEditService);
const service = useModel(advancedConfigService);
const loginService = useModel(LoginService);

Expand Down Expand Up @@ -183,7 +185,12 @@ export const AdvancedConfig = () => {
</Form.List>
<div className={styles.footer}>
<Space>
<Button type="primary" size="small" onClick={handleOk}>
<Button
type="primary"
size="small"
onClick={handleOk}
disabled={projectEditService.canEdit.advancedConfigDisabled}
>
保存配置
</Button>
</Space>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ import { Button, Space, Tooltip } from 'antd';
import React, { useEffect } from 'react';

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

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

import { ParametersResultDrawerView } from './drawer';
import { ModelParametersModificationService } from './model-parameters-modification-service';
import { SourceTypeEnum } from './types';
import type { CurrOperationEnum, ParametersData, ParametersDatum } from './types';
import type { ParametersData, ParametersDatum } from './types';

/** 2. 把表单格式,serializer 序列化,转换成 node info */
export const modelModificationsSerializer = (data: ParametersData) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ const QuatitiesWrapper = (props: { children: React.ReactNode }) => {
采样方式
<Tooltip
placement={'top'}
title={
'下采样时可选择采样方式;当上采样时,如选择不放回采样时,系统还是按照放回采样进行。'
}
title={'如采样倍率>1,但选择不放回采样则会报错处理。'}
>
<QuestionCircleOutlined />
</Tooltip>
Expand Down Expand Up @@ -95,7 +93,9 @@ const ObservationsQuantilesRender: React.FC<RenderProp<string>> = (prop) => {
<Form.Item
name={quantilesStringFieldName}
tooltip={translation[node.docString!] || node.docString}
label={<span className={styles.font}>观测值分位点</span>}
label={
<span className={styles.font}>{translation[node.name] || node.name}</span>
}
labelCol={{ span: 12 }}
rules={[
{ required: true, message: '请输入观测值分位点' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,51 @@ export const DefaultInputNumber: React.FC<RenderProp<number>> = (config) => {
},
{
validator: (_, value) => {
let errorText = '取值应该';
if (value === null || value === undefined) return Promise.resolve();
if (minVal !== null && minVal !== undefined) {
if (minInclusive) {
if (value < minVal)
return Promise.reject(new Error(`取值应该大于等于${minVal}`));
errorText += `大于等于${minVal}`;
} else {
if (value <= minVal)
return Promise.reject(new Error(`取值应该大于${minVal}`));
errorText +=
(errorText.replace('取值应该', '') ? `且` : '') + `大于${minVal}`;
}
}

if (maxVal !== null && maxVal !== undefined) {
if (maxInclusive) {
errorText +=
(errorText.replace('取值应该', '') ? `且` : '') + `小于等于${maxVal}`;
} else {
errorText +=
(errorText.replace('取值应该', '') ? `且` : '') + `小于${maxVal}`;
}
}

if (minVal !== null && minVal !== undefined) {
if (minInclusive) {
if (value < minVal) {
return Promise.reject(new Error(errorText));
}
} else {
if (value <= minVal) {
return Promise.reject(new Error(errorText));
}
}
}

if (maxVal !== null && maxVal !== undefined) {
if (maxInclusive) {
if (value > maxVal) {
return Promise.reject(new Error(`取值应该小于等于${maxVal}`));
return Promise.reject(new Error(errorText));
}
} else {
if (value >= maxVal) {
return Promise.reject(new Error(`取值应该小于${maxVal}`));
return Promise.reject(new Error(errorText));
}
}
}

return Promise.resolve();
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ import { getModel, Model, useModel } from '@/util/valtio-helper';
import { DatatableTreeService } from './datatable-tree.service';
import styles from './index.less';
import { openNewTab } from '@/util/path';
import { ProjectEditService } from '../layout/header-project-list/project-edit.service';

const { Text } = Typography;

export const DatatableTreeComponent = () => {
const viewInstance = useModel(DatatableTreeView);
const projectEditService = useModel(ProjectEditService);

const ref1 = useRef(null);
const { pathname, search } = useLocation();
const { projectId } = parse(search);
Expand Down Expand Up @@ -191,7 +194,8 @@ export const DatatableTreeComponent = () => {
</EdgeAuthWrapper>
)}
{item.nodeId === currentLoginNodeId &&
hasAccess({ type: [Platform.AUTONOMY] }) && (
hasAccess({ type: [Platform.AUTONOMY] }) &&
!projectEditService.canEdit.gotoDataManagerDisabled && (
<Button
type="link"
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export class ProjectEditService extends Model {
recordStoptaskDisabled: false,
pipelineEditDisabled: false,
submitModelDisabled: false,
advancedConfigDisabled: false,
gotoDataManagerDisabled: false,
};

changeCanEditTrue = () => {
Expand All @@ -30,6 +32,8 @@ export class ProjectEditService extends Model {
recordStoptaskDisabled: true,
pipelineEditDisabled: true,
submitModelDisabled: true,
advancedConfigDisabled: true,
gotoDataManagerDisabled: true,
};
};

Expand All @@ -45,6 +49,8 @@ export class ProjectEditService extends Model {
recordStoptaskDisabled: false,
pipelineEditDisabled: false,
submitModelDisabled: false,
advancedConfigDisabled: false,
gotoDataManagerDisabled: false,
};
};

Expand Down Expand Up @@ -85,4 +91,8 @@ type CanEditType = {
pipelineEditDisabled: boolean;
/** 画布提交模型 */
submitModelDisabled: boolean;
/** 全局配置保存配置 */
advancedConfigDisabled: boolean;
/** 画布数据集展示去节点管理添加数据按钮 */
gotoDataManagerDisabled: boolean;
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { Model, getModel, useModel } from '@/util/valtio-helper';

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

export type ProjectVO = API.ProjectVO;

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

projectList: ProjectVO[] = [];

Expand Down Expand Up @@ -130,7 +133,7 @@ export class HeaderProjectListView extends Model {
},
{ origin },
);

this.modalManager.closeModal(AdvancedConfigDrawer.id);
this.dagLayoutView.setActiveKey('pipeline');
};
}
2 changes: 2 additions & 0 deletions apps/platform/src/modules/main-dag/graph-request-service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ export class GraphRequestService extends DefaultRequestService {

async saveDag(dagId: string, model: GraphModel) {
const { nodes: n, edges: e } = model;
this.graphData = model;

const { mode } = parse(window.location.search);
const nodes = await Promise.all(
n.map(async (i) => {
Expand Down
48 changes: 38 additions & 10 deletions apps/platform/src/modules/main-dag/graph-service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { Edge, Graph } from '@antv/x6';
import { ActionType, NodeStatus } from '@secretflow/dag';
import type { GraphNode, Node, GraphEventHandlerProtocol } from '@secretflow/dag';
import type {
GraphNode,
Node,
GraphEventHandlerProtocol,
GraphModel,
} from '@secretflow/dag';
import { Emitter } from '@secretflow/utils';
import { message } from 'antd';
import { parse } from 'query-string';
Expand All @@ -12,7 +17,10 @@ import {
import { updateGraphNode } from '@/services/secretpad/GraphController';
import { getModel } from '@/util/valtio-helper';

import type { ComponentConfig } from '../component-config/component-config-protocol';
import type {
ComponentConfig,
StructConfigNode,
} from '../component-config/component-config-protocol';
import { ComponentConfigRegistry } from '../component-config/component-config-registry';
import { DefaultComponentConfigService } from '../component-config/component-config-service';
import { componentConfigDrawer } from '../component-config/config-modal';
Expand Down Expand Up @@ -250,7 +258,8 @@ export class GraphService implements GraphEventHandlerProtocol {
CUSTOM_COMPONENT.ModelParamModification,
].includes(node?.codeName)
) {
const { attrs, attrPaths, ...restNodeDef } = node.nodeDef || {};
const defaultNodeDef = this.getDefaultNodeDef(node);
const { attrs, attrPaths, ...restNodeDef } = node.nodeDef || defaultNodeDef;
const updatedNode = {
...node,
inputs: [sourcePortId],
Expand All @@ -264,7 +273,7 @@ export class GraphService implements GraphEventHandlerProtocol {
node: updatedNode,
});

mainDag.dataService.fetch();
await mainDag.dataService.fetch();
}
}
}
Expand All @@ -289,8 +298,25 @@ export class GraphService implements GraphEventHandlerProtocol {
].includes(node?.codeName),
)
.map((node) => node.id);
await this.cleanNodeDef(binningModificationNodeIds);
}

this.cleanNodeDef(binningModificationNodeIds);
getDefaultNodeDef(node: GraphNode) {
const { mode } = parse(window.location.search);
const { codeName } = node;
const config = this.componentConfigRegistry.getComponentConfig(
codeName,
mode as ComputeMode,
);
const { version, domain } = config as StructConfigNode;

const [, name] = codeName.split('/');

return {
version,
domain,
name,
};
}

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

const dataNodes = mainDag.dataService.nodes;
const dataNodes = (mainDag.requestService.graphData as GraphModel).nodes;

const nodes = dataNodes.map((node: GraphNode) => {
const defaultNodeDef = this.getDefaultNodeDef(node);

const nodes = dataNodes.map((node) => {
if (nodeIds.includes(node?.id)) {
const { attrs, attrPaths, ...restNodeDef } = node?.nodeDef || {};
const { attrs, attrPaths, ...restNodeDef } = node?.nodeDef || defaultNodeDef;
return {
...node,
nodeDef: {
Expand All @@ -323,7 +351,7 @@ export class GraphService implements GraphEventHandlerProtocol {
});

// 更新最新的 nodes
mainDag.dataService.fetch();
await mainDag.dataService.fetch();
}

saveTemplateQuickConfig = async (quickConfig: {
Expand Down Expand Up @@ -401,7 +429,7 @@ export class GraphService implements GraphEventHandlerProtocol {
)
.map((node) => node.id);

this.cleanNodeDef(binningModificationNodeIds);
await this.cleanNodeDef(binningModificationNodeIds);
} else {
message.error(status?.msg || '操作失败');
}
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/src/modules/managed-node-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export const ManagedNodeListComponent = () => {
type="link"
onClick={() => {
const url =
'https://www.secretflow.org.cn/docs/quickstart/fn9h9yqoievouz2a';
'https://www.secretflow.org.cn/zh-CN/docs/secretpad-all-in-one/center_deploy/platform_installation_guidelines_center';
const a = document.createElement('a');
a.href = url;
a.target = '_blank';
Expand Down
2 changes: 2 additions & 0 deletions apps/platform/src/modules/message-center/message.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { list, reply, pending, detail } from '@/services/secretpad/MessageController';
import { Model } from '@/util/valtio-helper';
import { message } from 'antd';

/**
* This is the service for a message center list. There are list of message items. It allows processing
Expand Down Expand Up @@ -105,6 +106,7 @@ export class MessageService extends Model {
this.messageDetail = info.data;
} else {
this.messageDetail = {};
message.error(info?.status?.msg);
}
this.messageInfoLoading = false;
};
Expand Down
4 changes: 4 additions & 0 deletions apps/platform/src/modules/pipeline/pipeline-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ export class DefaultPipelineService extends Model {
if (project.status !== ProjectStatus.ARCHIVED) {
this.projectEditService.changeCanEdit({
pipelineEditDisabled: false,
advancedConfigDisabled: false,
gotoDataManagerDisabled: false,
});
}
const pipeline = this.pipelines.find((p) => p.graphId === pipelineId);
Expand All @@ -156,6 +158,8 @@ export class DefaultPipelineService extends Model {
pipelineEditDisabled: false,
runAllToolTip: '非我方节点创建,仅可查看',
submitModelDisabled: false,
advancedConfigDisabled: false,
gotoDataManagerDisabled: false,
});
} else {
this.projectEditService.changeCanEditFalse();
Expand Down
Loading

0 comments on commit 4315e3e

Please sign in to comment.