import { request } from '@umijs/max';
// 查询实验列表
export function getExperiment(params, skipLoading) {
  return request(`/api/mmp/experiment`, {
    method: 'GET',
    params,
    skipLoading,
  });
}
// 运行实验
export function runExperiments(id) {
  return request('/api/mmp/experiment/experiments/' + id, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  });
}
// 根据id查询实验
export function getExperimentById(id) {
  return request(`/api/mmp/experiment/${id}`, {
    method: 'GET',
  });
}
// 根据id删除实验
export function deleteExperimentById(id) {
  return request(`/api/mmp/experiment/${id}`, {
    method: 'DELETE',
  });
}
// 根据id查询实验实例
export function getQueryByExperimentId(params, skipLoading) {
  return request(`/api/mmp/experimentIns`, {
    method: 'GET',
    params,
    skipLoading
  });
}
// 根据id删除实验实例
export function deleteQueryByExperimentInsId(id) {
  return request(`/api/mmp/experimentIns/${id}`, {
    method: 'DELETE',
  });
}
// 批量删除实验实例
export function deleteManyExperimentIns(data) {
  return request(`/api/mmp/experimentIns/batchDelete`, {
    method: 'DELETE',
    data,
  });
}
// 根据id终止实验实例
export function putQueryByExperimentInsId(id) {
  return request(`/api/mmp/experimentIns/${id}`, {
    method: 'PUT',
  });
}

// 编辑实验实例
export function editExperimentInsReq(data) {
  return request(`/api/mmp/experimentIns`, {
    method: 'PUT',
    data,
    skipLoading: true,
  });
}

// 查询实验实例实时日志
export function getQueryByExperimentLog(data) {
  return request('/api/mmp/experimentIns/realTimeLog/', {
    method: 'POST',
    data,
    skipErrorHandler: true,
    skipLoading: true,
  });
}
// 查询实例节点结果
export function getNodeResult(data) {
  return request(`/api/mmp/experimentIns/nodeResult/`, {
    method: 'POST',
    data,
  });
}

// 获取pod实时日志请求，运行完成的
export function getExperimentPodsLog(params) {
  return request('/api/mmp/experimentIns/pods/log', {
    method: 'GET',
    params,
  });
}
// 获取pod实时日志请求，运行中的
export function getExperimentPodsRealtimeLog(data) {
  return request('/api/mmp/experimentIns/pods/realTimeLog', {
    method: 'POST',
    data,
  });
}
// 根据实例查询详情
export function getExperimentIns(id) {
  return request(`/api/mmp/experimentIns/${id}`, {
    method: 'GET',
  });
}
// 新增实验
export function postExperiment(data) {
  return request(`/api/mmp/experiment`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
    data,
  });
}
// 编辑实验
export function putExperiment(data) {
  return request(`/api/mmp/experiment`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
    data,
  });
}

// 启动 tensorBoard
export function runTensorBoardReq(data) {
  return request(`/api/mmp/tensorBoard/run`, {
    method: 'POST',
    data,
  });
}

// 获取 tensorBoard 状态
export function getTensorBoardStatusReq(data) {
  return request(`/api/mmp/tensorBoard/getStatus`, {
    method: 'POST',
    data,
    skipLoading: true,
  });
}

// 获取当前实验的模型推理指标信息
export function getExpEvaluateInfosReq(experimentId, params) {
  return request(`/api/mmp/aim/getExpEvaluateInfos/${experimentId}`, {
    method: 'GET',
    params,
  });
}

// 获取当前实验的模型训练指标信息
export function getExpTrainInfosReq(experimentId, params) {
  return request(`/api/mmp/aim/getExpTrainInfos/${experimentId}`, {
    method: 'GET',
    params,
  });
}

// 获取当前实验的指标对比地址
export function getExpMetricsReq(data) {
  return request(`/api/mmp/aim/getExpMetrics`, {
    method: 'POST',
    data,
  });
}

// 获取服务器的当前时间
export function getSeverTimeReq(data) {
  return request(`/api/mmp/experimentIns/time`, {
    method: 'GET',
  });
}

