| @@ -29,10 +29,13 @@ public class Constant { | |||
| public final static String Running = "Running"; | |||
| public final static String Failed = "Failed"; | |||
| public final static String Pending = "Pending"; | |||
| public final static String Terminated = "Terminated"; | |||
| public final static String Init = "Init"; | |||
| public final static String Stopped = "Stopped"; | |||
| public final static String Succeeded = "Succeeded"; | |||
| public final static String Type_Train = "train"; | |||
| public final static String Type_Evaluate = "evaluate"; | |||
| public final static String AutoMl_Classification = "classification"; | |||
| } | |||
| @@ -16,10 +16,14 @@ public class AutoMlIns { | |||
| private Long autoMlId; | |||
| private String resultPath; | |||
| private String modelPath; | |||
| private String imgPath; | |||
| private String runHistoryPath; | |||
| private Integer state; | |||
| private String status; | |||
| @@ -41,4 +45,6 @@ public class AutoMlIns { | |||
| private Date createTime; | |||
| private Date updateTime; | |||
| private Date finishTime; | |||
| } | |||
| @@ -1,7 +1,9 @@ | |||
| package com.ruoyi.platform.service.impl; | |||
| import com.ruoyi.platform.constant.Constant; | |||
| import com.ruoyi.platform.domain.AutoMl; | |||
| import com.ruoyi.platform.domain.AutoMlIns; | |||
| import com.ruoyi.platform.mapper.AutoMlDao; | |||
| import com.ruoyi.platform.mapper.AutoMlInsDao; | |||
| import com.ruoyi.platform.service.AutoMlInsService; | |||
| import com.ruoyi.platform.utils.DateUtils; | |||
| @@ -29,7 +31,8 @@ public class AutoMlInsServiceImpl implements AutoMlInsService { | |||
| @Resource | |||
| private AutoMlInsDao autoMlInsDao; | |||
| @Resource | |||
| private AutoMlDao autoMlDao; | |||
| @Override | |||
| public Page<AutoMlIns> queryByPage(AutoMlIns autoMlIns, PageRequest pageRequest) throws IOException { | |||
| @@ -61,6 +64,7 @@ public class AutoMlInsServiceImpl implements AutoMlInsService { | |||
| autoMlIns.setState(Constant.State_invalid); | |||
| int update = autoMlInsDao.update(autoMlIns); | |||
| if (update > 0) { | |||
| updateAutoMlStatus(autoMlIns.getAutoMlId()); | |||
| return "删除成功"; | |||
| } else { | |||
| return "删除失败"; | |||
| @@ -121,7 +125,7 @@ public class AutoMlInsServiceImpl implements AutoMlInsService { | |||
| String finishedAtString = (String) status.get("finishedAt"); | |||
| if (finishedAtString != null && !finishedAtString.isEmpty()) { | |||
| Date finishTime = DateUtils.convertUTCtoShanghaiDate(finishedAtString); | |||
| ins.setUpdateTime(finishTime); | |||
| ins.setFinishTime(finishTime); | |||
| } | |||
| // 解析nodes字段,提取节点状态并转换为JSON字符串 | |||
| @@ -227,4 +231,19 @@ public class AutoMlInsServiceImpl implements AutoMlInsService { | |||
| public AutoMlIns getDetailById(Long id) { | |||
| return this.autoMlInsDao.queryById(id); | |||
| } | |||
| public void updateAutoMlStatus(Long autoMlId) { | |||
| List<AutoMlIns> insList = autoMlInsDao.getByAutoMlId(autoMlId); | |||
| 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); | |||
| AutoMl autoMl = autoMlDao.getAutoMlById(autoMlId); | |||
| if (!StringUtils.equals(autoMl.getStatusList(), subStatus)) { | |||
| autoMl.setStatusList(subStatus); | |||
| autoMlDao.edit(autoMl); | |||
| } | |||
| } | |||
| } | |||
| @@ -199,7 +199,9 @@ public class AutoMlServiceImpl implements AutoMlService { | |||
| } else { | |||
| autoMlIns.setImgPath(outputPath + "Auto-sklearn_accuracy_over_time.png" + "," + outputPath + "regression.png"); | |||
| } | |||
| autoMlIns.setResultPath(outputPath + "result.txt"); | |||
| String seed = autoMl.getSeed() != null ? String.valueOf(autoMl.getSeed()) : "1"; | |||
| autoMlIns.setRunHistoryPath(outputPath + "smac3-output/run_" + seed + "/runhistory.json"); | |||
| autoMlInsDao.insert(autoMlIns); | |||
| } catch (Exception e) { | |||
| @@ -3,9 +3,12 @@ | |||
| <mapper namespace="com.ruoyi.platform.mapper.AutoMlInsDao"> | |||
| <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | |||
| insert into auto_ml_ins(auto_ml_id, model_path, img_path, node_status, node_result, param, source, argo_ins_name, argo_ins_ns) | |||
| values (#{autoMlIns.autoMlId}, #{autoMlIns.modelPath}, #{autoMlIns.imgPath}, #{autoMlIns.nodeStatus}, | |||
| #{autoMlIns.nodeResult}, #{autoMlIns.param}, #{autoMlIns.source}, #{autoMlIns.argoInsName}, #{autoMlIns.argoInsNs}) | |||
| insert into auto_ml_ins(auto_ml_id, result_path, model_path, img_path, run_history_path, node_status, | |||
| node_result, param, source, argo_ins_name, argo_ins_ns, status) | |||
| values (#{autoMlIns.autoMlId}, #{autoMlIns.resultPath}, #{autoMlIns.modelPath}, #{autoMlIns.imgPath}, | |||
| #{autoMlIns.runHistoryPath}, #{autoMlIns.nodeStatus}, | |||
| #{autoMlIns.nodeResult}, #{autoMlIns.param}, #{autoMlIns.source}, #{autoMlIns.argoInsName}, | |||
| #{autoMlIns.argoInsNs}, #{autoMlIns.status}) | |||
| </insert> | |||
| <update id="update"> | |||
| @@ -32,6 +35,9 @@ | |||
| <if test="autoMlIns.updateTime != null"> | |||
| update_time = #{autoMlIns.updateTime}, | |||
| </if> | |||
| <if test="autoMlIns.finishTime != null"> | |||
| finish_time = #{autoMlIns.finishTime}, | |||
| </if> | |||
| </set> | |||
| where id = #{autoMlIns.id} | |||
| </update> | |||
| @@ -41,9 +47,7 @@ | |||
| from auto_ml_ins | |||
| <where> | |||
| state = 1 | |||
| <if test="autoMlIns.autoMlId != null"> | |||
| and auto_ml_id = #{autoMlIns.autoMlId} | |||
| </if> | |||
| and auto_ml_id = #{autoMlIns.autoMlId} | |||
| </where> | |||
| </select> | |||
| @@ -51,9 +55,7 @@ | |||
| select * from auto_ml_ins | |||
| <where> | |||
| state = 1 | |||
| <if test="autoMlIns.autoMlId != null"> | |||
| and auto_ml_id = #{autoMlIns.autoMlId} | |||
| </if> | |||
| and auto_ml_id = #{autoMlIns.autoMlId} | |||
| </where> | |||
| order by update_time DESC | |||
| limit #{pageable.offset}, #{pageable.pageSize} | |||