chore: init worker selector
This commit is contained in:
@@ -2,7 +2,7 @@ import { CheckCircleFilled, CopyOutlined } from '@ant-design/icons';
|
|||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Button, Tooltip, message } from 'antd';
|
import { Button, Tooltip, message } from 'antd';
|
||||||
import ClipboardJS from 'clipboard';
|
import ClipboardJS from 'clipboard';
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
type CopyButtonProps = {
|
type CopyButtonProps = {
|
||||||
text: string;
|
text: string;
|
||||||
@@ -20,6 +20,7 @@ type CopyButtonProps = {
|
|||||||
| 'topRight'
|
| 'topRight'
|
||||||
| 'bottomLeft'
|
| 'bottomLeft'
|
||||||
| 'bottomRight';
|
| 'bottomRight';
|
||||||
|
btnStyle?: React.CSSProperties;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ const CopyButton: React.FC<CopyButtonProps> = ({
|
|||||||
shape = 'default',
|
shape = 'default',
|
||||||
fontSize = '14px',
|
fontSize = '14px',
|
||||||
style,
|
style,
|
||||||
|
btnStyle,
|
||||||
placement,
|
placement,
|
||||||
size = 'middle'
|
size = 'middle'
|
||||||
}) => {
|
}) => {
|
||||||
@@ -77,6 +79,7 @@ const CopyButton: React.FC<CopyButtonProps> = ({
|
|||||||
size={size}
|
size={size}
|
||||||
disabled={!!disabled}
|
disabled={!!disabled}
|
||||||
data-clipboard-text={text}
|
data-clipboard-text={text}
|
||||||
|
style={{ ...btnStyle }}
|
||||||
icon={
|
icon={
|
||||||
copied ? (
|
copied ? (
|
||||||
<CheckCircleFilled
|
<CheckCircleFilled
|
||||||
|
|||||||
@@ -292,7 +292,6 @@ const AddModal: FC<AddModalProps> = (props) => {
|
|||||||
deploymentType === 'modelList' && (
|
deploymentType === 'modelList' && (
|
||||||
<TitleWrapper>
|
<TitleWrapper>
|
||||||
{intl.formatMessage({ id: 'models.form.configurations' })}
|
{intl.formatMessage({ id: 'models.form.configurations' })}
|
||||||
<span style={{ display: 'flex', height: 24 }}></span>
|
|
||||||
</TitleWrapper>
|
</TitleWrapper>
|
||||||
)}
|
)}
|
||||||
<DataForm
|
<DataForm
|
||||||
|
|||||||
@@ -259,8 +259,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
);
|
);
|
||||||
await updateModel({
|
await updateModel({
|
||||||
data: {
|
data: {
|
||||||
...result.values,
|
...result.values
|
||||||
..._.omit(data, result.omits)
|
|
||||||
},
|
},
|
||||||
id: currentData.current?.id as number
|
id: currentData.current?.id as number
|
||||||
});
|
});
|
||||||
@@ -296,8 +295,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
|
|
||||||
const modelData = await createModel({
|
const modelData = await createModel({
|
||||||
data: {
|
data: {
|
||||||
...result.values,
|
...result.values
|
||||||
..._.omit(data, result.omits)
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setOpenDeployModal({
|
setOpenDeployModal({
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import React from 'react';
|
|||||||
import '../style/title-wrapper.less';
|
import '../style/title-wrapper.less';
|
||||||
|
|
||||||
const TitleWrapper: React.FC<any> = ({ children }) => {
|
const TitleWrapper: React.FC<any> = ({ children }) => {
|
||||||
return <h3 className="h3">{children}</h3>;
|
return (
|
||||||
|
<h3 className="h3" style={{ height: 50 }}>
|
||||||
|
{children}
|
||||||
|
</h3>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TitleWrapper;
|
export default TitleWrapper;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { StatusMaps } from '@/config';
|
import { StatusMaps } from '@/config';
|
||||||
import { EditOutlined } from '@ant-design/icons';
|
import { EditOutlined } from '@ant-design/icons';
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
export const ollamaModelOptions = [
|
export const ollamaModelOptions = [
|
||||||
{
|
{
|
||||||
@@ -345,8 +346,7 @@ export const getSourceRepoConfigValue = (
|
|||||||
source: string,
|
source: string,
|
||||||
data: any
|
data: any
|
||||||
): {
|
): {
|
||||||
values: Record<string, any>;
|
values: typeof data;
|
||||||
omits: string[];
|
|
||||||
} => {
|
} => {
|
||||||
const config: Record<string, any> = sourceRepoConfig[source] || {};
|
const config: Record<string, any> = sourceRepoConfig[source] || {};
|
||||||
const result: Record<string, any> = {};
|
const result: Record<string, any> = {};
|
||||||
@@ -359,8 +359,7 @@ export const getSourceRepoConfigValue = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
values: result,
|
values: { ...result, ..._.omit(data, omits) }
|
||||||
omits: omits
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -369,7 +368,6 @@ export const setSourceRepoConfigValue = (
|
|||||||
data: any
|
data: any
|
||||||
): {
|
): {
|
||||||
values: Record<string, any>;
|
values: Record<string, any>;
|
||||||
omits: string[];
|
|
||||||
} => {
|
} => {
|
||||||
const config: Record<string, any> = sourceRepoConfig[source] || {};
|
const config: Record<string, any> = sourceRepoConfig[source] || {};
|
||||||
const result: Record<string, any> = {};
|
const result: Record<string, any> = {};
|
||||||
@@ -382,8 +380,7 @@ export const setSourceRepoConfigValue = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
values: result,
|
values: { ...result, ..._.omit(data, omits) }
|
||||||
omits: omits
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ export const useGenerateFormEditInitialValues = () => {
|
|||||||
|
|
||||||
const formData = {
|
const formData = {
|
||||||
...result.values,
|
...result.values,
|
||||||
..._.omit(data, result.omits),
|
|
||||||
categories: data?.categories?.length ? data.categories[0] : null,
|
categories: data?.categories?.length ? data.categories[0] : null,
|
||||||
scheduleType: data?.gpu_selector ? 'manual' : 'auto',
|
scheduleType: data?.gpu_selector ? 'manual' : 'auto',
|
||||||
gpu_selector: data?.gpu_selector?.gpu_ids?.length
|
gpu_selector: data?.gpu_selector?.gpu_ids?.length
|
||||||
|
|||||||
@@ -221,10 +221,18 @@ const ModelFiles = () => {
|
|||||||
).pop()
|
).pop()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const targetWorker = _.find(workersList, { value: record.worker_id })
|
||||||
|
?.labels?.['worker-name'];
|
||||||
|
|
||||||
const result = setSourceRepoConfigValue(record.source, record);
|
const result = setSourceRepoConfigValue(record.source, record);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...result.values,
|
...result.values,
|
||||||
|
worker_selector: targetWorker
|
||||||
|
? {
|
||||||
|
'worker-name': targetWorker
|
||||||
|
}
|
||||||
|
: {},
|
||||||
source: record.source,
|
source: record.source,
|
||||||
local_path: record.local_path,
|
local_path: record.local_path,
|
||||||
name: extractFileName(name),
|
name: extractFileName(name),
|
||||||
@@ -280,7 +288,6 @@ const ModelFiles = () => {
|
|||||||
]);
|
]);
|
||||||
const dataList = generateModelFileOptions(modelFileList, workersList);
|
const dataList = generateModelFileOptions(modelFileList, workersList);
|
||||||
const initialValues = generateInitialValues(record);
|
const initialValues = generateInitialValues(record);
|
||||||
console.log('initialValues:', initialValues);
|
|
||||||
setOpenDeployModal({
|
setOpenDeployModal({
|
||||||
...openDeployModal,
|
...openDeployModal,
|
||||||
source: record.source,
|
source: record.source,
|
||||||
@@ -359,8 +366,7 @@ const ModelFiles = () => {
|
|||||||
|
|
||||||
const modelData = await createModel({
|
const modelData = await createModel({
|
||||||
data: {
|
data: {
|
||||||
...result.values,
|
...result.values
|
||||||
..._.omit(data, result.omits)
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setOpenDeployModal({
|
setOpenDeployModal({
|
||||||
@@ -433,6 +439,7 @@ const ModelFiles = () => {
|
|||||||
<CopyButton
|
<CopyButton
|
||||||
text={record.resolved_paths?.[0]}
|
text={record.resolved_paths?.[0]}
|
||||||
type="link"
|
type="link"
|
||||||
|
btnStyle={{ width: 18, paddingInline: 2 }}
|
||||||
></CopyButton>
|
></CopyButton>
|
||||||
{renderParts(record)}
|
{renderParts(record)}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user