fix: parse yaml error
This commit is contained in:
@@ -178,7 +178,7 @@ const BackendCard: React.FC<BackendCardProps> = ({ data, onSelect }) => {
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}, [data.is_built_in]);
|
||||
}, [data]);
|
||||
|
||||
const onClick = (e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
|
||||
@@ -50,7 +50,7 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
|
||||
|
||||
const jsonData = yaml2Json(content);
|
||||
const exsistingVersions = Object.keys(jsonData.version_configs || {});
|
||||
|
||||
console.log('exsistingVersions', jsonData);
|
||||
// Check backend version rules
|
||||
if (
|
||||
actionStatus.isBuiltIn &&
|
||||
|
||||
@@ -285,16 +285,19 @@ default_version: v0.11.0
|
||||
health_check_path: /v1/models
|
||||
default_backend_param:
|
||||
- --host
|
||||
default_run_command: {{model_path}} --port {{port}} --host {{worker_ip}} --served-model-name {{model_name}}
|
||||
default_run_command: "{{model_path}} --port {{port}} --host {{worker_ip}} --served-model-name {{model_name}}"
|
||||
default_environment:
|
||||
version_configs:
|
||||
v0.11.0:
|
||||
image_name: lm/vllm:latest
|
||||
run_command: {{model_path}} --port {{port}} --host {{worker_ip}} --served-model-name {{model_name}}
|
||||
run_command: "{{model_path}} --port {{port}} --host {{worker_ip}} --served-model-name {{model_name}}"
|
||||
entrypoint: "/bin/sh -c"
|
||||
custom_framework: cuda
|
||||
environment:
|
||||
v0.10.0:
|
||||
image_name: lm/vllm:test
|
||||
entrypoint:
|
||||
run_command:
|
||||
custom_framework: rocm
|
||||
environment:
|
||||
`;
|
||||
|
||||
@@ -30,6 +30,13 @@
|
||||
"type": ["string", "null"],
|
||||
"description": "default start command"
|
||||
},
|
||||
"default_environment": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "default environment variables"
|
||||
},
|
||||
"health_check_path": {
|
||||
"type": ["string", "null"],
|
||||
"description": "health check path"
|
||||
@@ -55,6 +62,13 @@
|
||||
"custom_framework": {
|
||||
"type": ["string", "null"],
|
||||
"description": "custom framework"
|
||||
},
|
||||
"environment": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "environment variables"
|
||||
}
|
||||
},
|
||||
"required": ["image_name", "run_command"],
|
||||
|
||||
@@ -20,6 +20,13 @@
|
||||
"type": ["string", "null"],
|
||||
"description": "health check path"
|
||||
},
|
||||
"default_environment": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "environment variables"
|
||||
},
|
||||
"version_configs": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
@@ -41,6 +48,13 @@
|
||||
"custom_framework": {
|
||||
"type": ["string", "null"],
|
||||
"description": "custom framework"
|
||||
},
|
||||
"environment": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "environment variables"
|
||||
}
|
||||
},
|
||||
"required": ["image_name", "run_command"],
|
||||
|
||||
@@ -24,6 +24,13 @@
|
||||
"type": ["string", "null"],
|
||||
"description": "health check path"
|
||||
},
|
||||
"default_environment": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "environment variables"
|
||||
},
|
||||
"version_configs": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
@@ -45,6 +52,13 @@
|
||||
"custom_framework": {
|
||||
"type": ["string", "null"],
|
||||
"description": "custom framework"
|
||||
},
|
||||
"environment": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "environment variables"
|
||||
}
|
||||
},
|
||||
"required": ["image_name", "run_command"],
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useIntl } from '@umijs/max';
|
||||
import { Form } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React, { forwardRef, useEffect, useImperativeHandle } from 'react';
|
||||
import { BackendSourceValueMap } from '../config';
|
||||
import { FormContext } from '../config/form-context';
|
||||
import { FormData, ListItem } from '../config/types';
|
||||
import BasicForm from './basic';
|
||||
@@ -38,17 +39,19 @@ const BackendForm: React.FC<AddModalProps> = forwardRef(
|
||||
const handleOnFinish = (values: FormData) => {
|
||||
const data = {
|
||||
...values,
|
||||
backend_name: currentData?.is_built_in
|
||||
? values.backend_name
|
||||
: `${values.backend_name}-custom`
|
||||
backend_name:
|
||||
backendSource === BackendSourceValueMap.CUSTOM
|
||||
? `${values.backend_name}-custom`
|
||||
: values.backend_name
|
||||
};
|
||||
data.version_configs = data.version_configs?.map((item) => {
|
||||
if (item.version_no) {
|
||||
return {
|
||||
...item,
|
||||
version_no: currentData?.is_built_in
|
||||
? `${item.version_no}-custom`
|
||||
: item.version_no
|
||||
version_no:
|
||||
backendSource === BackendSourceValueMap.BUILTIN
|
||||
? `${item.version_no}-custom`
|
||||
: item.version_no
|
||||
};
|
||||
}
|
||||
return item;
|
||||
|
||||
@@ -11,7 +11,8 @@ import { useIntl } from '@umijs/max';
|
||||
import { Button, Form, Tag } from 'antd';
|
||||
import React, { useEffect, useMemo } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { frameworks } from '../config';
|
||||
import { BackendSourceValueMap, frameworks } from '../config';
|
||||
import { useFormContext } from '../config/form-context';
|
||||
import { ListItem } from '../config/types';
|
||||
|
||||
// version must be endwith '-custom'
|
||||
@@ -66,6 +67,7 @@ const VersionsForm: React.FC<AddModalProps> = ({
|
||||
const defaultCollapseKey =
|
||||
action === 'edit' ? new Set<number>() : new Set([0]);
|
||||
const form = Form.useFormInstance();
|
||||
const { backendSource } = useFormContext();
|
||||
const version_configs = Form.useWatch('version_configs', form);
|
||||
const [collapseKey, setCollapseKey] =
|
||||
React.useState<Set<number | string>>(defaultCollapseKey);
|
||||
@@ -198,6 +200,8 @@ const VersionsForm: React.FC<AddModalProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
const isBuiltin = backendSource === BackendSourceValueMap.BUILTIN;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Title>
|
||||
@@ -209,7 +213,7 @@ const VersionsForm: React.FC<AddModalProps> = ({
|
||||
<PlusOutlined /> {intl.formatMessage({ id: 'backend.addVersion' })}
|
||||
</Button>
|
||||
</span>
|
||||
{!currentData?.is_built_in && (
|
||||
{!isBuiltin && (
|
||||
<BaseSelect
|
||||
prefix={
|
||||
<span style={{ color: 'var(--ant-color-text-tertiary)' }}>
|
||||
@@ -292,7 +296,7 @@ const VersionsForm: React.FC<AddModalProps> = ({
|
||||
className="flex-center"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{!currentData?.is_built_in && (
|
||||
{!isBuiltin && (
|
||||
<Form.Item
|
||||
name={[name, 'is_default']}
|
||||
valuePropName="checked"
|
||||
@@ -301,7 +305,7 @@ const VersionsForm: React.FC<AddModalProps> = ({
|
||||
></Form.Item>
|
||||
)}
|
||||
</span>
|
||||
{(fields.length > 1 || currentData?.is_built_in) && (
|
||||
{(fields.length > 1 || isBuiltin) && (
|
||||
<Button
|
||||
size="small"
|
||||
shape="circle"
|
||||
@@ -325,7 +329,7 @@ const VersionsForm: React.FC<AddModalProps> = ({
|
||||
>
|
||||
<SealInput.Input
|
||||
trim
|
||||
addAfter={currentData?.is_built_in ? '-custom' : null}
|
||||
addAfter={isBuiltin ? '-custom' : null}
|
||||
onChange={handleVersionChange}
|
||||
label={intl.formatMessage({ id: 'backend.version' })}
|
||||
required
|
||||
|
||||
@@ -22,7 +22,12 @@ import {
|
||||
import AddModal from './components/add-modal';
|
||||
import BackendCardList from './components/backend-list';
|
||||
import VersionInfoModal from './components/version-info-modal';
|
||||
import { backendSourceOptions, json2Yaml, yaml2Json } from './config';
|
||||
import {
|
||||
backendSourceOptions,
|
||||
BackendSourceValueMap,
|
||||
json2Yaml,
|
||||
yaml2Json
|
||||
} from './config';
|
||||
import { FormData, ListItem } from './config/types';
|
||||
import useCreateBackend from './hooks/use-create-backend';
|
||||
import useExportYAML from './hooks/use-export-yaml';
|
||||
@@ -67,9 +72,15 @@ const BackendList = () => {
|
||||
if (openBackendModalStatus.action === 'create') {
|
||||
await createBackend({ data: values });
|
||||
} else {
|
||||
const omitFields = openBackendModalStatus.currentData?.is_built_in
|
||||
? ['built_in_version_configs', 'default_version']
|
||||
: ['built_in_version_configs'];
|
||||
console.log(
|
||||
'openBackendModalStatus.currentData',
|
||||
openBackendModalStatus
|
||||
);
|
||||
const omitFields =
|
||||
openBackendModalStatus.currentData?.backend_source ===
|
||||
BackendSourceValueMap.BUILTIN
|
||||
? ['built_in_version_configs', 'default_version']
|
||||
: ['built_in_version_configs'];
|
||||
|
||||
await updateBackend(openBackendModalStatus.currentData!.id!, {
|
||||
data: {
|
||||
|
||||
@@ -226,6 +226,7 @@ const BackendFields: React.FC = () => {
|
||||
backend
|
||||
]);
|
||||
}
|
||||
// TODO: init env variables from selected backend, when action is CREATE
|
||||
}
|
||||
}, [backend, flatBackendOptions]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user