/*
 * @Author: 赵伟
 * @Date: 2025-01-08 14:30:58
 * @Description: 实验列表组件配置
 */

import {
  batchDeleteActiveLearnInsReq,
  deleteActiveLearnInsReq,
  deleteActiveLearnReq,
  editActiveLearnInsReq,
  getActiveLearnInsListReq,
  getActiveLearnListReq,
  runActiveLearnReq,
  stopActiveLearnInsReq,
} from '@/services/activeLearn';
import {
  batchDeleteExperimentInsReq,
  deleteAutoMLReq,
  deleteExperimentInsReq,
  editExperimentInsReq,
  getAutoMLListReq,
  getExperimentInsListReq,
  runAutoMLReq,
  stopExperimentInsReq,
} from '@/services/autoML';
import {
  batchDeleteRayInsReq,
  deleteRayInsReq,
  deleteRayReq,
  editRayInsReq,
  getRayInsListReq,
  getRayListReq,
  runRayReq,
  stopRayInsReq,
} from '@/services/hyperParameter';

export enum ExperimentListType {
  AutoML = 'AutoML',
  HyperParameter = 'HyperParameter',
  ActiveLearn = 'ActiveLearn',
}

type ExperimentListInfo = {
  getListReq: (params: any, skipLoading?: boolean) => Promise<any>; // 获取列表
  getInsListReq: (params: any, skipLoading?: boolean) => Promise<any>; // 获取实例列表
  deleteRecordReq: (params: any) => Promise<any>; // 删除
  runRecordReq: (params: any) => Promise<any>; // 运行
  deleteInsReq: (params: any) => Promise<any>; // 删除实例
  batchDeleteInsReq: (params: any) => Promise<any>; // 批量删除实例
  stopInsReq: (params: any) => Promise<any>; // 终止实例
  editInsReq: (params: any) => Promise<any>; // 编辑实例
  title: string; // 标题
  pathPrefix: string; // 路由路径前缀
  idProperty: string; // ID属性
  nameProperty: string; // 名称属性
  descProperty: string; // 描述属性
  idInsProperty: string; // 实例返回的ID属性
};

export const experimentListConfig: Record<ExperimentListType, ExperimentListInfo> = {
  [ExperimentListType.AutoML]: {
    getListReq: getAutoMLListReq,
    getInsListReq: getExperimentInsListReq,
    deleteRecordReq: deleteAutoMLReq,
    runRecordReq: runAutoMLReq,
    deleteInsReq: deleteExperimentInsReq,
    batchDeleteInsReq: batchDeleteExperimentInsReq,
    stopInsReq: stopExperimentInsReq,
    editInsReq: editExperimentInsReq,
    title: '自主机器学习',
    pathPrefix: 'automl',
    nameProperty: 'name',
    descProperty: 'description',
    idProperty: 'machineLearnId',
    idInsProperty: 'machine_learn_id',
  },
  [ExperimentListType.HyperParameter]: {
    getListReq: getRayListReq,
    getInsListReq: getRayInsListReq,
    deleteRecordReq: deleteRayReq,
    runRecordReq: runRayReq,
    deleteInsReq: deleteRayInsReq,
    batchDeleteInsReq: batchDeleteRayInsReq,
    stopInsReq: stopRayInsReq,
    editInsReq: editRayInsReq,
    title: '超参数自动寻优',
    pathPrefix: 'hyperparameter',
    nameProperty: 'name',
    descProperty: 'description',
    idProperty: 'rayId',
    idInsProperty: 'ray_id',
  },
  [ExperimentListType.ActiveLearn]: {
    getListReq: getActiveLearnListReq,
    getInsListReq: getActiveLearnInsListReq,
    deleteRecordReq: deleteActiveLearnReq,
    runRecordReq: runActiveLearnReq,
    deleteInsReq: deleteActiveLearnInsReq,
    batchDeleteInsReq: batchDeleteActiveLearnInsReq,
    stopInsReq: stopActiveLearnInsReq,
    editInsReq: editActiveLearnInsReq,
    title: '自动学习',
    pathPrefix: 'active-learn',
    nameProperty: 'name',
    descProperty: 'description',
    idProperty: 'activeLearnId',
    idInsProperty: 'active_learn_id',
  },
};
