fix: do not trigger evaluation replica 0
This commit is contained in:
@@ -331,7 +331,6 @@ export const DO_NOT_TRIGGER_CHECK_COMPATIBILITY = [
|
|||||||
'huggingface_repo_id',
|
'huggingface_repo_id',
|
||||||
'huggingface_filename',
|
'huggingface_filename',
|
||||||
'model_scope_file_path',
|
'model_scope_file_path',
|
||||||
'replicas',
|
|
||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
'env',
|
'env',
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { useIntl } from '@umijs/max';
|
|||||||
import { Form } from 'antd';
|
import { Form } from 'antd';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { sourceOptions } from '../config';
|
import { sourceOptions } from '../config';
|
||||||
import { useFormContext } from '../config/form-context';
|
|
||||||
import { FormData } from '../config/types';
|
import { FormData } from '../config/types';
|
||||||
import CatalogFrom from './catalog';
|
import CatalogFrom from './catalog';
|
||||||
import LocalPathSource from './local-path-source';
|
import LocalPathSource from './local-path-source';
|
||||||
@@ -35,19 +34,12 @@ const BasicForm: React.FC<BasicFormProps> = (props) => {
|
|||||||
} = props;
|
} = props;
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { getRuleMessage } = useAppUtils();
|
const { getRuleMessage } = useAppUtils();
|
||||||
const { onValuesChange } = useFormContext();
|
|
||||||
const form = Form.useFormInstance();
|
const form = Form.useFormInstance();
|
||||||
|
|
||||||
const handleOnSourceChange = (val: string) => {
|
const handleOnSourceChange = (val: string) => {
|
||||||
onSourceChange?.(val);
|
onSourceChange?.(val);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleReplicasChange = (val: number) => {
|
|
||||||
if (val > 0) {
|
|
||||||
onValuesChange?.({}, form.getFieldsValue());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const clusterOptions = useMemo(() => {
|
const clusterOptions = useMemo(() => {
|
||||||
return clusterList?.map((item) => {
|
return clusterList?.map((item) => {
|
||||||
return {
|
return {
|
||||||
@@ -134,7 +126,6 @@ const BasicForm: React.FC<BasicFormProps> = (props) => {
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SealInput.Number
|
<SealInput.Number
|
||||||
onChange={handleReplicasChange}
|
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
id: 'models.form.replicas'
|
id: 'models.form.replicas'
|
||||||
|
|||||||
@@ -81,16 +81,6 @@ const ScheduleTypeForm: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleGpusPerReplicasChange = (val: string | number | null) => {
|
|
||||||
if (val === null) {
|
|
||||||
form.setFieldValue(['gpu_selector', 'gpus_per_replica'], -1);
|
|
||||||
} else {
|
|
||||||
form.setFieldValue(['gpu_selector', 'gpus_per_replica'], val);
|
|
||||||
}
|
|
||||||
|
|
||||||
onValuesChange?.({}, form.getFieldsValue());
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleGpuSelectorChange = (value: any[]) => {
|
const handleGpuSelectorChange = (value: any[]) => {
|
||||||
if (value.length > 0) {
|
if (value.length > 0) {
|
||||||
onValuesChange?.({}, form.getFieldsValue());
|
onValuesChange?.({}, form.getFieldsValue());
|
||||||
@@ -99,23 +89,6 @@ const ScheduleTypeForm: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnStepReplicaStep = (
|
|
||||||
value: number | string | null,
|
|
||||||
info: { offset: number | string | null; type: 'up' | 'down' }
|
|
||||||
) => {
|
|
||||||
let newValue = value;
|
|
||||||
const isPowerOfTwo = (n: number) => (n & (n - 1)) === 0 && n !== 0; // check power of two
|
|
||||||
if (!isPowerOfTwo(value as number)) {
|
|
||||||
if (info.type === 'up') {
|
|
||||||
newValue = Math.pow(2, Math.ceil(Math.log2(value as number)));
|
|
||||||
} else {
|
|
||||||
newValue = Math.pow(2, Math.floor(Math.log2(value as number)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
form.setFieldValue(['gpu_selector', 'gpus_per_replica'], newValue);
|
|
||||||
onValuesChange?.({}, form.getFieldsValue());
|
|
||||||
};
|
|
||||||
|
|
||||||
const onSelectorChange = (field: string, allowEmpty?: boolean) => {
|
const onSelectorChange = (field: string, allowEmpty?: boolean) => {
|
||||||
const workerSelector = form.getFieldValue(field);
|
const workerSelector = form.getFieldValue(field);
|
||||||
// check if all keys have values
|
// check if all keys have values
|
||||||
|
|||||||
@@ -392,9 +392,11 @@ export const useCheckCompatibility = () => {
|
|||||||
source: string;
|
source: string;
|
||||||
}) => {
|
}) => {
|
||||||
const { allValues, source } = params;
|
const { allValues, source } = params;
|
||||||
|
console.log('handleOnValuesChange', allValues);
|
||||||
if (
|
if (
|
||||||
_.isEqual(cacheFormValuesRef.current, allValues) ||
|
_.isEqual(cacheFormValuesRef.current, allValues) ||
|
||||||
noLocalPathValue(allValues)
|
noLocalPathValue(allValues) ||
|
||||||
|
!allValues.replicas
|
||||||
) {
|
) {
|
||||||
console.log('No changes detected, skipping evaluation.');
|
console.log('No changes detected, skipping evaluation.');
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user