fix: edit gpu_selector failed

This commit is contained in:
jialin
2025-09-17 19:53:40 +08:00
parent 4d9dec8511
commit bf400547e1
17 changed files with 296 additions and 544 deletions
+33
View File
@@ -0,0 +1,33 @@
import _ from 'lodash';
import { backendOptionsMap } from '../config/backend-parameters';
export const generateGPUSelector = (data: any, gpuOptions: any[]) => {
const gpu_ids = _.get(data, 'gpu_selector.gpu_ids', []);
if (gpu_ids.length === 0) {
return {
gpu_selector: null
};
}
const valueMap = new Map<string, string>();
gpuOptions?.forEach((item) => {
item.children?.forEach((child: any) => {
valueMap.set(child.value, item.value);
});
});
const gpuids: string[][] = gpu_ids
.map((id: string) => {
const parent = valueMap.get(id);
return parent ? [parent, id] : null;
})
.filter(Boolean) as string[][];
const result = data.backend === backendOptionsMap.voxBox ? gpuids[0] : gpuids;
return {
gpu_selector: {
gpu_ids: result
}
};
};