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