fix: cpu init value failed
This commit is contained in:
@@ -381,8 +381,7 @@ export default (props: any) => {
|
|||||||
menuFooterRender={() => (
|
menuFooterRender={() => (
|
||||||
<Button
|
<Button
|
||||||
style={{
|
style={{
|
||||||
border: 'none',
|
border: 'none'
|
||||||
cursor: collapsed ? 'e-resize' : 'w-resize'
|
|
||||||
}}
|
}}
|
||||||
size="small"
|
size="small"
|
||||||
type={'text'}
|
type={'text'}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
|
|||||||
const formAction =
|
const formAction =
|
||||||
realAction === PageAction.CREATE ? PageAction.CREATE : action;
|
realAction === PageAction.CREATE ? PageAction.CREATE : action;
|
||||||
const sshEnabled = Form.useWatch('enable_ssh', form);
|
const sshEnabled = Form.useWatch('enable_ssh', form);
|
||||||
const description = Form.useWatch(['spec', 'description'], form);
|
const description = Form.useWatch(['description'], form);
|
||||||
// `organization_id` is owned by the create-scope picker slot; it only
|
// `organization_id` is owned by the create-scope picker slot; it only
|
||||||
// exists/changes when a platform admin retargets the form. Watch it
|
// exists/changes when a platform admin retargets the form. Watch it
|
||||||
// so the parent can re-scope offerings (see onScopeChange).
|
// so the parent can re-scope offerings (see onScopeChange).
|
||||||
@@ -151,6 +151,7 @@ const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
|
|||||||
|
|
||||||
const isGPUType = useMemo(() => {
|
const isGPUType = useMemo(() => {
|
||||||
const spec = parseJsonSafe(description || '{}', {} as any)?.spec;
|
const spec = parseJsonSafe(description || '{}', {} as any)?.spec;
|
||||||
|
console.log('derived spec from description', spec);
|
||||||
return spec?.acceleratable;
|
return spec?.acceleratable;
|
||||||
}, [description]);
|
}, [description]);
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ import { InputNumber } from '@gpustack/core-ui';
|
|||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Flex, Form } from 'antd';
|
import { Flex, Form } from 'antd';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { useMemo } from 'react';
|
import { useContext, useMemo } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { BasicResourceMax } from '../../templates/forms/basic';
|
import { BasicResourceMax } from '../../templates/forms/basic';
|
||||||
import { parseJsonSafe } from '../../utils';
|
import { parseJsonSafe } from '../../utils';
|
||||||
import InstanceTypeItem, {
|
import InstanceTypeItem, {
|
||||||
InstanceMetadataSection
|
InstanceMetadataSection
|
||||||
} from '../components/instance-type-item';
|
} from '../components/instance-type-item';
|
||||||
|
import { FormContext } from '../config/form-context';
|
||||||
import {
|
import {
|
||||||
FormData,
|
FormData,
|
||||||
InstanceTypeItem as InstanceTypeItemModel,
|
InstanceTypeItem as InstanceTypeItemModel,
|
||||||
@@ -79,6 +80,7 @@ const InstanceTypeFormItem: React.FC<InstanceTypeFormItemProps> = ({
|
|||||||
onGPUCountChange
|
onGPUCountChange
|
||||||
}) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const { isGPUType } = useContext(FormContext);
|
||||||
|
|
||||||
const maxComputeUnitCount = useMemo(() => {
|
const maxComputeUnitCount = useMemo(() => {
|
||||||
if (action === PageAction.EDIT) {
|
if (action === PageAction.EDIT) {
|
||||||
@@ -110,7 +112,7 @@ const InstanceTypeFormItem: React.FC<InstanceTypeFormItemProps> = ({
|
|||||||
return (
|
return (
|
||||||
<Flex gap={4} align="center">
|
<Flex gap={4} align="center">
|
||||||
{label}
|
{label}
|
||||||
{!isGPU && (
|
{!isGPUType && (
|
||||||
<span>
|
<span>
|
||||||
({intl.formatMessage({ id: 'common.max' }, { count: max })})
|
({intl.formatMessage({ id: 'common.max' }, { count: max })})
|
||||||
</span>
|
</span>
|
||||||
@@ -120,7 +122,7 @@ const InstanceTypeFormItem: React.FC<InstanceTypeFormItemProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const renderMemoryLabel = (): React.ReactNode => {
|
const renderMemoryLabel = (): React.ReactNode => {
|
||||||
if (isGPU || action === PageAction.EDIT || !onceMaxRequest?.memory) {
|
if (isGPUType || action === PageAction.EDIT || !onceMaxRequest?.memory) {
|
||||||
return intl.formatMessage({ id: 'gpuservice.template.memory' });
|
return intl.formatMessage({ id: 'gpuservice.template.memory' });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +163,7 @@ const InstanceTypeFormItem: React.FC<InstanceTypeFormItemProps> = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const numberSelectionLabel = isGPU
|
const numberSelectionLabel = isGPUType
|
||||||
? {
|
? {
|
||||||
label: 'GPU',
|
label: 'GPU',
|
||||||
maxLabel: 'gpuservice.instance.gpuCount.max',
|
maxLabel: 'gpuservice.instance.gpuCount.max',
|
||||||
@@ -197,12 +199,13 @@ const InstanceTypeFormItem: React.FC<InstanceTypeFormItemProps> = ({
|
|||||||
</FieldBlock>
|
</FieldBlock>
|
||||||
{!noAvailableTypes && (
|
{!noAvailableTypes && (
|
||||||
<Form.Item<FormData>
|
<Form.Item<FormData>
|
||||||
key={isGPU ? 'accelerator' : 'cpu'}
|
key={isGPUType ? 'accelerator' : 'cpu'}
|
||||||
name={
|
name={
|
||||||
isGPU
|
isGPUType
|
||||||
? ['spec', 'resources', 'accelerator']
|
? ['spec', 'resources', 'accelerator']
|
||||||
: ['spec', 'resources', 'cpu']
|
: ['spec', 'resources', 'cpu']
|
||||||
}
|
}
|
||||||
|
preserve
|
||||||
hidden={action === PageAction.EDIT}
|
hidden={action === PageAction.EDIT}
|
||||||
normalize={(value) => (value != null ? _.toString(value) : undefined)}
|
normalize={(value) => (value != null ? _.toString(value) : undefined)}
|
||||||
getValueProps={(value) => ({
|
getValueProps={(value) => ({
|
||||||
@@ -271,11 +274,12 @@ const InstanceTypeFormItem: React.FC<InstanceTypeFormItemProps> = ({
|
|||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
{isGPU && (
|
{isGPUType && (
|
||||||
<div style={{ flex: 1 }}>
|
<div style={{ flex: 1 }}>
|
||||||
<Form.Item<FormData>
|
<Form.Item<FormData>
|
||||||
name={['spec', 'resources', 'cpu']}
|
name={['spec', 'resources', 'cpu']}
|
||||||
key="cpu_input"
|
key="cpu_input"
|
||||||
|
preserve
|
||||||
>
|
>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
label={'CPU'}
|
label={'CPU'}
|
||||||
|
|||||||
Reference in New Issue
Block a user