fix: default benchmark form values
This commit is contained in:
@@ -9,6 +9,7 @@ import StatusTag from '@/components/status-tag';
|
||||
import ThemeTag from '@/components/tags-wrapper/theme-tag';
|
||||
import { HandlerOptions } from '@/hooks/use-chunk-fetch';
|
||||
import useDownloadStream from '@/hooks/use-download-stream';
|
||||
import { useBenchmarkTargetInstance } from '@/pages/llmodels/hooks/use-run-benchmark';
|
||||
import { ListItem as WorkerListItem } from '@/pages/resources/config/types';
|
||||
import { convertFileSize } from '@/utils';
|
||||
import {
|
||||
@@ -333,6 +334,12 @@ const childActionList = [
|
||||
],
|
||||
icon: <DownloadOutlined />
|
||||
},
|
||||
{
|
||||
label: 'models.table.instance.benchmark',
|
||||
key: 'benchmark',
|
||||
status: [InstanceStatusMap.Running],
|
||||
icon: <IconFont type="icon-speed" />
|
||||
},
|
||||
{
|
||||
label: 'common.button.delrecreate',
|
||||
key: 'delete',
|
||||
@@ -416,6 +423,7 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
||||
defaultOpenId,
|
||||
handleChildSelect
|
||||
}) => {
|
||||
const { runBenchmarkOnInstance } = useBenchmarkTargetInstance();
|
||||
const [api, contextHolder] = notification.useNotification({
|
||||
stack: { threshold: 1 }
|
||||
});
|
||||
@@ -423,7 +431,7 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
||||
const intl = useIntl();
|
||||
const actionItems = useMemo(() => {
|
||||
return _.filter(childActionList, (action: any) => {
|
||||
if (action.key === 'viewlog' || action.key === 'download') {
|
||||
if (action.status && action.status.length > 0) {
|
||||
return action.status.includes(instanceData.state);
|
||||
}
|
||||
return true;
|
||||
@@ -662,7 +670,9 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
||||
]);
|
||||
|
||||
const handleOnSelect = (val: string) => {
|
||||
if (val === 'download') {
|
||||
if (val === 'benchmark') {
|
||||
runBenchmarkOnInstance(instanceData);
|
||||
} else if (val === 'download') {
|
||||
downloadStream({
|
||||
url: `${MODEL_INSTANCE_API}/${instanceData.id}/logs`,
|
||||
filename: createFileName(instanceData.name),
|
||||
|
||||
@@ -114,6 +114,7 @@ export interface DistributedServers {
|
||||
}
|
||||
export interface ModelInstanceListItem {
|
||||
backend?: string;
|
||||
cluster_id: number;
|
||||
backend_version?: string;
|
||||
source: string;
|
||||
huggingface_repo_id: string;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { benchmarkTargetInstanceAtom } from '@/atoms/benchmark';
|
||||
import { useNavigate } from '@umijs/max';
|
||||
import { useAtom } from 'jotai';
|
||||
import { ModelInstanceListItem } from '../config/types';
|
||||
|
||||
export const useBenchmarkTargetInstance = () => {
|
||||
const [benchmarkTargetInstance, setBenchmarkTargetInstance] = useAtom(
|
||||
benchmarkTargetInstanceAtom
|
||||
);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const runBenchmarkOnInstance = (instance: ModelInstanceListItem) => {
|
||||
setBenchmarkTargetInstance({
|
||||
cluster_id: instance.cluster_id,
|
||||
model_name: instance.model_name,
|
||||
model_id: instance.model_id,
|
||||
model_instance_name: instance.name,
|
||||
model_instance: [instance.model_name, instance.name]
|
||||
});
|
||||
navigate('/models/benchmark');
|
||||
};
|
||||
|
||||
const clearBenchmarkTargetInstance = () => {
|
||||
setBenchmarkTargetInstance({
|
||||
cluster_id: null,
|
||||
model_name: '',
|
||||
model_id: null,
|
||||
model_instance_name: '',
|
||||
model_instance: []
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
benchmarkTargetInstance,
|
||||
clearBenchmarkTargetInstance,
|
||||
runBenchmarkOnInstance
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user