| @@ -0,0 +1,62 @@ | |||||
| package com.ruoyi.platform.controller.ray; | |||||
| import com.ruoyi.common.core.web.controller.BaseController; | |||||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||||
| import com.ruoyi.platform.domain.Ray; | |||||
| import com.ruoyi.platform.service.RayService; | |||||
| import com.ruoyi.platform.vo.RayVo; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.annotation.Resource; | |||||
| import java.io.IOException; | |||||
| @RestController | |||||
| @RequestMapping("ray") | |||||
| @Api("自动超参数寻优") | |||||
| public class RayController extends BaseController { | |||||
| @Resource | |||||
| private RayService rayService; | |||||
| @GetMapping | |||||
| @ApiOperation("分页查询") | |||||
| public GenericsAjaxResult<Page<Ray>> queryByPage(@RequestParam("page") int page, | |||||
| @RequestParam("size") int size, | |||||
| @RequestParam(value = "name", required = false) String name) { | |||||
| PageRequest pageRequest = PageRequest.of(page, size); | |||||
| return genericsSuccess(this.rayService.queryByPage(name, pageRequest)); | |||||
| } | |||||
| @PostMapping | |||||
| @ApiOperation("新增自动超参数寻优") | |||||
| public GenericsAjaxResult<Ray> addRay(@RequestBody RayVo rayVo) throws Exception { | |||||
| return genericsSuccess(this.rayService.save(rayVo)); | |||||
| } | |||||
| @PutMapping | |||||
| @ApiOperation("编辑自动超参数寻优") | |||||
| public GenericsAjaxResult<String> editRay(@RequestBody RayVo rayVo) throws Exception{ | |||||
| return genericsSuccess(this.rayService.edit(rayVo)); | |||||
| } | |||||
| @GetMapping("/getRayDetail") | |||||
| @ApiOperation("获取自动超参数寻优详细信息") | |||||
| public GenericsAjaxResult<RayVo> getRayDetail(@RequestParam("id") Long id) throws IOException { | |||||
| return genericsSuccess(this.rayService.getRayDetail(id)); | |||||
| } | |||||
| @DeleteMapping("{id}") | |||||
| @ApiOperation("删除自动超参数寻优") | |||||
| public GenericsAjaxResult<String> deleteRay(@PathVariable("id") Long id) { | |||||
| return genericsSuccess(this.rayService.delete(id)); | |||||
| } | |||||
| @PostMapping("/run/{id}") | |||||
| @ApiOperation("运行自动超参数寻优实验") | |||||
| public GenericsAjaxResult<String> runRay(@PathVariable("id") Long id) throws Exception { | |||||
| return genericsSuccess(this.rayService.runRayIns(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,60 @@ | |||||
| package com.ruoyi.platform.controller.ray; | |||||
| import com.ruoyi.common.core.web.controller.BaseController; | |||||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||||
| import com.ruoyi.platform.domain.RayIns; | |||||
| import com.ruoyi.platform.service.RayInsService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import javax.annotation.Resource; | |||||
| import java.io.IOException; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("rayIns") | |||||
| @Api("自动超参数寻优实验实例") | |||||
| public class RayInsController extends BaseController { | |||||
| @Resource | |||||
| private RayInsService rayInsService; | |||||
| @GetMapping | |||||
| @ApiOperation("分页查询") | |||||
| public GenericsAjaxResult<Page<RayIns>> queryByPage(Long rayId, int page, int size) throws IOException { | |||||
| PageRequest pageRequest = PageRequest.of(page, size); | |||||
| return genericsSuccess(this.rayInsService.queryByPage(rayId, pageRequest)); | |||||
| } | |||||
| @PostMapping | |||||
| @ApiOperation("新增实验实例") | |||||
| public GenericsAjaxResult<RayIns> add(@RequestBody RayIns rayIns) { | |||||
| return genericsSuccess(this.rayInsService.insert(rayIns)); | |||||
| } | |||||
| @DeleteMapping("{id}") | |||||
| @ApiOperation("删除实验实例") | |||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) { | |||||
| return genericsSuccess(this.rayInsService.deleteById(id)); | |||||
| } | |||||
| @DeleteMapping("batchDelete") | |||||
| @ApiOperation("批量删除实验实例") | |||||
| public GenericsAjaxResult<String> batchDelete(@RequestBody List<Long> ids) { | |||||
| return genericsSuccess(this.rayInsService.batchDelete(ids)); | |||||
| } | |||||
| @PutMapping("{id}") | |||||
| @ApiOperation("终止实验实例") | |||||
| public GenericsAjaxResult<Boolean> terminateRayIns(@PathVariable("id") Long id) throws Exception { | |||||
| return genericsSuccess(this.rayInsService.terminateRayIns(id)); | |||||
| } | |||||
| @GetMapping("{id}") | |||||
| @ApiOperation("查看实验实例详情") | |||||
| public GenericsAjaxResult<RayIns> getDetailById(@PathVariable("id") Long id) { | |||||
| return genericsSuccess(this.rayInsService.getDetailById(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,77 @@ | |||||
| package com.ruoyi.platform.domain; | |||||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||||
| import io.swagger.annotations.ApiModel; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | |||||
| import java.util.Date; | |||||
| @Data | |||||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||||
| @ApiModel(description = "自动超参数寻优") | |||||
| public class Ray { | |||||
| private Long id; | |||||
| @ApiModelProperty(value = "实验名称") | |||||
| private String name; | |||||
| @ApiModelProperty(value = "数据集") | |||||
| private String dataset; | |||||
| @ApiModelProperty(value = "代码") | |||||
| private String code; | |||||
| @ApiModelProperty(value = "主函数代码文件") | |||||
| private String mainPy; | |||||
| @ApiModelProperty(value = "总实验次数") | |||||
| private Integer numSamples; | |||||
| @ApiModelProperty(value = "参数") | |||||
| private String parameters; | |||||
| @ApiModelProperty(value = "手动指定需要运行的参数") | |||||
| private String pointsToEvaluate; | |||||
| @ApiModelProperty(value = "保存路径") | |||||
| private String storagePath; | |||||
| @ApiModelProperty(value = "搜索算法") | |||||
| private String searchAlg; | |||||
| @ApiModelProperty(value = "调度算法") | |||||
| private String scheduler; | |||||
| @ApiModelProperty(value = "指标") | |||||
| private String metric; | |||||
| @ApiModelProperty(value = "指标最大化或最小化,min or max") | |||||
| private String mode; | |||||
| @ApiModelProperty(value = "搜索算法为ASHA,HyperBand时传入,每次试验的最大时间单位。测试将在max_t时间单位后停止。") | |||||
| private Integer maxT; | |||||
| @ApiModelProperty(value = "搜索算法为MedianStopping时传入,计算中位数的最小试验数。") | |||||
| private Integer minSamplesRequired; | |||||
| @ApiModelProperty(value = "使用cpu数") | |||||
| private Integer cpu; | |||||
| @ApiModelProperty(value = "使用gpu数") | |||||
| private Integer gpu; | |||||
| private Integer state; | |||||
| private String createBy; | |||||
| private String updateBy; | |||||
| private Date createTime; | |||||
| private Date updateTime; | |||||
| @ApiModelProperty(value = "状态列表") | |||||
| private String statusList; | |||||
| } | |||||
| @@ -0,0 +1,45 @@ | |||||
| package com.ruoyi.platform.domain; | |||||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||||
| import io.swagger.annotations.ApiModel; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | |||||
| import java.util.Date; | |||||
| @Data | |||||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||||
| @ApiModel(description = "自动超参数寻优实验实例") | |||||
| public class RayIns { | |||||
| private Long id; | |||||
| private Long rayId; | |||||
| private String resultPath; | |||||
| private Integer state; | |||||
| private String status; | |||||
| private String nodeStatus; | |||||
| private String nodeResult; | |||||
| private String param; | |||||
| private String source; | |||||
| @ApiModelProperty(value = "Argo实例名称") | |||||
| private String argoInsName; | |||||
| @ApiModelProperty(value = "Argo命名空间") | |||||
| private String argoInsNs; | |||||
| private Date createTime; | |||||
| private Date updateTime; | |||||
| private Date finishTime; | |||||
| } | |||||
| @@ -0,0 +1,21 @@ | |||||
| package com.ruoyi.platform.mapper; | |||||
| import com.ruoyi.platform.domain.Ray; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import java.util.List; | |||||
| public interface RayDao { | |||||
| long count(@Param("name") String name); | |||||
| List<Ray> queryByPage(@Param("name") String name, @Param("pageable") PageRequest pageRequest); | |||||
| Ray getRayByName(@Param("name") String name); | |||||
| Ray getRayById(@Param("id") Long id); | |||||
| int save(@Param("ray") Ray ray); | |||||
| int edit(@Param("ray") Ray ray); | |||||
| } | |||||
| @@ -0,0 +1,21 @@ | |||||
| package com.ruoyi.platform.mapper; | |||||
| import com.ruoyi.platform.domain.RayIns; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import org.springframework.data.domain.Pageable; | |||||
| import java.util.List; | |||||
| public interface RayInsDao { | |||||
| long count(@Param("rayId") Long rayId); | |||||
| List<RayIns> queryAllByLimit(@Param("rayId") Long rayId, @Param("pageable") Pageable pageable); | |||||
| RayIns queryById(@Param("id") Long id); | |||||
| List<RayIns> getByRayId(@Param("rayId") Long rayId); | |||||
| int insert(@Param("rayIns") RayIns rayIns); | |||||
| int update(@Param("rayIns") RayIns rayIns); | |||||
| } | |||||
| @@ -0,0 +1,21 @@ | |||||
| package com.ruoyi.platform.service; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import com.ruoyi.platform.domain.RayIns; | |||||
| import java.io.IOException; | |||||
| import java.util.List; | |||||
| public interface RayInsService { | |||||
| Page<RayIns> queryByPage(Long rayId, PageRequest pageRequest) throws IOException; | |||||
| RayIns insert(RayIns rayIns); | |||||
| String deleteById(Long id); | |||||
| String batchDelete(List<Long> ids); | |||||
| boolean terminateRayIns(Long id) throws Exception; | |||||
| RayIns getDetailById(Long id); | |||||
| void updateRayStatus(Long rayId); | |||||
| } | |||||
| @@ -0,0 +1,22 @@ | |||||
| package com.ruoyi.platform.service; | |||||
| import com.ruoyi.platform.domain.Ray; | |||||
| import com.ruoyi.platform.vo.RayVo; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import java.io.IOException; | |||||
| public interface RayService { | |||||
| Page<Ray> queryByPage(String name, PageRequest pageRequest); | |||||
| Ray save(RayVo rayVo) throws Exception; | |||||
| String edit(RayVo rayVo) throws Exception; | |||||
| RayVo getRayDetail(Long id) throws IOException; | |||||
| String delete(Long id); | |||||
| String runRayIns(Long id) throws Exception; | |||||
| } | |||||
| @@ -0,0 +1,130 @@ | |||||
| package com.ruoyi.platform.service.impl; | |||||
| import com.ruoyi.platform.constant.Constant; | |||||
| import com.ruoyi.platform.domain.Ray; | |||||
| import com.ruoyi.platform.domain.RayIns; | |||||
| import com.ruoyi.platform.mapper.RayDao; | |||||
| import com.ruoyi.platform.mapper.RayInsDao; | |||||
| import com.ruoyi.platform.service.RayInsService; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageImpl; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.stereotype.Service; | |||||
| import javax.annotation.Resource; | |||||
| import java.io.IOException; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @Service("rayInsService") | |||||
| public class RayInsServiceImpl implements RayInsService { | |||||
| @Resource | |||||
| private RayInsDao rayInsDao; | |||||
| @Resource | |||||
| private RayDao rayDao; | |||||
| @Override | |||||
| public Page<RayIns> queryByPage(Long rayId, PageRequest pageRequest) throws IOException { | |||||
| long total = this.rayInsDao.count(rayId); | |||||
| List<RayIns> rayInsList = this.rayInsDao.queryAllByLimit(rayId, pageRequest); | |||||
| return new PageImpl<>(rayInsList, pageRequest, total); | |||||
| } | |||||
| @Override | |||||
| public RayIns insert(RayIns rayIns) { | |||||
| this.rayInsDao.insert(rayIns); | |||||
| return rayIns; | |||||
| } | |||||
| @Override | |||||
| public String deleteById(Long id) { | |||||
| RayIns rayIns = rayInsDao.queryById(id); | |||||
| if (rayIns == null) { | |||||
| return "实验实例不存在"; | |||||
| } | |||||
| if (StringUtils.isEmpty(rayIns.getStatus())) { | |||||
| //todo queryStatusFromArgo | |||||
| } | |||||
| if (StringUtils.equals(rayIns.getStatus(), Constant.Running)) { | |||||
| return "实验实例正在运行,不可删除"; | |||||
| } | |||||
| rayIns.setState(Constant.State_invalid); | |||||
| int update = rayInsDao.update(rayIns); | |||||
| if (update > 0) { | |||||
| updateRayStatus(rayIns.getRayId()); | |||||
| return "删除成功"; | |||||
| } else { | |||||
| return "删除失败"; | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public String batchDelete(List<Long> ids) { | |||||
| for (Long id : ids) { | |||||
| String result = deleteById(id); | |||||
| if (!"删除成功".equals(result)) { | |||||
| return result; | |||||
| } | |||||
| } | |||||
| return "删除成功"; | |||||
| } | |||||
| @Override | |||||
| public boolean terminateRayIns(Long id) throws Exception { | |||||
| RayIns rayIns = rayInsDao.queryById(id); | |||||
| if (rayIns == null) { | |||||
| throw new IllegalStateException("实验实例未查询到,id: " + id); | |||||
| } | |||||
| String currentStatus = rayIns.getStatus(); | |||||
| String name = rayIns.getArgoInsName(); | |||||
| String namespace = rayIns.getArgoInsNs(); | |||||
| // 获取当前状态,如果为空,则从Argo查询 | |||||
| if (StringUtils.isEmpty(currentStatus)) { | |||||
| // todo queryStatusFromArgo | |||||
| } | |||||
| // 只有状态是"Running"时才能终止实例 | |||||
| if (!currentStatus.equalsIgnoreCase(Constant.Running)) { | |||||
| throw new Exception("终止错误,只有运行状态的实例才能终止"); // 如果不是"Running"状态,则不执行终止操作 | |||||
| } | |||||
| //todo terminateFromArgo | |||||
| rayIns.setStatus(Constant.Terminated); | |||||
| rayIns.setFinishTime(new Date()); | |||||
| this.rayInsDao.update(rayIns); | |||||
| updateRayStatus(rayIns.getRayId()); | |||||
| return true; | |||||
| } | |||||
| @Override | |||||
| public RayIns getDetailById(Long id) { | |||||
| RayIns rayIns = rayInsDao.queryById(id); | |||||
| if (Constant.Running.equals(rayIns.getStatus()) || Constant.Pending.equals(rayIns.getStatus())) { | |||||
| //todo queryStatusFromArgo | |||||
| } | |||||
| return rayIns; | |||||
| } | |||||
| @Override | |||||
| public void updateRayStatus(Long rayId) { | |||||
| List<RayIns> insList = rayInsDao.getByRayId(rayId); | |||||
| List<String> statusList = new ArrayList<>(); | |||||
| // 更新实验状态列表 | |||||
| for (int i = 0; i < insList.size(); i++) { | |||||
| statusList.add(insList.get(i).getStatus()); | |||||
| } | |||||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | |||||
| Ray ray = rayDao.getRayById(rayId); | |||||
| if (!StringUtils.equals(ray.getStatusList(), subStatus)) { | |||||
| ray.setStatusList(subStatus); | |||||
| rayDao.edit(ray); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,119 @@ | |||||
| package com.ruoyi.platform.service.impl; | |||||
| import com.ruoyi.common.security.utils.SecurityUtils; | |||||
| import com.ruoyi.platform.constant.Constant; | |||||
| import com.ruoyi.platform.domain.Ray; | |||||
| import com.ruoyi.platform.mapper.RayDao; | |||||
| import com.ruoyi.platform.service.RayService; | |||||
| import com.ruoyi.platform.utils.JacksonUtil; | |||||
| import com.ruoyi.platform.utils.JsonUtils; | |||||
| import com.ruoyi.platform.vo.RayVo; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.beans.BeanUtils; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageImpl; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.stereotype.Service; | |||||
| import javax.annotation.Resource; | |||||
| import java.io.IOException; | |||||
| import java.util.List; | |||||
| @Service("rayService") | |||||
| public class RayServiceImpl implements RayService { | |||||
| @Resource | |||||
| private RayDao rayDao; | |||||
| @Override | |||||
| public Page<Ray> queryByPage(String name, PageRequest pageRequest) { | |||||
| long total = rayDao.count(name); | |||||
| List<Ray> rays = rayDao.queryByPage(name, pageRequest); | |||||
| return new PageImpl<>(rays, pageRequest, total); | |||||
| } | |||||
| @Override | |||||
| public Ray save(RayVo rayVo) throws Exception { | |||||
| Ray rayByName = rayDao.getRayByName(rayVo.getName()); | |||||
| if (rayByName != null) { | |||||
| throw new RuntimeException("实验名称已存在"); | |||||
| } | |||||
| Ray ray = new Ray(); | |||||
| BeanUtils.copyProperties(rayVo, ray); | |||||
| String username = SecurityUtils.getLoginUser().getUsername(); | |||||
| ray.setCreateBy(username); | |||||
| ray.setUpdateBy(username); | |||||
| String datasetJson = JacksonUtil.toJSONString(rayVo.getDataset()); | |||||
| ray.setDataset(datasetJson); | |||||
| String codeJson = JacksonUtil.toJSONString(rayVo.getCode()); | |||||
| ray.setCode(codeJson); | |||||
| rayDao.save(ray); | |||||
| return ray; | |||||
| } | |||||
| @Override | |||||
| public String edit(RayVo rayVo) throws Exception { | |||||
| Ray oldRay = rayDao.getRayByName(rayVo.getName()); | |||||
| if (oldRay != null && !oldRay.getId().equals(rayVo.getId())) { | |||||
| throw new RuntimeException("实验名称已存在"); | |||||
| } | |||||
| Ray ray = new Ray(); | |||||
| BeanUtils.copyProperties(rayVo, ray); | |||||
| String username = SecurityUtils.getLoginUser().getUsername(); | |||||
| ray.setUpdateBy(username); | |||||
| String parameters = JacksonUtil.toJSONString(rayVo.getParameters()); | |||||
| ray.setParameters(parameters); | |||||
| String pointsToEvaluate = JacksonUtil.toJSONString(rayVo.getPointsToEvaluate()); | |||||
| ray.setPointsToEvaluate(pointsToEvaluate); | |||||
| String datasetJson = JacksonUtil.toJSONString(rayVo.getDataset()); | |||||
| ray.setDataset(datasetJson); | |||||
| String codeJson = JacksonUtil.toJSONString(rayVo.getCode()); | |||||
| ray.setCode(codeJson); | |||||
| rayDao.edit(ray); | |||||
| return "修改成功"; | |||||
| } | |||||
| @Override | |||||
| public RayVo getRayDetail(Long id) throws IOException { | |||||
| Ray ray = rayDao.getRayById(id); | |||||
| RayVo rayVo = new RayVo(); | |||||
| BeanUtils.copyProperties(ray, rayVo); | |||||
| if (StringUtils.isNotEmpty(ray.getParameters())) { | |||||
| rayVo.setParameters(JsonUtils.jsonToMap(ray.getParameters())); | |||||
| } | |||||
| if (StringUtils.isNotEmpty(ray.getPointsToEvaluate())) { | |||||
| rayVo.setPointsToEvaluate(JsonUtils.jsonToMap(ray.getPointsToEvaluate())); | |||||
| } | |||||
| if (StringUtils.isNotEmpty(ray.getDataset())) { | |||||
| rayVo.setDataset(JsonUtils.jsonToMap(ray.getDataset())); | |||||
| } | |||||
| if (StringUtils.isNotEmpty(ray.getCode())) { | |||||
| rayVo.setCode(JsonUtils.jsonToMap(ray.getCode())); | |||||
| } | |||||
| return rayVo; | |||||
| } | |||||
| @Override | |||||
| public String delete(Long id) { | |||||
| Ray ray = rayDao.getRayById(id); | |||||
| if (ray == null) { | |||||
| throw new RuntimeException("实验不存在"); | |||||
| } | |||||
| String username = SecurityUtils.getLoginUser().getUsername(); | |||||
| String createBy = ray.getCreateBy(); | |||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | |||||
| throw new RuntimeException("无权限删除该实验"); | |||||
| } | |||||
| ray.setState(Constant.State_invalid); | |||||
| return rayDao.edit(ray) > 0 ? "删除成功" : "删除失败"; | |||||
| } | |||||
| @Override | |||||
| public String runRayIns(Long id) throws Exception { | |||||
| Ray ray = rayDao.getRayById(id); | |||||
| if (ray == null) { | |||||
| throw new Exception("自动超参数寻优配置不存在"); | |||||
| } | |||||
| //todo argo | |||||
| return null; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,76 @@ | |||||
| package com.ruoyi.platform.vo; | |||||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||||
| import io.swagger.annotations.ApiModel; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | |||||
| import java.util.Date; | |||||
| import java.util.Map; | |||||
| @Data | |||||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||||
| @ApiModel(description = "自动超参数寻优") | |||||
| public class RayVo { | |||||
| private Long id; | |||||
| @ApiModelProperty(value = "实验名称") | |||||
| private String name; | |||||
| @ApiModelProperty(value = "主函数代码文件") | |||||
| private String mainPy; | |||||
| @ApiModelProperty(value = "总实验次数") | |||||
| private Integer numSamples; | |||||
| @ApiModelProperty(value = "参数") | |||||
| private Map<String, Object> parameters; | |||||
| @ApiModelProperty(value = "手动指定需要运行的参数") | |||||
| private Map<String, Object> pointsToEvaluate; | |||||
| @ApiModelProperty(value = "保存路径") | |||||
| private String storagePath; | |||||
| @ApiModelProperty(value = "搜索算法") | |||||
| private String searchAlg; | |||||
| @ApiModelProperty(value = "调度算法") | |||||
| private String scheduler; | |||||
| @ApiModelProperty(value = "指标") | |||||
| private String metric; | |||||
| @ApiModelProperty(value = "指标最大化或最小化,min or max") | |||||
| private String mode; | |||||
| @ApiModelProperty(value = "搜索算法为ASHA,HyperBand时传入,每次试验的最大时间单位。测试将在max_t时间单位后停止。") | |||||
| private Integer maxT; | |||||
| @ApiModelProperty(value = "搜索算法为MedianStopping时传入,计算中位数的最小试验数。") | |||||
| private Integer minSamplesRequired; | |||||
| @ApiModelProperty(value = "使用cpu数") | |||||
| private Integer cpu; | |||||
| @ApiModelProperty(value = "使用gpu数") | |||||
| private Integer gpu; | |||||
| private String createBy; | |||||
| private Date createTime; | |||||
| private String updateBy; | |||||
| private Date updateTime; | |||||
| private Integer state; | |||||
| private String runState; | |||||
| @ApiModelProperty(value = "代码") | |||||
| private Map<String, Object> code; | |||||
| private Map<String, Object> dataset; | |||||
| } | |||||
| @@ -0,0 +1,109 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.ruoyi.platform.mapper.RayDao"> | |||||
| <insert id="save"> | |||||
| insert into ray(name, dataset, code, main_py, num_samples, parameters, points_to_evaluate, storage_path, | |||||
| search_alg, scheduler, metric, mode, max_t, | |||||
| min_samples_required, cpu, gpu, create_by, update_by) | |||||
| values (#{ray.name}, #{ray.dataset}, #{ray.code}, #{ray.mainPy}, #{ray.numSamples}, #{ray.parameters}, | |||||
| #{ray.pointsToEvaluate}, #{ray.storagePath}, | |||||
| #{ray.searchAlg}, #{ray.scheduler}, #{ray.metric}, #{ray.mode}, #{ray.maxT}, #{ray.minSamplesRequired}, | |||||
| #{ray.cpu}, #{ray.gpu}, #{ray.createBy}, #{ray.updateBy}) | |||||
| </insert> | |||||
| <update id="edit"> | |||||
| update ray | |||||
| <set> | |||||
| <if test="ray.name != null and ray.name !=''"> | |||||
| name = #{ray.name}, | |||||
| </if> | |||||
| <if test="ray.dataset != null and ray.dataset !=''"> | |||||
| dataset = #{ray.dataset}, | |||||
| </if> | |||||
| <if test="ray.code != null and ray.code !=''"> | |||||
| code = #{ray.code}, | |||||
| </if> | |||||
| <if test="ray.mainPy != null and ray.mainPy !=''"> | |||||
| main_py = #{ray.mainPy}, | |||||
| </if> | |||||
| <if test="ray.numSamples != null"> | |||||
| num_samples = #{ray.numSamples}, | |||||
| </if> | |||||
| <if test="ray.parameters != null and ray.parameters !=''"> | |||||
| parameters = #{ray.parameters}, | |||||
| </if> | |||||
| <if test="ray.pointsToEvaluate != null and ray.pointsToEvaluate !=''"> | |||||
| points_to_evaluate = #{ray.pointsToEvaluate}, | |||||
| </if> | |||||
| <if test="ray.storagePath != null and ray.storagePath !=''"> | |||||
| storage_path = #{ray.storagePath}, | |||||
| </if> | |||||
| <if test="ray.searchAlg != null and ray.searchAlg !=''"> | |||||
| search_alg = #{ray.searchAlg}, | |||||
| </if> | |||||
| <if test="ray.scheduler != null and ray.scheduler !=''"> | |||||
| scheduler = #{ray.scheduler}, | |||||
| </if> | |||||
| <if test="ray.metric != null and ray.metric !=''"> | |||||
| metric = #{ray.metric}, | |||||
| </if> | |||||
| <if test="ray.mode != null and ray.mode !=''"> | |||||
| mode = #{ray.mode}, | |||||
| </if> | |||||
| <if test="ray.maxT != null"> | |||||
| max_t = #{ray.maxT}, | |||||
| </if> | |||||
| <if test="ray.minSamplesRequired != null"> | |||||
| min_samples_required = #{ray.minSamplesRequired}, | |||||
| </if> | |||||
| <if test="ray.cpu != null"> | |||||
| cpu = #{ray.cpu}, | |||||
| </if> | |||||
| <if test="ray.gpu != null"> | |||||
| gpu = #{ray.gpu}, | |||||
| </if> | |||||
| <if test="ray.updateBy != null and ray.updateBy !=''"> | |||||
| update_by = #{ray.updateBy}, | |||||
| </if> | |||||
| <if test="ray.statusList != null and ray.statusList !=''"> | |||||
| status_list = #{ray.statusList}, | |||||
| </if> | |||||
| <if test="ray.state != null"> | |||||
| state = #{ray.state}, | |||||
| </if> | |||||
| </set> | |||||
| where id = #{ray.id} | |||||
| </update> | |||||
| <select id="count" resultType="java.lang.Long"> | |||||
| select count(1) from ray | |||||
| <include refid="common_condition"></include> | |||||
| </select> | |||||
| <select id="queryByPage" resultType="com.ruoyi.platform.domain.Ray"> | |||||
| select * from ray | |||||
| <include refid="common_condition"></include> | |||||
| </select> | |||||
| <select id="getRayByName" resultType="com.ruoyi.platform.domain.Ray"> | |||||
| select * | |||||
| from ray _ | |||||
| where name = #{name} | |||||
| and state = 1 | |||||
| </select> | |||||
| <select id="getRayById" resultType="com.ruoyi.platform.domain.Ray"> | |||||
| select * | |||||
| from ray | |||||
| where id = #{id} | |||||
| </select> | |||||
| <sql id="common_condition"> | |||||
| <where> | |||||
| state = 1 | |||||
| <if test="name != null and name != ''"> | |||||
| and name like concat('%', #{name}, '%') | |||||
| </if> | |||||
| </where> | |||||
| </sql> | |||||
| </mapper> | |||||
| @@ -0,0 +1,69 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.ruoyi.platform.mapper.RayInsDao"> | |||||
| <insert id="insert"> | |||||
| insert into ray_ins(ray_id, result_path, argo_ins_name, argo_ins_ns, node_status, node_result, param, source, | |||||
| status) | |||||
| values (#{rayIns.rayId}, #{rayIns.resultPath}, #{rayIns.argoInsName}, #{rayIns.argoInsNs}, | |||||
| #{rayIns.nodeStatus}, #{rayIns.nodeResult}, #{rayIns.param}, #{rayIns.source}, #{rayIns.status}) | |||||
| </insert> | |||||
| <update id="update"> | |||||
| update ray_ins | |||||
| <set> | |||||
| <if test="rayIns.resultPath != null and rayIns.resultPath != ''"> | |||||
| result_path = #{rayIns.resultPath}, | |||||
| </if> | |||||
| <if test="rayIns.status != null and rayIns.status != ''"> | |||||
| status = #{rayIns.status}, | |||||
| </if> | |||||
| <if test="rayIns.nodeStatus != null and rayIns.nodeStatus != ''"> | |||||
| node_status = #{rayIns.nodeStatus}, | |||||
| </if> | |||||
| <if test="rayIns.nodeResult != null and rayIns.nodeResult != ''"> | |||||
| node_result = #{rayIns.nodeResult}, | |||||
| </if> | |||||
| <if test="rayIns.state != null"> | |||||
| state = #{rayIns.state}, | |||||
| </if> | |||||
| <if test="rayIns.finishTime != null"> | |||||
| finish_time = #{rayIns.finishTime}, | |||||
| </if> | |||||
| </set> | |||||
| where id = #{rayIns.id} | |||||
| </update> | |||||
| <select id="count" resultType="java.lang.Long"> | |||||
| select count(1) | |||||
| from ray_ins | |||||
| <where> | |||||
| state = 1 | |||||
| and ray_id = #{rayId} | |||||
| </where> | |||||
| </select> | |||||
| <select id="queryAllByLimit" resultType="com.ruoyi.platform.domain.RayIns"> | |||||
| select * from ray_ins | |||||
| <where> | |||||
| state = 1 | |||||
| and ray_id = #{rayId} | |||||
| </where> | |||||
| order by update_time DESC | |||||
| limit #{pageable.offset}, #{pageable.pageSize} | |||||
| </select> | |||||
| <select id="queryById" resultType="com.ruoyi.platform.domain.RayIns"> | |||||
| select * from ray_ins | |||||
| <where> | |||||
| state = 1 and id = #{id} | |||||
| </where> | |||||
| </select> | |||||
| <select id="getByRayId" resultType="com.ruoyi.platform.domain.RayIns"> | |||||
| select * | |||||
| from ray_ins | |||||
| where ray_id = #{rayId} | |||||
| and state = 1 | |||||
| order by update_time DESC limit 5 | |||||
| </select> | |||||
| </mapper> | |||||