diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/textClassfication/TextClassificationController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/textClassfication/TextClassificationController.java new file mode 100644 index 00000000..4d643e80 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/textClassfication/TextClassificationController.java @@ -0,0 +1,62 @@ +package com.ruoyi.platform.controller.textClassfication; + +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.GenericsAjaxResult; +import com.ruoyi.platform.domain.TextClassification; +import com.ruoyi.platform.service.TextClassificationService; +import com.ruoyi.platform.vo.TextClassificationVo; +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; + +@RestController +@RequestMapping("textClassification") +@Api("文本分类") +public class TextClassificationController extends BaseController { + @Resource + private TextClassificationService textClassificationService; + + @GetMapping + @ApiOperation("分页查询") + public GenericsAjaxResult> 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.textClassificationService.queryByPage(name, pageRequest)); + } + + @PostMapping + @ApiOperation("新增文本分类") + public GenericsAjaxResult add(@RequestBody TextClassificationVo textClassificationVo) throws Exception { + return genericsSuccess(this.textClassificationService.save(textClassificationVo)); + } + + @PutMapping + @ApiOperation("编辑文本分类") + public GenericsAjaxResult edit(@RequestBody TextClassificationVo textClassificationVo) throws Exception { + return genericsSuccess(this.textClassificationService.edit(textClassificationVo)); + } + + @GetMapping("/getTextClassificationDetail") + @ApiOperation("获取文本分类详细信息") + public GenericsAjaxResult getTextClassificationDetail(@RequestParam("id") Long id)throws IOException { + return genericsSuccess(this.textClassificationService.getTextClassificationDetail(id)); + } + + @DeleteMapping("{id}") + @ApiOperation("删除文本分类") + public GenericsAjaxResult deleteTextClassification(@PathVariable("id") Long id){ + return genericsSuccess(this.textClassificationService.delete(id)); + } + + @PostMapping("/run/{id}") + @ApiOperation("运行文本分类") + public GenericsAjaxResult runTextClassification(@PathVariable("id") Long id) throws Exception { + return genericsSuccess(this.textClassificationService.runTextClassificationIns(id)); + } +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/textClassfication/TextClassificationInsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/textClassfication/TextClassificationInsController.java new file mode 100644 index 00000000..9c6c7692 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/textClassfication/TextClassificationInsController.java @@ -0,0 +1,59 @@ +package com.ruoyi.platform.controller.textClassfication; + +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.GenericsAjaxResult; +import com.ruoyi.platform.domain.TextClassificationIns; +import com.ruoyi.platform.service.TextClassificationInsService; +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.util.List; + +@RestController +@RequestMapping("textClassificationIns") +@Api("文本分类实验实例") +public class TextClassificationInsController extends BaseController { + @Resource + private TextClassificationInsService textClassificationInsService; + + @GetMapping + @ApiOperation("分页查询") + public GenericsAjaxResult> queryByPage(TextClassificationIns textClassificationIns, int page, int size){ + PageRequest pageRequest = PageRequest.of(page, size); + return genericsSuccess(this.textClassificationInsService.queryByPage(textClassificationIns, pageRequest)); + } + + @PostMapping + @ApiOperation("新增实验实例") + public GenericsAjaxResult add(@RequestBody TextClassificationIns textClassificationIns) { + return genericsSuccess(this.textClassificationInsService.insert(textClassificationIns)); + } + + @DeleteMapping("{id}") + @ApiOperation("删除实验实例") + public GenericsAjaxResult deleteById(@PathVariable("id") Long id) { + return genericsSuccess(this.textClassificationInsService.removeById(id)); + } + + @DeleteMapping("batchDelete") + @ApiOperation("批量删除实验实例") + public GenericsAjaxResult batchDelete(@RequestBody List ids) { + return genericsSuccess(this.textClassificationInsService.batchDelete(ids)); + } + + @PutMapping("{id}") + @ApiOperation("终止实验实例") + public GenericsAjaxResult terminateTextClassificationIns(@PathVariable("id") Long id) throws Exception { + return genericsSuccess(this.textClassificationInsService.terminateTextClassificationIns(id)); + } + + @GetMapping("{id}") + @ApiOperation("查看实验实例详情") + public GenericsAjaxResult getDetailById(@PathVariable("id") Long id) { + return genericsSuccess(this.textClassificationInsService.getDetailById(id)); + } +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/TextClassification.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/TextClassification.java new file mode 100644 index 00000000..f6a239c5 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/TextClassification.java @@ -0,0 +1,50 @@ +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 TextClassification { + private Long id; + + @ApiModelProperty(value = "实验名称") + private String name; + + @ApiModelProperty(value = "实验描述") + private String description; + + @ApiModelProperty(value = "模型") + private String model; + + @ApiModelProperty(value = "数据集") + private String dataset; + + @ApiModelProperty(value = "epochs") + private Integer epochs; + + @ApiModelProperty(value = "batch_size") + private Integer batchSize; + + @ApiModelProperty(value = "学习率") + private Float lr; + + private String createBy; + + private String updateBy; + + private Date createTime; + + private Date updateTime; + + private Integer state; + + @ApiModelProperty(value = "状态列表") + private String statusList; +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/TextClassificationIns.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/TextClassificationIns.java new file mode 100644 index 00000000..09c43f25 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/TextClassificationIns.java @@ -0,0 +1,41 @@ +package com.ruoyi.platform.domain; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.util.Date; + +@Data +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +@ApiModel(description = "文本分类实验实例") +public class TextClassificationIns { + private Long id; + + private Long textClassificationId; + + private Integer state; + + private String status; + + private String param; + + private Date createTime; + + private Date updateTime; + + private Date finishTime; + + private String argoInsName; + + private String argoInsNs; + + private String resultPath; + + private String ModelPath; + + private String nodeStatus; + + private String nodeResult; +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/TextClassificationDao.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/TextClassificationDao.java new file mode 100644 index 00000000..f69f248b --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/TextClassificationDao.java @@ -0,0 +1,23 @@ +package com.ruoyi.platform.mapper; + +import com.ruoyi.platform.domain.TextClassification; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +public interface TextClassificationDao { + long count(@Param("name") String name); + + List queryByPage(@Param("name") String name, @Param("pageable") Pageable pageable); + + TextClassification getByName(@Param("name") String name); + + TextClassification getById(@Param("id") Long id); + + int save(@Param("textClassification") TextClassification textClassification); + + int edit(@Param("textClassification") TextClassification textClassification); + + List queryByDatasetId(@Param("datasetId") String datasetId); +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/TextClassificationInsDao.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/TextClassificationInsDao.java new file mode 100644 index 00000000..3bc16cd2 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/TextClassificationInsDao.java @@ -0,0 +1,23 @@ +package com.ruoyi.platform.mapper; + +import com.ruoyi.platform.domain.TextClassificationIns; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +public interface TextClassificationInsDao { + long count(@Param("textClassificationIns") TextClassificationIns textClassificationIns); + + List queryAllByLimit(@Param("textClassificationIns") TextClassificationIns textClassificationIns, @Param("pageable") Pageable pageable); + + List getByTextClassificationId(@Param("textClassificationId") Long textClassificationId); + + TextClassificationIns queryById(@Param("id") Long id); + + int insert(@Param("textClassificationIns") TextClassificationIns textClassificationIns); + + int update(@Param("textClassificationIns") TextClassificationIns textClassificationIns); + + List queryByNotTerminated(); +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/TextClassificationInsService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/TextClassificationInsService.java new file mode 100644 index 00000000..d14c3a51 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/TextClassificationInsService.java @@ -0,0 +1,26 @@ +package com.ruoyi.platform.service; +import com.ruoyi.platform.domain.TextClassificationIns; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +import java.util.List; + +public interface TextClassificationInsService { + Page queryByPage(TextClassificationIns textClassificationIns, PageRequest pageRequest); + + TextClassificationIns insert(TextClassificationIns textClassificationIns); + + String removeById(Long id); + + String batchDelete(List ids); + + boolean terminateTextClassificationIns(Long id) throws Exception; + + TextClassificationIns getDetailById(Long id); + + List queryByNotTerminated(); + + TextClassificationIns queryStatusFromArgo(TextClassificationIns textClassificationIns); + + void updateTextClassificationStatus(Long textClassificationId); +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/TextClassificationService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/TextClassificationService.java new file mode 100644 index 00000000..fffa57de --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/TextClassificationService.java @@ -0,0 +1,21 @@ +package com.ruoyi.platform.service; +import com.ruoyi.platform.domain.TextClassification; +import com.ruoyi.platform.vo.TextClassificationVo; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +import java.io.IOException; + +public interface TextClassificationService { + Page queryByPage(String name, PageRequest pageRequest); + + TextClassification save(TextClassificationVo textClassificationVo) throws Exception; + + String edit(TextClassificationVo textClassificationVo) throws Exception; + + String delete(Long id); + + TextClassificationVo getTextClassificationDetail(Long id) throws IOException; + + String runTextClassificationIns(Long id) throws Exception; +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java index ca35a866..60cb3868 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java @@ -126,7 +126,7 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res)); // 检查响应是否为空或无内容 if (StringUtils.isEmpty(req)) { - throw new RuntimeException("终止响应内容为空。"); + throw new RuntimeException("终止响应内容为空"); } // 将响应的JSON字符串转换为Map对象 @@ -214,19 +214,19 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res)); // 检查响应是否为空或无内容 if (req == null || StringUtils.isEmpty(req)) { - throw new RuntimeException("工作流状态响应为空。"); + throw new RuntimeException("工作流状态响应为空"); } // 将响应的JSON字符串转换为Map对象 Map runResMap = JsonUtils.jsonToMap(req); // 从响应Map中获取"data"部分 Map data = (Map) runResMap.get("data"); if (data == null || data.isEmpty()) { - throw new RuntimeException("工作流数据为空."); + throw new RuntimeException("工作流数据为空"); } // 从"data"中获取"status"部分,并返回"phase"的值 Map status = (Map) data.get("status"); if (status == null || status.isEmpty()) { - throw new RuntimeException("工作流状态为空。"); + throw new RuntimeException("工作流状态为空"); } //解析流水线结束时间 diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java index a1f2f93b..04b3809a 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java @@ -60,13 +60,13 @@ public class ActiveLearnServiceImpl implements ActiveLearnService { @Override public ActiveLearn save(ActiveLearnVo activeLearnVo) throws Exception { + if (activeLearnVo.getName().length() >= 64) { + throw new RuntimeException("实验名称大于最大长度"); + } ActiveLearn activeLearnByName = activeLearnDao.getActiveLearnByName(activeLearnVo.getName()); if (activeLearnByName != null) { throw new RuntimeException("实验名称已存在"); } - if (activeLearnVo.getName().length() >= 64) { - throw new RuntimeException("实验名称大于最大长度"); - } ActiveLearn activeLearn = new ActiveLearn(); BeanUtils.copyProperties(activeLearnVo, activeLearn); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlInsServiceImpl.java index 2fbceeea..1294d426 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlInsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlInsServiceImpl.java @@ -108,19 +108,19 @@ public class AutoMlInsServiceImpl implements AutoMlInsService { String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res)); // 检查响应是否为空或无内容 if (req == null || StringUtils.isEmpty(req)) { - throw new RuntimeException("工作流状态响应为空。"); + throw new RuntimeException("工作流状态响应为空"); } // 将响应的JSON字符串转换为Map对象 Map runResMap = JsonUtils.jsonToMap(req); // 从响应Map中获取"data"部分 Map data = (Map) runResMap.get("data"); if (data == null || data.isEmpty()) { - throw new RuntimeException("工作流数据为空."); + throw new RuntimeException("工作流数据为空"); } // 从"data"中获取"status"部分,并返回"phase"的值 Map status = (Map) data.get("status"); if (status == null || status.isEmpty()) { - throw new RuntimeException("工作流状态为空。"); + throw new RuntimeException("工作流状态为空"); } //解析流水线结束时间 @@ -190,7 +190,7 @@ public class AutoMlInsServiceImpl implements AutoMlInsService { String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res)); // 检查响应是否为空或无内容 if (StringUtils.isEmpty(req)) { - throw new RuntimeException("终止响应内容为空。"); + throw new RuntimeException("终止响应内容为空"); } // 将响应的JSON字符串转换为Map对象 @@ -211,8 +211,8 @@ public class AutoMlInsServiceImpl implements AutoMlInsService { if (innerMap.containsKey("phase")) { String phaseValue = (String) innerMap.get("phase"); // 如果值不等于 Succeeded,则赋值为 Failed - if (!StringUtils.equals("Succeeded", phaseValue)) { - innerMap.put("phase", "Failed"); + if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { + innerMap.put("phase", Constant.Failed); } } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java index bff62c3c..99354424 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java @@ -66,15 +66,13 @@ public class AutoMlServiceImpl implements AutoMlService { @Override public AutoMl save(AutoMlVo autoMlVo) throws Exception { + if (autoMlVo.getMlName().length() >= 64) { + throw new RuntimeException("实验名称大于最大长度"); + } AutoMl autoMlByName = autoMlDao.getAutoMlByName(autoMlVo.getMlName()); if (autoMlByName != null) { throw new RuntimeException("实验名称已存在"); } - - if (autoMlVo.getMlName().length() >= 64) { - throw new RuntimeException("实验名称大于最大长度"); - } - AutoMl autoMl = new AutoMl(); BeanUtils.copyProperties(autoMlVo, autoMl); String username = SecurityUtils.getLoginUser().getUsername(); @@ -178,13 +176,13 @@ public class AutoMlServiceImpl implements AutoMlService { String runRes = HttpUtils.sendPost(argoUrl + argoWorkflowRun, JsonUtils.mapToJson(runReqMap)); if (runRes == null || StringUtils.isEmpty(runRes)) { - throw new RuntimeException("Failed to run workflow."); + throw new RuntimeException("运行流水线失败"); } Map runResMap = JsonUtils.jsonToMap(runRes); Map data = (Map) runResMap.get("data"); //判断data为空 if (data == null || MapUtils.isEmpty(data)) { - throw new RuntimeException("Failed to run workflow."); + throw new RuntimeException("运行流水线失败"); } Map metadata = (Map) data.get("metadata"); // 插入记录到实验实例表 diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java index 8c4f02f3..872b34b9 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java @@ -94,7 +94,7 @@ public class CodeConfigServiceImpl implements CodeConfigService { List assetWorkflow = assetWorkflowDao.getAssetWorkflow(id, Constant.Asset_Type_Code, null); if (assetWorkflow != null && !assetWorkflow.isEmpty()) { String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); - throw new Exception("该代码配置被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); + throw new Exception("该代码配置被流水线:" + workflows + "使用,不能删除,请先删除流水线"); } HashMap map = new HashMap<>(); @@ -102,19 +102,19 @@ public class CodeConfigServiceImpl implements CodeConfigService { List rayList = rayDao.queryByCodeConfig(JSON.toJSONString(map)); if (rayList != null && !rayList.isEmpty()) { String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); - throw new Exception("该代码配置被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); + throw new Exception("该代码配置被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优"); } List activeLearnList = activeLearnDao.queryByCodeConfig(JSON.toJSONString(map)); if (activeLearnList != null && !activeLearnList.isEmpty()) { String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); - throw new Exception("该代码配置被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习。"); + throw new Exception("该代码配置被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习"); } List serviceVersionList = serviceDao.queryByCodeConfig(JSON.toJSONString(map)); if (serviceVersionList != null && !serviceVersionList.isEmpty()) { String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet())); - throw new Exception("该代码配置被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本。"); + throw new Exception("该代码配置被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本"); } LoginUser loginUser = SecurityUtils.getLoginUser(); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java index 47b05f0d..a93628e3 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java @@ -121,7 +121,7 @@ public class ComponentServiceImpl implements ComponentService { Integer existingCount = this.componentDao.countByNameAndCategoryId(component.getComponentName(),component.getCategoryId()); if(existingCount != null && existingCount > 0) { - throw new RuntimeException("该类别下已有同名组件。"); + throw new RuntimeException("该类别下已有同名组件"); } this.componentDao.insert(component); @@ -140,7 +140,7 @@ public class ComponentServiceImpl implements ComponentService { //只能更新当前存在的组件 if (component == null){ - throw new RuntimeException("组件不存在,无法更新。"); + throw new RuntimeException("组件不存在,无法更新"); } //将object转成string类型 diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java index a08d3db4..ba3f35e8 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java @@ -147,7 +147,7 @@ public class DatasetServiceImpl implements DatasetService { public Dataset update(Dataset dataset) { int currentState = dataset.getState(); if (currentState == 0) { - throw new RuntimeException("数据集已被删除,无法更新。"); + throw new RuntimeException("数据集已被删除,无法更新"); } LoginUser loginUser = SecurityUtils.getLoginUser(); dataset.setUpdateBy(loginUser.getUsername()); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java index 61d61031..d4e99abc 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java @@ -101,7 +101,7 @@ public class DatasetVersionServiceImpl implements DatasetVersionService { public DatasetVersion update(DatasetVersion datasetVersion) { int currentState = datasetVersion.getState(); if (currentState == 0){ - throw new RuntimeException("数据集版本已被删除,无法更新。"); + throw new RuntimeException("数据集版本已被删除,无法更新"); } LoginUser loginUser = SecurityUtils.getLoginUser(); datasetVersion.setUpdateBy(loginUser.getUsername()); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java index 33f2d338..b58e449b 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java @@ -285,7 +285,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res)); // 检查响应是否为空或无内容 if (req == null || StringUtils.isEmpty(req)) { - throw new RuntimeException("工作流状态响应为空。"); + throw new RuntimeException("工作流状态响应为空"); } // 将响应的JSON字符串转换为Map对象 @@ -293,12 +293,12 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { // 从响应Map中获取"data"部分 Map data = (Map) runResMap.get("data"); if (data == null || data.isEmpty()) { - throw new RuntimeException("工作流数据为空."); + throw new RuntimeException("工作流数据为空"); } // 从"data"中获取"status"部分,并返回"phase"的值 Map status = (Map) data.get("status"); if (status == null || status.isEmpty()) { - throw new RuntimeException("工作流状态为空。"); + throw new RuntimeException("工作流状态为空"); } //解析流水线结束时间 @@ -379,7 +379,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res)); // 检查响应是否为空或无内容 if (StringUtils.isEmpty(req)) { - throw new RuntimeException("终止响应内容为空。"); + throw new RuntimeException("终止响应内容为空"); } // 将响应的JSON字符串转换为Map对象 @@ -509,7 +509,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { // 从响应Map中获取"data"的值,也就是日志的值 String experimentInsLog = (String) runResMap.get("data"); if (experimentInsLog == null) { - throw new RuntimeException("日志为空。"); + throw new RuntimeException("日志为空"); } //返回日志内容 return experimentInsLog; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java index 0a6b2bc7..96193527 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java @@ -264,13 +264,13 @@ public class ExperimentServiceImpl implements ExperimentService { String runRes = HttpUtils.sendPost(argoUrl + argoWorkflowRun, JsonUtils.mapToJson(runReqMap)); if (runRes == null || StringUtils.isEmpty(runRes)) { - throw new RuntimeException("Failed to run workflow."); + throw new RuntimeException("运行流水线失败"); } Map runResMap = JsonUtils.jsonToMap(runRes); Map data = (Map) runResMap.get("data"); //判断data为空 if (data == null || MapUtils.isEmpty(data)) { - throw new RuntimeException("Failed to run workflow."); + throw new RuntimeException("运行流水线失败"); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/GitServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/GitServiceImpl.java index 60f62afe..684d8069 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/GitServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/GitServiceImpl.java @@ -140,7 +140,7 @@ public class GitServiceImpl implements GitService { String req = httpUtils.sendGetWithToken(gitendpoint + "/api/v1/" + owner + "/" + projectName + "/branches/all.json", null, token); // 解析响应JSON if (StringUtils.isEmpty(req)) { - throw new RuntimeException("终止响应内容为空。"); + throw new RuntimeException("终止响应内容为空"); } // 将响应的JSON字符串转换为List对象 List> mapList = JacksonUtil.parseJSONStr2MapList(req); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java index fb7f66f5..0c52a9bb 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java @@ -144,7 +144,7 @@ public class ImageServiceImpl implements ImageService { public Image update(Image image) { int currentState = image.getState(); if (currentState == 0) { - throw new RuntimeException("镜像已被删除,无法更新。"); + throw new RuntimeException("镜像已被删除,无法更新"); } LoginUser loginUser = SecurityUtils.getLoginUser(); image.setUpdateBy(loginUser.getUsername()); @@ -175,7 +175,7 @@ public class ImageServiceImpl implements ImageService { List assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(id), Constant.Asset_Type_Image, null); if (assetWorkflow != null && !assetWorkflow.isEmpty()) { String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); - throw new Exception("该镜像被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); + throw new Exception("该镜像被流水线:" + workflows + "使用,不能删除,请先删除流水线"); } HashMap map = new HashMap<>(); @@ -183,25 +183,25 @@ public class ImageServiceImpl implements ImageService { List rayList = rayDao.queryByImageId(JSON.toJSONString(map)); if (rayList != null && !rayList.isEmpty()) { String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); - throw new Exception("该镜像被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); + throw new Exception("该镜像被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优"); } List activeLearnList = activeLearnDao.queryByImageId(JSON.toJSONString(map)); if (activeLearnList != null && !activeLearnList.isEmpty()) { String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); - throw new Exception("该镜像被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习。"); + throw new Exception("该镜像被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习"); } List devEnvironmentList = devEnvironmentDao.queryByImageId(JSON.toJSONString(map)); if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) { String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet())); - throw new Exception("该镜像被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境。"); + throw new Exception("该镜像被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境"); } List serviceVersionList = serviceDao.queryByImageId(JSON.toJSONString(map)); if (serviceVersionList != null && !serviceVersionList.isEmpty()) { String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet())); - throw new Exception("该镜像被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本。"); + throw new Exception("该镜像被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本"); } //判断权限,只有admin和创建者本身可以删除该数据集 diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageVersionServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageVersionServiceImpl.java index 2f35c63d..7205a225 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageVersionServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageVersionServiceImpl.java @@ -86,7 +86,7 @@ public class ImageVersionServiceImpl implements ImageVersionService { List assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(imageVersion.getImageId()), Constant.Asset_Type_Image, imageVersion.getTagName()); if (assetWorkflow != null && !assetWorkflow.isEmpty()) { String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); - return GenericsAjaxResult.error("该镜像版本被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); + return GenericsAjaxResult.error("该镜像版本被流水线:" + workflows + "使用,不能删除,请先删除流水线"); } HashMap map = new HashMap<>(); @@ -94,25 +94,25 @@ public class ImageVersionServiceImpl implements ImageVersionService { List rayList = rayDao.queryByImageId(JSON.toJSONString(map)); if (rayList != null && !rayList.isEmpty()) { String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); - return GenericsAjaxResult.error("该镜像版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); + return GenericsAjaxResult.error("该镜像版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优"); } List activeLearnList = activeLearnDao.queryByImageId(JSON.toJSONString(map)); if (activeLearnList != null && !activeLearnList.isEmpty()) { String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); - return GenericsAjaxResult.error("该镜像版本被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习。"); + return GenericsAjaxResult.error("该镜像版本被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习"); } List devEnvironmentList = devEnvironmentDao.queryByImageId(JSON.toJSONString(map)); if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) { String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet())); - throw new Exception("该镜像版本被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境。"); + throw new Exception("该镜像版本被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境"); } List serviceVersionList = serviceDao.queryByImageId(JSON.toJSONString(map)); if (serviceVersionList != null && !serviceVersionList.isEmpty()) { String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet())); - throw new Exception("该镜像版本被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本。"); + throw new Exception("该镜像版本被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本"); } //判断权限,只有admin和创建者本身可以删除该数据集 @@ -156,7 +156,7 @@ public class ImageVersionServiceImpl implements ImageVersionService { public ImageVersion update(ImageVersion imageVersion) { int currentState = imageVersion.getState(); if (currentState == 0) { - throw new RuntimeException("镜像版本已被删除,无法更新。"); + throw new RuntimeException("镜像版本已被删除,无法更新"); } LoginUser loginUser = SecurityUtils.getLoginUser(); imageVersion.setUpdateBy(loginUser.getUsername()); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java index c6c9ae0e..71f02654 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java @@ -190,7 +190,7 @@ public class ModelsServiceImpl implements ModelsService { public Models update(Models models) { int currentState = models.getState(); if (currentState == 0) { - throw new RuntimeException("模型已被删除,无法更新。"); + throw new RuntimeException("模型已被删除,无法更新"); } LoginUser loginUser = SecurityUtils.getLoginUser(); models.setUpdateBy(loginUser.getUsername()); @@ -1161,7 +1161,7 @@ public class ModelsServiceImpl implements ModelsService { List assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(repoId), Constant.Asset_Type_Model, null); if (assetWorkflow != null && !assetWorkflow.isEmpty()) { String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); - throw new Exception("该模型被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); + throw new Exception("该模型被流水线:" + workflows + "使用,不能删除,请先删除流水线"); } HashMap queryMap = new HashMap<>(); @@ -1169,25 +1169,25 @@ public class ModelsServiceImpl implements ModelsService { List rayList = rayDao.queryByModelId(JSON.toJSONString(queryMap)); if (rayList != null && !rayList.isEmpty()) { String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); - throw new Exception("该模型被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); + throw new Exception("该模型被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优"); } List activeLearnList = activeLearnDao.queryByModelId(JSON.toJSONString(queryMap)); if (activeLearnList != null && !activeLearnList.isEmpty()) { String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); - throw new Exception("该模型被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习。"); + throw new Exception("该模型被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习"); } List devEnvironmentList = devEnvironmentDao.queryByModelId(JSON.toJSONString(queryMap)); if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) { String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet())); - throw new Exception("该模型被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境。"); + throw new Exception("该模型被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境"); } List serviceVersionList = serviceDao.queryByModelId(JSON.toJSONString(queryMap)); if (serviceVersionList != null && !serviceVersionList.isEmpty()) { String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet())); - throw new Exception("该模型被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本。"); + throw new Exception("该模型被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本"); } String token = gitService.checkoutToken(); @@ -1210,7 +1210,7 @@ public class ModelsServiceImpl implements ModelsService { List assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(repoId), Constant.Asset_Type_Model, version); if (assetWorkflow != null && !assetWorkflow.isEmpty()) { String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); - throw new Exception("该模型版本被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); + throw new Exception("该模型版本被流水线:" + workflows + "使用,不能删除,请先删除流水线"); } HashMap queryMap = new HashMap<>(); @@ -1219,25 +1219,25 @@ public class ModelsServiceImpl implements ModelsService { List rayList = rayDao.queryByModelId(JSON.toJSONString(queryMap)); if (rayList != null && !rayList.isEmpty()) { String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); - throw new Exception("该模型版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); + throw new Exception("该模型版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优"); } List activeLearnList = activeLearnDao.queryByModelId(JSON.toJSONString(queryMap)); if (activeLearnList != null && !activeLearnList.isEmpty()) { String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); - throw new Exception("该模型版本被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习。"); + throw new Exception("该模型版本被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习"); } List devEnvironmentList = devEnvironmentDao.queryByModelId(JSON.toJSONString(queryMap)); if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) { String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet())); - throw new Exception("该模型版本被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境。"); + throw new Exception("该模型版本被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境"); } List serviceVersionList = serviceDao.queryByModelId(JSON.toJSONString(queryMap)); if (serviceVersionList != null && !serviceVersionList.isEmpty()) { String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet())); - throw new Exception("该模型版本被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本。"); + throw new Exception("该模型版本被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本"); } String token = gitService.checkoutToken(); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsVersionServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsVersionServiceImpl.java index 274b3c1d..24a6b636 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsVersionServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsVersionServiceImpl.java @@ -99,7 +99,7 @@ public class ModelsVersionServiceImpl implements ModelsVersionService { public ModelsVersion update(ModelsVersion modelsVersion) { int currentState = modelsVersion.getState(); if(currentState == 0){ - throw new RuntimeException("模型版本已被删除,无法更新。"); + throw new RuntimeException("模型版本已被删除,无法更新"); } LoginUser loginUser = SecurityUtils.getLoginUser(); modelsVersion.setUpdateBy(loginUser.getUsername()); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java index 80b4a986..caeffbbb 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java @@ -415,7 +415,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { List assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(repoId), Constant.Asset_Type_Dataset, null); if (assetWorkflow != null && !assetWorkflow.isEmpty()) { String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); - throw new Exception("该数据集被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); + throw new Exception("该数据集被流水线:" + workflows + "使用,不能删除,请先删除流水线"); } HashMap map = new HashMap<>(); @@ -423,25 +423,25 @@ public class NewDatasetServiceImpl implements NewDatasetService { List autoMlList = autoMlDao.queryByDatasetId(JSON.toJSONString(map)); if (autoMlList != null && !autoMlList.isEmpty()) { String autoMls = String.join(",", autoMlList.stream().map(AutoMl::getMlName).collect(Collectors.toSet())); - throw new Exception("该数据集被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习。"); + throw new Exception("该数据集被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习"); } List rayList = rayDao.queryByDatasetId(JSON.toJSONString(map)); if (rayList != null && !rayList.isEmpty()) { String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); - throw new Exception("该数据集被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); + throw new Exception("该数据集被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优"); } List activeLearnList = activeLearnDao.queryByDatasetId(JSON.toJSONString(map)); if (activeLearnList != null && !activeLearnList.isEmpty()) { String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); - throw new Exception("该数据集被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习。"); + throw new Exception("该数据集被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习"); } List devEnvironmentList = devEnvironmentDao.queryByDatasetId(JSON.toJSONString(map)); if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) { String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet())); - throw new Exception("该数据集被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境。"); + throw new Exception("该数据集被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境"); } String token = gitService.checkoutToken(); @@ -457,7 +457,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { List assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(repoId), Constant.Asset_Type_Dataset, version); if (assetWorkflow != null && !assetWorkflow.isEmpty()) { String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); - throw new Exception("该数据集版本被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); + throw new Exception("该数据集版本被流水线:" + workflows + "使用,不能删除,请先删除流水线"); } HashMap map = new HashMap<>(); @@ -466,25 +466,25 @@ public class NewDatasetServiceImpl implements NewDatasetService { List autoMlList = autoMlDao.queryByDatasetId(JSON.toJSONString(map)); if (autoMlList != null && !autoMlList.isEmpty()) { String autoMls = String.join(",", autoMlList.stream().map(AutoMl::getMlName).collect(Collectors.toSet())); - throw new Exception("该数据集版本被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习。"); + throw new Exception("该数据集版本被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习"); } List rayList = rayDao.queryByDatasetId(JSON.toJSONString(map)); if (rayList != null && !rayList.isEmpty()) { String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); - throw new Exception("该数据集版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); + throw new Exception("该数据集版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优"); } List activeLearnList = activeLearnDao.queryByDatasetId(JSON.toJSONString(map)); if (activeLearnList != null && !activeLearnList.isEmpty()) { String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); - throw new Exception("该数据集版本被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习。"); + throw new Exception("该数据集版本被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习"); } List devEnvironmentList = devEnvironmentDao.queryByDatasetId(JSON.toJSONString(map)); if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) { String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet())); - throw new Exception("该数据集版本被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境。"); + throw new Exception("该数据集版本被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境"); } String token = gitService.checkoutToken(); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayInsServiceImpl.java index c29c0951..9e757c0c 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayInsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayInsServiceImpl.java @@ -139,7 +139,7 @@ public class RayInsServiceImpl implements RayInsService { String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res)); // 检查响应是否为空或无内容 if (StringUtils.isEmpty(req)) { - throw new RuntimeException("终止响应内容为空。"); + throw new RuntimeException("终止响应内容为空"); } // 将响应的JSON字符串转换为Map对象 @@ -227,19 +227,19 @@ public class RayInsServiceImpl implements RayInsService { String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res)); // 检查响应是否为空或无内容 if (req == null || StringUtils.isEmpty(req)) { - throw new RuntimeException("工作流状态响应为空。"); + throw new RuntimeException("工作流状态响应为空"); } // 将响应的JSON字符串转换为Map对象 Map runResMap = JsonUtils.jsonToMap(req); // 从响应Map中获取"data"部分 Map data = (Map) runResMap.get("data"); if (data == null || data.isEmpty()) { - throw new RuntimeException("工作流数据为空."); + throw new RuntimeException("工作流数据为空"); } // 从"data"中获取"status"部分,并返回"phase"的值 Map status = (Map) data.get("status"); if (status == null || status.isEmpty()) { - throw new RuntimeException("工作流状态为空。"); + throw new RuntimeException("工作流状态为空"); } //解析流水线结束时间 diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java index f2021a88..1a9c9770 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java @@ -63,15 +63,14 @@ public class RayServiceImpl implements RayService { @Override public Ray save(RayVo rayVo) throws Exception { + if (rayVo.getName().length() >= 64) { + throw new RuntimeException("实验名称大于最大长度"); + } Ray rayByName = rayDao.getRayByName(rayVo.getName()); if (rayByName != null) { throw new RuntimeException("实验名称已存在"); } - if (rayVo.getName().length() >= 64) { - throw new RuntimeException("实验名称大于最大长度"); - } - Ray ray = new Ray(); BeanUtils.copyProperties(rayVo, ray); String username = SecurityUtils.getLoginUser().getUsername(); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java index c48ed069..14b58f2b 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java @@ -229,7 +229,7 @@ public class ServiceServiceImpl implements ServiceService { List assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(id), Constant.Asset_Type_Service, null); if (assetWorkflow != null && !assetWorkflow.isEmpty()) { String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); - throw new Exception("该服务被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); + throw new Exception("该服务被流水线:" + workflows + "使用,不能删除,请先删除流水线"); } LoginUser loginUser = SecurityUtils.getLoginUser(); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/TextClassificationServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/TextClassificationServiceImpl.java new file mode 100644 index 00000000..e085bbea --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/TextClassificationServiceImpl.java @@ -0,0 +1,179 @@ +package com.ruoyi.platform.service.impl; + +import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.platform.domain.TextClassification; +import com.ruoyi.platform.domain.TextClassificationIns; +import com.ruoyi.platform.mapper.TextClassificationDao; +import com.ruoyi.platform.mapper.TextClassificationInsDao; +import com.ruoyi.platform.service.TextClassificationInsService; +import com.ruoyi.platform.service.TextClassificationService; +import com.ruoyi.platform.utils.HttpUtils; +import com.ruoyi.platform.utils.JacksonUtil; +import com.ruoyi.platform.utils.JsonUtils; +import com.ruoyi.platform.vo.TextClassificationParamVo; +import com.ruoyi.platform.vo.TextClassificationVo; +import com.ruoyi.system.api.constant.Constant; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Value; +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.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class TextClassificationServiceImpl implements TextClassificationService { + @Value("${git.localPath}") + String localPath; + @Value("${argo.url}") + private String argoUrl; + @Value("${argo.convertTextClassification}") + String convertTextClassification; + @Value("${argo.workflowRun}") + private String argoWorkflowRun; + @Value("${minio.endpointIp}") + private String minioEndpoint; + + @Resource + private TextClassificationDao textClassificationDao; + @Resource + private TextClassificationInsDao textClassificationInsDao; + @Resource + private TextClassificationInsService textClassificationInsService; + + @Override + public Page queryByPage(String name, PageRequest pageRequest) { + long total = textClassificationDao.count(name); + List textClassifications= textClassificationDao.queryByPage(name, pageRequest); + return new PageImpl<>(textClassifications, pageRequest, total); + } + + @Override + public TextClassification save(TextClassificationVo textClassificationVo) throws Exception { + if (textClassificationVo.getName().length() >= 64) { + throw new RuntimeException("实验名称大于最大长度"); + } + TextClassification textClassificationByName = textClassificationDao.getByName(textClassificationVo.getName()); + if (textClassificationByName != null) { + throw new RuntimeException("实验名称已存在"); + } + TextClassification textClassification = new TextClassification(); + BeanUtils.copyProperties(textClassificationVo, textClassification); + String username = SecurityUtils.getLoginUser().getUsername(); + textClassification.setCreateBy(username); + textClassification.setUpdateBy(username); + String datasetJson = JacksonUtil.toJSONString(textClassificationVo.getDataset()); + textClassification.setDataset(datasetJson); + textClassificationDao.save(textClassification); + return textClassification; + } + + @Override + public String edit(TextClassificationVo textClassificationVo) throws Exception { + TextClassification oldTextClassification = textClassificationDao.getByName(textClassificationVo.getName()); + if (oldTextClassification != null && !oldTextClassification.getId().equals(textClassificationVo.getId())) { + throw new RuntimeException("实验名称已存在"); + } + TextClassification textClassification = new TextClassification(); + BeanUtils.copyProperties(textClassificationVo, textClassification); + String username = SecurityUtils.getLoginUser().getUsername(); + textClassification.setUpdateBy(username); + String datasetJson = JacksonUtil.toJSONString(textClassificationVo.getDataset()); + textClassification.setDataset(datasetJson); + + textClassificationDao.edit(textClassification); + return "修改成功"; + } + + @Override + public String delete(Long id) { + TextClassification textClassification = textClassificationDao.getById(id); + if (textClassification == null) { + throw new RuntimeException("实验不存在"); + } + String username = SecurityUtils.getLoginUser().getUsername(); + String createBy = textClassification.getCreateBy(); + if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { + throw new RuntimeException("无权限删除该实验"); + } + textClassification.setState(Constant.State_invalid); + return textClassificationDao.edit(textClassification) > 0 ? "删除成功" : "删除失败"; + } + + @Override + public TextClassificationVo getTextClassificationDetail(Long id) throws IOException { + TextClassification textClassification = textClassificationDao.getById(id); + TextClassificationVo textClassificationVo = new TextClassificationVo(); + BeanUtils.copyProperties(textClassification, textClassificationVo); + if (StringUtils.isNotEmpty(textClassification.getDataset())) { + textClassificationVo.setDataset(JsonUtils.jsonToMap(textClassification.getDataset())); + } + return textClassificationVo; + } + + @Override + public String runTextClassificationIns(Long id) throws Exception { + TextClassification textClassification = textClassificationDao.getById(id); + if (textClassification == null) { + throw new Exception("文本分类配置不存在"); + } + TextClassificationParamVo paramVo = new TextClassificationParamVo(); + BeanUtils.copyProperties(textClassification, paramVo); + paramVo.setDataset(JsonUtils.jsonToMap(textClassification.getDataset())); + String param = JsonUtils.objectToJson(paramVo); + // 调argo转换接口 + try { + String convertRes = HttpUtils.sendPost(argoUrl + convertTextClassification, param); + if (convertRes == null || StringUtils.isEmpty(convertRes)) { + throw new RuntimeException("转换流水线失败"); + } + Map converMap = JsonUtils.jsonToMap(convertRes); + // 组装运行接口json + Map output = (Map) converMap.get("output"); + Map runReqMap = new HashMap<>(); + runReqMap.put("data", converMap.get("data")); + // 调argo运行接口 + String runRes = HttpUtils.sendPost(argoUrl + argoWorkflowRun, JsonUtils.mapToJson(runReqMap)); + + if (runRes == null || StringUtils.isEmpty(runRes)) { + throw new RuntimeException("运行流水线失败"); + } + Map runResMap = JsonUtils.jsonToMap(runRes); + Map data = (Map) runResMap.get("data"); + //判断data为空 + if (data == null || MapUtils.isEmpty(data)) { + throw new RuntimeException("运行流水线失败"); + } + Map metadata = (Map) data.get("metadata"); + // 插入记录到实验实例表 + TextClassificationIns textClassificationIns = new TextClassificationIns(); + textClassificationIns.setTextClassificationId(id); + textClassificationIns.setArgoInsNs((String) metadata.get("namespace")); + textClassificationIns.setArgoInsName((String) metadata.get("name")); + textClassificationIns.setParam(param); + textClassificationIns.setStatus(Constant.Pending); + //替换argoInsName + String outputString = JsonUtils.mapToJson(output); + textClassificationIns.setNodeResult(outputString.replace("{{workflow.name}}", (String) metadata.get("name"))); + + Map param_output = (Map) output.get("param_output"); + List output1 = (ArrayList) param_output.values().toArray()[0]; + Map output2 = (Map) output1.get(0); + String outputPath = minioEndpoint + "/" + output2.get("path").replace("{{workflow.name}}", (String) metadata.get("name")) + "/"; + textClassificationIns.setModelPath(outputPath + "/saved_dict/" + textClassification.getModel() + ".ckpt"); + textClassificationInsDao.insert(textClassificationIns); + textClassificationInsService.updateTextClassificationStatus(id); + } catch (Exception e) { + throw new RuntimeException(e); + } + return "执行成功"; + } +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java index 2535c1e0..fbeb54a5 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java @@ -201,7 +201,7 @@ public class WorkflowServiceImpl implements WorkflowService { // 从响应Map中获取"data"的值,也就是日志的值 String newDag = (String) runResMap.get("data"); if (newDag == null) { - throw new RuntimeException("响应内容为空。"); + throw new RuntimeException("响应内容为空"); } duplicateWorkflow.setDag(newDag); duplicateWorkflow.setDescription(workflow.getDescription()); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/TextClassificationParamVo.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/TextClassificationParamVo.java new file mode 100644 index 00000000..90252141 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/TextClassificationParamVo.java @@ -0,0 +1,31 @@ +package com.ruoyi.platform.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +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.Map; + +@Data +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +@JsonInclude(JsonInclude.Include.NON_NULL) +@ApiModel(description = "文本分类参数") +public class TextClassificationParamVo { + @ApiModelProperty(value = "模型") + private String model; + + @ApiModelProperty(value = "数据集") + private Map dataset; + + @ApiModelProperty(value = "epochs") + private Integer epochs; + + @ApiModelProperty(value = "batch_size") + private Integer batchSize; + + @ApiModelProperty(value = "学习率") + private Float lr; +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/TextClassificationVo.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/TextClassificationVo.java new file mode 100644 index 00000000..5b780955 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/TextClassificationVo.java @@ -0,0 +1,51 @@ +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 TextClassificationVo { + private Long id; + + @ApiModelProperty(value = "实验名称") + private String name; + + @ApiModelProperty(value = "实验描述") + private String description; + + @ApiModelProperty(value = "模型") + private String model; + + @ApiModelProperty(value = "数据集") + private Map dataset; + + @ApiModelProperty(value = "epochs") + private Integer epochs; + + @ApiModelProperty(value = "batch_size") + private Integer batchSize; + + @ApiModelProperty(value = "学习率") + private Float lr; + + private String createBy; + + private String updateBy; + + private Date createTime; + + private Date updateTime; + + private Integer state; + + @ApiModelProperty(value = "状态列表") + private String statusList; +} diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml index 8bf8250f..79cf3e35 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml @@ -1,7 +1,7 @@ - + insert into auto_ml(ml_name, ml_description, task_type, dataset, time_left_for_this_task, per_run_time_limit, ensemble_size, ensemble_class, ensemble_nbest, max_models_on_disc, seed, memory_limit, @@ -37,9 +37,6 @@ status_list = #{autoMl.statusList}, - - - task_type = #{autoMl.taskType}, diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/TextClassificationDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/TextClassificationDaoMapper.xml new file mode 100644 index 00000000..b600dec9 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/TextClassificationDaoMapper.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + insert into text_classification(name, description, model, dataset, epochs, batch_size, lr, create_by, update_by) + values (#{textClassification.name}, #{textClassification.description}, #{textClassification.model}, + #{textClassification.dataset}, #{textClassification.epochs}, #{textClassification.batchSize}, + #{textClassification.lr}, #{textClassification.createBy}, #{textClassification.updateBy},) + + + + update text_classification + + + name = #{textClassification.name}, + + + description = #{textClassification.description}, + + + model = #{textClassification.model}, + + + dataset = #{textClassification.dataset}, + + + epochs = #{textClassification.epochs}, + + + batch_size = #{textClassification.batchSize}, + + + lr = #{textClassification.lr}, + + + update_by = #{textClassification.updateBy}, + + + status_list = #{textClassification.statusList}, + + + state = #{textClassification.state}, + + + where id = #{textClassification.id} + + + + + + + state = 1 + + and name like concat('%', #{name}, '%') + + + + \ No newline at end of file diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/TextClassificationInsDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/TextClassificationInsDaoMapper.xml new file mode 100644 index 00000000..fd481dae --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/TextClassificationInsDaoMapper.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + insert into text_classification_ins(text_classification_id, status, param, argo_ins_name, argo_ins_ns, + node_status, node_result) + values (#{textClassificationIns.textClassificationId}, #{textClassificationIns.status}, + #{textClassificationIns.param}, #{textClassificationIns.argoInsName}, + #{textClassificationIns.argoInsNs}, #{textClassificationIns.nodeStatus}, + #{textClassificationIns.nodeResult}) + + + + update text_classification_ins + + + model_path = #{autoMlIns.modelPath}, + + + result_path = #{autoMlIns.resultPath}, + + + status = #{autoMlIns.status}, + + + node_status = #{autoMlIns.nodeStatus}, + + + node_result = #{autoMlIns.nodeResult}, + + + state = #{autoMlIns.state}, + + + update_time = #{autoMlIns.updateTime}, + + + finish_time = #{autoMlIns.finishTime}, + + + where id = #{textClassificationIns.id} + + + + \ No newline at end of file