Skip to content

Commit

Permalink
repo-sync-2024-10-21T17:38:18+0800
Browse files Browse the repository at this point in the history
  • Loading branch information
yinrouni authored and 霓君 committed Oct 21, 2024
1 parent 105b5e7 commit 65f794f
Show file tree
Hide file tree
Showing 73 changed files with 3,210 additions and 376 deletions.
5 changes: 5 additions & 0 deletions apps/platform/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export const routes = [
component: 'model-submission',
wrappers: ['@/wrappers/p2p-center-auth', '@/wrappers/component-wrapper'],
},
{
path: '/periodic-task-detail',
component: 'periodic-task-detail',
wrappers: ['@/wrappers/p2p-center-auth', '@/wrappers/component-wrapper'],
},
{
path: '/node',
component: 'new-node',
Expand Down
1 change: 1 addition & 0 deletions apps/platform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"react-csv": "^2.2.2",
"react-syntax-highlighter": "^15.5.0",
"umi": "^4.0.64",
"uuid": "^10.0.0",
"valtio": "^1.10.7"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions apps/platform/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { history } from 'umi';
import request from 'umi-request';
import { v4 as uuidv4 } from 'uuid';

request.interceptors.request.use((url, options) => {
const traceId = uuidv4(); // 生成唯一的 traceId
const token = localStorage.getItem('User-Token') || '';
return {
url: `${url}`,
Expand All @@ -13,6 +15,7 @@ request.interceptors.request.use((url, options) => {
headers: {
'Content-Type': 'application/json',
'User-Token': token,
'Trace-Id': traceId,
},
},
};
Expand Down
4 changes: 2 additions & 2 deletions apps/platform/src/assets/run-all.icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { SettingOutlined } from '@ant-design/icons';
import { Tooltip } from 'antd';

import { DefaultModalManager } from '@/modules/dag-modal-manager';
import { useModel } from '@/util/valtio-helper';

import {
AdvancedConfig,
AdvancedConfigDrawer,
} from './advanced-config-drawer/advanced-config-view';
import { useModel } from '@/util/valtio-helper';
import { DefaultModalManager } from '@/modules/dag-modal-manager';

import styles from './index.less';
import { Tooltip } from 'antd';

export const AdvancedConfigComponent: React.FC = () => {
const modalManager = useModel(DefaultModalManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const codeNameRenderKey = {
'preprocessing/psi': 'UNION_KEY_SELECT',
'preprocessing/sqlite': 'SQL',
'data_filter/sample': 'SAMPLE',
'ml.predict/read_model': 'MODEL_SELECT', // TODO:修改名称
};

export interface ComponentConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ export const ConfigFormComponent: React.FC<IConfigFormComponent> = (prop) => {
}, [node, nodeId, savedNode, mode, nodeName]);

useEffect(() => {
if (pathname !== '/dag') setIsEditable(false);
if (pathname !== '/dag') {
setIsEditable(false);
return;
}
if (projectEditService.canEdit.configFormDisabled) {
setIsEditable(false);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { LinearModelParametersModificationRender } from './custom-render/linear-
import ObservationsQuantilesRender from './custom-render/observations-quantiles-render';
import { DefaultColSelection } from './default-col-selection-template';
import { DefaultMultiTableFeatureSelection } from './default-feature-selection/default-feature-selection';
import { DefaultModelSelect } from './default-model-selection-template';
import { DefaultNodeSelect } from './default-node-selection-template';
import {
DefaultInputNumber,
Expand Down Expand Up @@ -98,6 +99,12 @@ export class DefaultConfigRender implements ConfigRenderProtocol {
},
component: DefaultTableSelect,
},
{
canHandle: (node: AtomicConfigNode, renderKey?: string) => {
return renderKey === 'MODEL_SELECT' ? 3 : false;
},
component: DefaultModelSelect,
},
{
canHandle: (node: AtomicConfigNode) => {
return node.allowed_values ? 2 : false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const GroupByRender = (prop: { node: AtomicConfigNode }) => {
);

const form = Form.useFormInstance();
const groupCols = Form.useWatch('input/input_data/by', form);
const groupCols = Form.useWatch('input/input_ds/by', form);

return (
<Form.Item name={name} noStyle preserve={false}>
Expand Down Expand Up @@ -169,7 +169,7 @@ export const GroupByRender = (prop: { node: AtomicConfigNode }) => {
{...restField}
className={styles.col}
name={[name, 'column_name']}
dependencies={['input/input_data/by']}
dependencies={['input/input_ds/by']}
rules={[
{ required: true, message: '请选择值列' },
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { AtomicConfigNode } from '../../component-config-protocol';
import styles from '../../index.less';
import type { RenderProp } from '../config-render-protocol';

import { SingleTableFeatureSelection } from './feature-selection-only-one';
import { MultiTableFeatureSelection } from './table-feature-selection';

interface IDataTable {
Expand Down Expand Up @@ -151,17 +152,22 @@ export const DefaultMultiTableFeatureSelection: React.FC<RenderProp<string>> = (
initialValue={defaultVal}
colon={false}
>
<MultiTableFeatureSelection
tableKeys={tables}
outputTableKeys={outputTables}
size={'small'}
fromTableKey={fromTable}
disabled={disabled}
rules={{
min: node.col_min_cnt_inclusive || 0,
max: node.col_max_cnt_inclusive,
}}
/>
{node.col_max_cnt_inclusive === 1 ? (
// 最多只能选择一列则变为单选下拉框
<SingleTableFeatureSelection tableKeys={tables} fromTableKey={fromTable} />
) : (
<MultiTableFeatureSelection
tableKeys={tables} // 上游的输出表
outputTableKeys={outputTables} // 上游所有的输出表
size={'small'}
fromTableKey={fromTable} // 上游输入的样本表
disabled={disabled}
rules={{
min: node.col_min_cnt_inclusive || 0,
max: node.col_max_cnt_inclusive,
}}
/>
)}
</Form.Item>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { useDeepCompareEffect } from 'ahooks';
import { Select } from 'antd';
import { uniqBy } from 'lodash';
import { parse } from 'query-string';
import { useState } from 'react';
import { useLocation } from 'umi';

import { getGraphNodeOutput } from '@/services/secretpad/GraphController';
import { getProjectDatatable } from '@/services/secretpad/ProjectController';

import type { TableInfoType } from './type';

export interface IProps {
/** 上游的输出表 */
tableKeys: TableInfoType[];
/** 上游输入的样本表 */
fromTableKey?: TableInfoType;
onChange?: (values: string[]) => void;
value?: string[];
}

export const SingleTableFeatureSelection = (props: IProps) => {
const { tableKeys: tables, fromTableKey: fromTable, value = [], onChange } = props;
const [colsOptions, setCols] = useState<{ value: string; label: string }[]>([]);
const { search } = useLocation();

const { projectId, dagId } = parse(search) as { projectId: string; dagId: string };

useDeepCompareEffect(() => {
const getSchema = async () => {
const tableFields: { colName: string; colType: string }[] = [];
// 利用最上游输入的样本表 fromTable 和 上游的输出表(tables) 来进行获取特征
const schemaArr = fromTable ? [fromTable, ...tables] : tables;
await Promise.all(
schemaArr.map(async (s) => {
const { datatableId, nodeId, graphNodeId } = s;

if (!nodeId && graphNodeId) {
const { data } = await getGraphNodeOutput({
projectId,
graphId: dagId,
graphNodeId,
outputId: datatableId,
});

if (data?.meta?.rows?.length) {
data.meta.rows.forEach(
({ fieldTypes, fields }: { fieldTypes: string; fields: string }) => {
if (fieldTypes && fields) {
const fieldList = fields.split(',');
const fieldTypeList = fieldTypes.split(',');
tableFields.push(
...fieldList.map((f, i) => ({
colName: f,
colType: fieldTypeList[i],
})),
);
}
},
);
}
} else {
const { data } = await getProjectDatatable({
datatableId,
nodeId,
projectId,
type: 'CSV',
});
if (!data) return;
const { configs } = data;
configs.map((c) => {
tableFields.push({ colName: c.colName, colType: c.colType });
});
}
}),
);
const selectOptions = tableFields.map(
(option: { colName: string; colType: string }) => ({
value: option.colName,
label: option.colName,
key: `${option.colName}_${option.colType}`,
}),
);
const cols = uniqBy(selectOptions, 'key');
setCols(cols);
};
getSchema();
}, [fromTable, tables]);

return (
<Select
maxCount={1}
mode="multiple"
value={value}
onChange={onChange}
options={colsOptions}
showSearch
filterOption={(input: string, option?: { label: string; value: string }) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export const MultiTableFeatureSelection = (props: IProps) => {
{showFields && <FieldMiniTable selectedFields={fields} />}
<MultiFieldSelectModal
visible={showSelectorModal}
tableInfos={tableKeys}
fromTableInfo={fromTableKey}
outputTableInfos={outputTableKeys}
tableInfos={tableKeys} // 上游的输出表
fromTableInfo={fromTableKey} // 上游输入的样本表
outputTableInfos={outputTableKeys} // 上游所有的输出表
multiple={Array.isArray(tableKeys) && tableKeys.length > 1}
submit={onChange}
fields={fields.map((f: string) => ({ colName: f }))}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { parse } from 'query-string';
import { useState, useEffect } from 'react';
import { Form, Select } from 'antd';

import type { RenderProp } from './config-render-protocol';

import { modelPackPage } from '@/services/secretpad/ModelManagementController';
import styles from '../index.less';

export const DefaultModelSelect: React.FC<RenderProp<string>> = (config) => {
const { onChange, value, defaultVal, node, translation } = config;

const [modelList, setModelList] = useState<
{
modelName: string;
modelId: string;
}[]
>([]);

useEffect(() => {
const getModelList = async () => {
const { search } = window.location;
const { projectId } = parse(search) as { projectId: string };

const { data, status } = await modelPackPage({
projectId: projectId,
page: 1,
size: 1000,
});
if (status && status.code === 0 && data) {
const modelList = (data?.modelPacks || []).map((item) => ({
modelName: item.modelName!,
modelId: item.modelId!,
}));
setModelList(modelList);
} else {
setModelList([]);
}
};
getModelList();
}, []);

return (
<Form.Item noStyle>
<Form.Item
label={
<div className={styles.configItemLabel}>
{translation[node.name] || node.name}
</div>
}
name={
node.prefixes && node.prefixes.length > 0
? node.prefixes.join('/') + '/' + node.name
: node.name
}
messageVariables={{ label: translation[node.name] || node.name }}
tooltip={
node.docString ? translation[node.docString] || node.docString : undefined
}
rules={[
{
required: node.isRequired,
},
]}
initialValue={defaultVal}
colon={false}
>
<Select
value={value}
onChange={(val) => {
onChange(val);
}}
showSearch
filterOption={(input: string, option?: { label: string; value: string }) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
options={modelList.map((item) => ({
label: item.modelName,
value: item.modelId,
}))}
></Select>
</Form.Item>
</Form.Item>
);
};
Loading

0 comments on commit 65f794f

Please sign in to comment.