import { type ParameterInputObject } from '@/components/ResourceSelect';
import { type NodeStatus } from '@/types';
import { type HyperParameterFile } from '@/pages/HyperParameter/types';

export { type HyperParameterFile }

// 操作类型
export enum OperationType {
  Create = 'Create', // 创建
  Update = 'Update', // 更新
}

// 表单数据
export type FormData = {
  name: string; // 实验名称
  description: string; // 实验描述
  type: string; // 类型
  ensemble_class?: string; // 集成方式
  ensemble_nbest?: string; // 集成最佳模型数量
  ensemble_size?: number; // 集成模型数量
  include_classifier?: string[]; // 分类算法
  include_feature_preprocessor?: string[]; // 特征预处理算法
  include_regressor?: string[]; // 回归算法
  exclude_classifier?: string[];
  exclude_feature_preprocessor?: string[];
  exclude_regressor?: string[];
  max_models_on_disc?: number; // 最大数量
  memory_limit?: number; // 内存限制（MB）
  per_run_time_limit?: number; // 时间限制（秒）
  resampling_strategy?: string; // 重采样策略
  folds?: number; // 交叉验证折数
  scoring_functions?: string; // 计算指标
  shuffle?: boolean; // 是否打乱
  seed?: number; // 随机种子
  task_type: string; // 任务类型
  test_size?: number; // 测试集比率
  train_size?: number; // 训练集比率
  time_left_for_this_task: number; // 搜索时间限制（秒）
  metric_name?: string; // 指标名称
  greater_is_better: boolean; // 指标优化方向
  metrics?: { name: string; value: number }[]; // 指标权重
  dataset: ParameterInputObject; // 数据集
  target_columns: string; // 预测目标列
  model_type?: string; // 文本模型
  computing_resource_id?: number; // 资源规格
  batch_size?: number;
  epochs?: number;
  lr?: number;
  num_classes?: number;
  is_validate?: boolean; 
  train_data_prefix?: string; 
  valid_data_prefix?: string; 
  train_file_path?: string; 
  valid_file_path?: string; 
};

export type AutoMLData = {
  id: number;
  progress: number;
  run_state: string;
  state: number;
  metrics?: string;
  include_classifier?: string;
  include_feature_preprocessor?: string;
  include_regressor?: string;
  exclude_classifier?: string;
  exclude_feature_preprocessor?: string;
  exclude_regressor?: string;
  dataset?: string;
  create_by?: string;
  create_time?: string;
  update_by?: string;
  update_time?: string;
  status_list: string; // 最近五次运行状态
  param: string; // 参数json字符串
} & Omit<
  FormData,
  'metrics|dataset|include_classifier|include_feature_preprocessor|include_regressor|exclude_classifier|exclude_feature_preprocessor|exclude_regressor'
>;

// 自动机器学习实验实例
export type AutoMLInstanceData = {
  id: number;
  auto_ml_id: number;
  result_path: string;
  model_path: string;
  img_path: string;
  run_history_path: string;
  state: number;
  status: string;
  node_status: string;
  node_result: string;
  param: string;
  source: string | null;
  argo_ins_name: string;
  argo_ins_ns: string;
  create_time: string;
  update_time: string;
  finish_time: string;
  nodeStatus?: NodeStatus;
  type: string;
  file_map?: HyperParameterFile;
};
