Skip to content

Commit c077db1

Browse files
committed
fix: replicas trigger compatibility
1 parent 801c88a commit c077db1

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

src/pages/llmodels/components/update-modal.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import React, { useEffect, useMemo, useRef } from 'react';
88
import ColumnWrapper from '../../_components/column-wrapper';
99
import {
1010
deployFormKeyMap,
11-
ScheduleValueMap,
12-
updateIgnoreFields
11+
DO_NOT_NOTIFY_RECREATE,
12+
ScheduleValueMap
1313
} from '../config';
1414
import { backendOptionsMap } from '../config/backend-parameters';
1515
import { FormData } from '../config/types';
@@ -65,6 +65,12 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
6565
const setOriginalFormData = () => {
6666
if (!originFormData.current) {
6767
originFormData.current = _.cloneDeep(formData);
68+
if (!originFormData.current.extended_kv_cache?.enabled) {
69+
originFormData.current.extended_kv_cache = {
70+
enabled: false
71+
};
72+
}
73+
// TODO: set speculative_config
6874
}
6975
};
7076

@@ -80,6 +86,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
8086
return undefined;
8187
};
8288

89+
// this function is used compare form data changes in updating model, and show warning if needed
8390
const handleOnValuesChange = _.debounce((data: any) => {
8491
const formdata = formRef.current?.getFieldsValue?.();
8592
console.log('handleOnValuesChange:', formdata);
@@ -103,13 +110,13 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
103110
}
104111

105112
const originalData = _.pick(originFormData.current, Object.keys(alldata));
106-
console.log('alldata:', formdata, alldata, originalData);
107113

108114
const isEqual = _.isEqualWith(
109-
_.omit(alldata, updateIgnoreFields),
110-
_.omit(originalData, updateIgnoreFields),
115+
_.omit(alldata, DO_NOT_NOTIFY_RECREATE),
116+
_.omit(originalData, DO_NOT_NOTIFY_RECREATE),
111117
customizer
112118
);
119+
113120
if (isEqual) {
114121
setWarningStatus({
115122
show: false,
@@ -175,7 +182,6 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
175182
};
176183

177184
const handleManulOnValuesChange = (changedValues: any, allValues: any) => {
178-
console.log('handleManulOnValuesChange:', { changedValues, allValues });
179185
handleOnValuesChange({
180186
changedValues,
181187
allValues,

src/pages/llmodels/config/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,12 @@ export const modelLabels = [
322322
{ label: 'Embedding', value: 'embedding_only' }
323323
];
324324

325-
// do not trigger form check compatibility
326-
export const excludeFields = [
325+
// do not trigger form check compatibility when these fields change
326+
export const DO_NOT_TRIGGER_CHECK_COMPATIBILITY = [
327327
'model_scope_model_id',
328328
'huggingface_repo_id',
329329
'huggingface_filename',
330330
'model_scope_file_path',
331-
'replicas',
332331
'name',
333332
'description',
334333
'env',
@@ -350,11 +349,11 @@ export const excludeFields = [
350349
'extended_kv_cache.enabled'
351350
];
352351

353-
// ingore fields when compare old and new data
354-
export const updateIgnoreFields = ['categories', 'replicas', 'description'];
352+
// ignore to compare old and new data when these fields change in updating model
353+
export const DO_NOT_NOTIFY_RECREATE = ['categories', 'replicas', 'description'];
355354

356355
// if some fields need to trigger manual check, add them here
357-
export const updateExcludeFields = [
356+
export const TRIGGER_CHECK_MANUAL = [
358357
'model_scope_model_id',
359358
'huggingface_repo_id',
360359
'huggingface_filename',

src/pages/llmodels/forms/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import React, { forwardRef, useImperativeHandle, useMemo } from 'react';
88
import styled from 'styled-components';
99
import {
1010
deployFormKeyMap,
11-
excludeFields,
11+
DO_NOT_NOTIFY_RECREATE,
12+
DO_NOT_TRIGGER_CHECK_COMPATIBILITY,
1213
modelSourceMap,
1314
ScheduleValueMap
1415
} from '../config';
@@ -249,7 +250,10 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
249250
const handleOnValuesChange = async (changedValues: any, allValues: any) => {
250251
const fieldName = getFieldPaths(changedValues);
251252

252-
if (excludeFields.includes(fieldName)) {
253+
if (
254+
DO_NOT_TRIGGER_CHECK_COMPATIBILITY.includes(fieldName) ||
255+
(DO_NOT_NOTIFY_RECREATE.includes(fieldName) && action === PageAction.EDIT)
256+
) {
253257
return;
254258
}
255259
onValuesChange?.(changedValues, allValues);

0 commit comments

Comments
 (0)