| @@ -1,7 +1,10 @@ | |||||
| import { ServiceData } from '@/pages/ModelDeployment/types'; | |||||
| import { getDatasetList, getModelList } from '@/services/dataset/index.js'; | import { getDatasetList, getModelList } from '@/services/dataset/index.js'; | ||||
| import { getServiceListReq } from '@/services/modelDeployment'; | |||||
| import { getComputingResourceReq } from '@/services/pipeline'; | import { getComputingResourceReq } from '@/services/pipeline'; | ||||
| import { ComputingResource } from '@/types'; | import { ComputingResource } from '@/types'; | ||||
| import { type SelectProps } from 'antd'; | import { type SelectProps } from 'antd'; | ||||
| import { pick } from 'lodash'; | |||||
| // 过滤资源规格 | // 过滤资源规格 | ||||
| const filterResourceStandard: SelectProps<string, ComputingResource>['filterOption'] = ( | const filterResourceStandard: SelectProps<string, ComputingResource>['filterOption'] = ( | ||||
| @@ -62,6 +65,25 @@ export const paramSelectConfig: Record<string, SelectPropsConfig> = { | |||||
| }, | }, | ||||
| optionFilterProp: 'name', | optionFilterProp: 'name', | ||||
| }, | }, | ||||
| service: { | |||||
| getOptions: async () => { | |||||
| const res = await getServiceListReq({ | |||||
| page: 0, | |||||
| size: 1000, | |||||
| }); | |||||
| return ( | |||||
| res?.data?.content?.map((item: ServiceData) => ({ | |||||
| label: item.service_name, | |||||
| value: JSON.stringify(pick(item, ['id', 'service_name'])), | |||||
| })) ?? [] | |||||
| ); | |||||
| }, | |||||
| fieldNames: { | |||||
| label: 'label', | |||||
| value: 'value', | |||||
| }, | |||||
| optionFilterProp: 'label', | |||||
| }, | |||||
| resource: { | resource: { | ||||
| getOptions: async () => { | getOptions: async () => { | ||||
| const res = await getComputingResourceReq({ | const res = await getComputingResourceReq({ | ||||
| @@ -24,7 +24,7 @@ import SessionStorage from '@/utils/sessionStorage'; | |||||
| import { modalConfirm } from '@/utils/ui'; | import { modalConfirm } from '@/utils/ui'; | ||||
| import { PlusOutlined } from '@ant-design/icons'; | import { PlusOutlined } from '@ant-design/icons'; | ||||
| import { useNavigate, useParams } from '@umijs/max'; | import { useNavigate, useParams } from '@umijs/max'; | ||||
| import { App, Button, Col, Flex, Form, Input, Row, Select } from 'antd'; | |||||
| import { App, Button, Col, Flex, Form, Input, InputNumber, Row, Select } from 'antd'; | |||||
| import { omit, pick } from 'lodash'; | import { omit, pick } from 'lodash'; | ||||
| import { useEffect, useState } from 'react'; | import { useEffect, useState } from 'react'; | ||||
| import { | import { | ||||
| @@ -120,11 +120,11 @@ function CreateServiceVersion() { | |||||
| // 创建版本 | // 创建版本 | ||||
| const createServiceVersion = async (formData: FormData) => { | const createServiceVersion = async (formData: FormData) => { | ||||
| const envList = formData['env_variables'] ?? []; | |||||
| const envList = formData['env_variables']; | |||||
| const image = formData['image']; | const image = formData['image']; | ||||
| const model = formData['model']; | const model = formData['model']; | ||||
| const codeConfig = formData['code_config']; | const codeConfig = formData['code_config']; | ||||
| const envVariables = envList.reduce((acc, cur) => { | |||||
| const envVariables = envList?.reduce((acc, cur) => { | |||||
| acc[cur.key] = cur.value; | acc[cur.key] = cur.value; | ||||
| return acc; | return acc; | ||||
| }, {} as Record<string, string>); | }, {} as Record<string, string>); | ||||
| @@ -139,9 +139,11 @@ function CreateServiceVersion() { | |||||
| pick(model, ['id', 'name', 'version', 'path', 'identifier', 'owner', 'showValue']), | pick(model, ['id', 'name', 'version', 'path', 'identifier', 'owner', 'showValue']), | ||||
| { showValue: 'show_value' }, | { showValue: 'show_value' }, | ||||
| ), | ), | ||||
| code_config: changePropertyName(pick(codeConfig, ['code_path', 'branch', 'showValue']), { | |||||
| showValue: 'show_value', | |||||
| }), | |||||
| code_config: codeConfig | |||||
| ? changePropertyName(pick(codeConfig, ['code_path', 'branch', 'showValue']), { | |||||
| showValue: 'show_value', | |||||
| }) | |||||
| : undefined, | |||||
| service_id: serviceInfo?.id, | service_id: serviceInfo?.id, | ||||
| }; | }; | ||||
| @@ -334,17 +336,7 @@ function CreateServiceVersion() { | |||||
| </Row> | </Row> | ||||
| <Row gutter={8}> | <Row gutter={8}> | ||||
| <Col span={10}> | <Col span={10}> | ||||
| <Form.Item | |||||
| label="代码配置" | |||||
| name="code_config" | |||||
| rules={[ | |||||
| { | |||||
| validator: requiredValidator, | |||||
| message: '请选择代码配置', | |||||
| }, | |||||
| ]} | |||||
| required | |||||
| > | |||||
| <Form.Item label="代码配置" name="code_config"> | |||||
| <CodeSelect | <CodeSelect | ||||
| placeholder="请选择代码配置" | placeholder="请选择代码配置" | ||||
| canInput={false} | canInput={false} | ||||
| @@ -395,7 +387,12 @@ function CreateServiceVersion() { | |||||
| }, | }, | ||||
| ]} | ]} | ||||
| > | > | ||||
| <Input placeholder="请输入副本数量" allowClear /> | |||||
| <InputNumber | |||||
| style={{ width: '100%' }} | |||||
| placeholder="请输入副本数量" | |||||
| min={1} | |||||
| precision={0} | |||||
| /> | |||||
| </Form.Item> | </Form.Item> | ||||
| </Col> | </Col> | ||||
| </Row> | </Row> | ||||
| @@ -117,6 +117,11 @@ function ServiceInfo() { | |||||
| const [res] = await to(getServiceVersionsReq(params)); | const [res] = await to(getServiceVersionsReq(params)); | ||||
| if (res && res.data) { | if (res && res.data) { | ||||
| const { content = [], totalElements = 0 } = res.data; | const { content = [], totalElements = 0 } = res.data; | ||||
| content.forEach((item: ServiceVersionData) => { | |||||
| if (item.model && !item.model.show_value) { | |||||
| item.model.show_value = `${item.model.name}:${item.model.version}`; | |||||
| } | |||||
| }); | |||||
| setTableData(content); | setTableData(content); | ||||
| setTotal(totalElements); | setTotal(totalElements); | ||||
| } | } | ||||
| @@ -27,7 +27,7 @@ function BasicInfo({ info }: BasicInfoProps) { | |||||
| }; | }; | ||||
| const formatCodeConfig = () => { | const formatCodeConfig = () => { | ||||
| if (info && info.code_config) { | |||||
| if (info && info.code_config && info.code_config.code_path) { | |||||
| const { code_path, branch } = info.code_config; | const { code_path, branch } = info.code_config; | ||||
| const url = getGitUrl(code_path, branch); | const url = getGitUrl(code_path, branch); | ||||
| return ( | return ( | ||||
| @@ -36,7 +36,7 @@ function BasicInfo({ info }: BasicInfoProps) { | |||||
| </a> | </a> | ||||
| ); | ); | ||||
| } | } | ||||
| return undefined; | |||||
| return '--'; | |||||
| }; | }; | ||||
| const formatResource = () => { | const formatResource = () => { | ||||
| @@ -43,22 +43,34 @@ const PipelineNodeParameter = forwardRef(({ onFormChange }: PipelineNodeParamete | |||||
| if (!open) { | if (!open) { | ||||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||||
| const [_values, error] = await to(form.validateFields()); | const [_values, error] = await to(form.validateFields()); | ||||
| // 不管是否验证成功,都需要获取表单数据 | |||||
| const fields = form.getFieldsValue(); | const fields = form.getFieldsValue(); | ||||
| const control_strategy = JSON.stringify(fields.control_strategy); | |||||
| const in_parameters = JSON.stringify(fields.in_parameters); | |||||
| const out_parameters = JSON.stringify(fields.out_parameters); | |||||
| // 保存字段顺序 | |||||
| const control_strategy = { | |||||
| ...stagingItem.control_strategy, | |||||
| ...fields.control_strategy, | |||||
| }; | |||||
| const in_parameters = { | |||||
| ...stagingItem.in_parameters, | |||||
| ...fields.in_parameters, | |||||
| }; | |||||
| const out_parameters = { | |||||
| ...stagingItem.out_parameters, | |||||
| ...fields.out_parameters, | |||||
| }; | |||||
| // console.log('getFieldsValue', fields); | // console.log('getFieldsValue', fields); | ||||
| const res = { | const res = { | ||||
| ...stagingItem, | ...stagingItem, | ||||
| ...fields, | ...fields, | ||||
| control_strategy: control_strategy, | |||||
| in_parameters: in_parameters, | |||||
| out_parameters: out_parameters, | |||||
| control_strategy: JSON.stringify(control_strategy), | |||||
| in_parameters: JSON.stringify(in_parameters), | |||||
| out_parameters: JSON.stringify(out_parameters), | |||||
| formError: !!error, | formError: !!error, | ||||
| }; | }; | ||||
| console.log('res', res); | |||||
| // console.log('res', res); | |||||
| onFormChange(res); | onFormChange(res); | ||||
| } | } | ||||
| }; | }; | ||||