Skip to content

Commit 6a1b2f9

Browse files
committed
fix: custom backend version suffix
1 parent b733b36 commit 6a1b2f9

File tree

19 files changed

+98
-89
lines changed

19 files changed

+98
-89
lines changed

src/components/seal-form/wrapper/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,13 @@ const Extra = styled.div`
170170

171171
const AddAfter = styled.div`
172172
position: relative;
173-
color: var(--ant-color-text-quaternary);
173+
color: var(--ant-color-text-tertiary);
174174
font-size: var(--font-size-base);
175-
padding-right: calc(var(--ant-padding-sm) - 1px);
175+
padding-inline: calc(var(--ant-padding-sm) - 1px);
176+
height: 100%;
177+
display: flex;
178+
align-items: center;
179+
background-color: var(--ant-color-fill-secondary);
176180
`;
177181

178182
// for wrapper

src/locales/en-US/backends.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export default {
1919
'backend.mode.yaml': 'YAML Mode',
2020
'backend.form.healthCheckPath': 'Health Check Path',
2121
'backend.form.defaultExecuteCommand': 'Default Execution Command',
22+
'backend.form.defaultExecuteCommand.tips':
23+
'{{model_path}} is the model path, and {{port}} is the service port. These variable names cannot be modified.',
2224
'backend.form.defaultBackendParameters': 'Default Backend Parameters',
2325
'backend.form.versionConfig': 'Versions Config',
2426
'backend.form.addParameter': 'Add Parameter',
@@ -27,5 +29,5 @@ export default {
2729
'backend.versionInfo.autoImage': 'Automatically selected at runtime',
2830
'backend.version.rules.builtin': 'Must end with "-custom"',
2931
'backend.version.no.tips':
30-
'Built-in backend versions must end with "-custom".'
32+
'The name of a custom version must end with "-custom."'
3133
};

src/locales/ja-JP/backends.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export default {
1919
'backend.mode.yaml': 'YAML Mode',
2020
'backend.form.healthCheckPath': 'Health Check Path',
2121
'backend.form.defaultExecuteCommand': 'Default Execution Command',
22+
'backend.form.defaultExecuteCommand.tips':
23+
'{{model_path}} is the model path, and {{port}} is the service port. These variable names cannot be modified.',
2224
'backend.form.defaultBackendParameters': 'Default Backend Parameters',
2325
'backend.form.versionConfig': 'Versions Config',
2426
'backend.form.addParameter': 'Add Parameter',
@@ -27,5 +29,5 @@ export default {
2729
'backend.versionInfo.autoImage': 'Automatically selected at runtime',
2830
'backend.version.rules.builtin': 'Must end with "-custom"',
2931
'backend.version.no.tips':
30-
'Built-in backend versions must end with "-custom".'
32+
'The name of a custom version must end with "-custom."'
3133
};

src/locales/ru-RU/backends.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export default {
1919
'backend.mode.yaml': 'Режим YAML',
2020
'backend.form.healthCheckPath': 'Путь проверки здоровья',
2121
'backend.form.defaultExecuteCommand': 'Команда выполнения по умолчанию',
22+
'backend.form.defaultExecuteCommand.tips':
23+
'{{model_path}} is the model path, and {{port}} is the service port. These variable names cannot be modified.',
2224
'backend.form.defaultBackendParameters': 'Параметры бэкенда по умолчанию',
2325
'backend.form.versionConfig': 'Конфигурация версий',
2426
'backend.form.addParameter': 'Добавить параметр',
@@ -27,9 +29,10 @@ export default {
2729
'backend.versionInfo.autoImage': 'Автоматически выбор во время запуска',
2830
'backend.version.rules.builtin': 'Должен заканчиваться на "-custom"',
2931
'backend.version.no.tips':
30-
'Built-in backend versions must end with "-custom".'
32+
'The name of a custom version must end with "-custom."'
3133
};
3234

3335
// ========== To-Do: Translate Keys (Remove After Translation) ==========
34-
// 1. 'backend.version.no.tips': 'Built-in backend versions must end with "-custom".'
36+
// 1. 'backend.form.defaultExecuteCommand.tips': '{{model_path}} is the model path, and {{port}} is the service port. These variable names cannot be modified.'
37+
// 2. 'backend.version.no.tips': 'The name of a custom version must end with "-custom."'
3538
// ========== End of To-Do List ==========

src/locales/zh-CN/backends.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ export default {
1919
'backend.mode.yaml': 'YAML 模式',
2020
'backend.form.healthCheckPath': '健康检查路径',
2121
'backend.form.defaultExecuteCommand': '默认执行命令',
22+
'backend.form.defaultExecuteCommand.tips':
23+
'{{model_path}} 为模型文件路径,{{port}} 为服务端口,这两个变量名不可更改。',
2224
'backend.form.defaultBackendParameters': '默认后端参数',
2325
'backend.form.versionConfig': '版本配置',
2426
'backend.form.addParameter': '添加参数',
2527
'backend.form.noVersion': '未添加版本',
2628
'backend.noVersion': '未找到版本',
2729
'backend.versionInfo.autoImage': '运行时自动选择',
2830
'backend.version.rules.builtin': '须以 "-custom" 结尾',
29-
'backend.version.no.tips': '内置的后端版本须以 "-custom" 结尾。'
31+
'backend.version.no.tips': '自定义版本名称必须以 "-custom" 结尾。'
3032
};

src/pages/backends/components/add-modal.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ const AddModal: React.FC<AddModalProps> = (props) => {
5353
const [yamlContent, setYamlContent] = useState<string>('');
5454
const [formContent, setFormContent] = useState<FormData>({} as FormData);
5555

56+
const genertateCurrentData = (values: ListItem): ListItem => {
57+
const data = { ...values };
58+
data.version_configs = Object.entries(data.version_configs || {}).reduce(
59+
(acc, [key, value]) => {
60+
const version = key.replace(/-custom$/, '');
61+
acc[version] = { ...value };
62+
return acc;
63+
},
64+
{} as any
65+
);
66+
67+
return data;
68+
};
69+
5670
const onOk = () => {
5771
if (activeKey === 'yaml') {
5872
const content = editorRef.current?.getContent();
@@ -90,9 +104,12 @@ const AddModal: React.FC<AddModalProps> = (props) => {
90104
};
91105

92106
useEffect(() => {
93-
const iniFormContent = (values: any) => {
107+
const iniFormContent = (data: ListItem) => {
108+
const values: any = genertateCurrentData(data);
109+
110+
// custom versions
94111
const versionConfigs = Object.keys(values.version_configs || {}).map(
95-
(key) => ({
112+
(key: string) => ({
96113
version_no: key,
97114
image_name: values.version_configs?.[key]?.image_name,
98115
run_command: values.version_configs?.[key]?.run_command,
@@ -101,6 +118,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
101118
})
102119
);
103120

121+
// built-in versions
104122
const builtInVersions = Object.keys(
105123
values.built_in_version_configs || {}
106124
).map((key) => ({

src/pages/backends/components/import-yaml.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
101101
const getContent = () => {
102102
try {
103103
const content = editorRef.current?.getValue();
104-
if (actionStatus.isBuiltIn) {
105-
const jsonData = yaml2Json(content);
106-
const exsistingVersions = Object.keys(jsonData.version_configs || {});
107-
const invalidVersion = exsistingVersions.find(
108-
(v) => !v.endsWith('-custom')
109-
);
110-
if (invalidVersion) {
111-
setError(intl.formatMessage({ id: 'backend.version.no.tips' }));
112-
return false;
113-
}
104+
105+
const jsonData = yaml2Json(content);
106+
const exsistingVersions = Object.keys(jsonData.version_configs || {});
107+
const invalidVersion = exsistingVersions.find(
108+
(v) => !v.endsWith('-custom')
109+
);
110+
if (invalidVersion) {
111+
setError(intl.formatMessage({ id: 'backend.version.no.tips' }));
112+
return false;
114113
}
114+
115115
return content;
116116
} catch (error) {
117117
return false;

src/pages/backends/config/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ default_version: v0.5.1
150150
health_check_path: /v1/models
151151
default_backend_param:
152152
- --host
153-
default_run_command: myBackend serve {{model}} --port {{port}}
153+
default_run_command: myBackend serve {{model_path}} --port {{port}}
154154
version_configs:
155-
v0.0.1:
155+
v0.0.1-custom:
156156
image_name: lm/mybackend:latest
157-
run_command: myBackend serve {{model}} --port {{port}}
157+
run_command: myBackend serve {{model_path}} --port {{port}}
158158
custom_framework: cuda
159-
v0.0.2:
159+
v0.0.2-custom:
160160
image_name: lm/mybackend:test
161161
run_command:
162162
custom_framework:

src/pages/backends/forms/basic.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ const BasicForm: React.FC<AddModalProps> = ({ action }) => {
5353
<SealTextArea
5454
scaleSize={true}
5555
alwaysFocus={true}
56+
description={intl.formatMessage({
57+
id: 'backend.form.defaultExecuteCommand.tips'
58+
})}
5659
placeholder={intl.formatMessage(
5760
{ id: 'common.help.eg' },
58-
{ content: 'vllm serve {{model}} --port {{port}}' }
61+
{ content: 'vllm serve {{model_path}} --port {{port}}' }
5962
)}
6063
autoSize={{ minRows: 2, maxRows: 4 }}
6164
label={intl.formatMessage({

src/pages/backends/forms/index.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ const BackendForm: React.FC<AddModalProps> = forwardRef(
3333
}
3434
};
3535

36+
const handleOnFinish = (values: FormData) => {
37+
const data = { ...values };
38+
data.version_configs = data.version_configs?.map((item) => {
39+
if (item.version_no) {
40+
return {
41+
...item,
42+
version_no: `${item.version_no}-custom`
43+
};
44+
}
45+
return item;
46+
});
47+
48+
onFinish(data);
49+
};
50+
3651
useEffect(() => {
3752
if (currentData) {
3853
form.setFieldsValue(currentData);
@@ -61,7 +76,7 @@ const BackendForm: React.FC<AddModalProps> = forwardRef(
6176
<Form
6277
name="basicForm"
6378
form={form}
64-
onFinish={onFinish}
79+
onFinish={handleOnFinish}
6580
preserve={false}
6681
scrollToFirstError={true}
6782
initialValues={_.omit(currentData, ['version_configs'])}

0 commit comments

Comments
 (0)