Browse Source

文本分类功能开发,优化

pull/225/head
chenzhihang 9 months ago
parent
commit
ab9c953ee4
34 changed files with 816 additions and 84 deletions
  1. +62
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/textClassfication/TextClassificationController.java
  2. +59
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/textClassfication/TextClassificationInsController.java
  3. +50
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/TextClassification.java
  4. +41
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/TextClassificationIns.java
  5. +23
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/TextClassificationDao.java
  6. +23
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/TextClassificationInsDao.java
  7. +26
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/TextClassificationInsService.java
  8. +21
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/TextClassificationService.java
  9. +4
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java
  10. +3
    -3
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java
  11. +6
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlInsServiceImpl.java
  12. +5
    -7
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java
  13. +4
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java
  14. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java
  15. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java
  16. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java
  17. +5
    -5
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java
  18. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java
  19. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/GitServiceImpl.java
  20. +6
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java
  21. +6
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageVersionServiceImpl.java
  22. +11
    -11
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java
  23. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsVersionServiceImpl.java
  24. +10
    -10
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java
  25. +4
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayInsServiceImpl.java
  26. +3
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java
  27. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java
  28. +179
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/TextClassificationServiceImpl.java
  29. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java
  30. +31
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/TextClassificationParamVo.java
  31. +51
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/TextClassificationVo.java
  32. +1
    -4
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml
  33. +87
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/TextClassificationDaoMapper.xml
  34. +85
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/TextClassificationInsDaoMapper.xml

+ 62
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/textClassfication/TextClassificationController.java View File

@@ -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<Page<TextClassification>> 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<TextClassification> add(@RequestBody TextClassificationVo textClassificationVo) throws Exception {
return genericsSuccess(this.textClassificationService.save(textClassificationVo));
}

@PutMapping
@ApiOperation("编辑文本分类")
public GenericsAjaxResult<String> edit(@RequestBody TextClassificationVo textClassificationVo) throws Exception {
return genericsSuccess(this.textClassificationService.edit(textClassificationVo));
}

@GetMapping("/getTextClassificationDetail")
@ApiOperation("获取文本分类详细信息")
public GenericsAjaxResult<TextClassificationVo> getTextClassificationDetail(@RequestParam("id") Long id)throws IOException {
return genericsSuccess(this.textClassificationService.getTextClassificationDetail(id));
}

@DeleteMapping("{id}")
@ApiOperation("删除文本分类")
public GenericsAjaxResult<String> deleteTextClassification(@PathVariable("id") Long id){
return genericsSuccess(this.textClassificationService.delete(id));
}

@PostMapping("/run/{id}")
@ApiOperation("运行文本分类")
public GenericsAjaxResult<String> runTextClassification(@PathVariable("id") Long id) throws Exception {
return genericsSuccess(this.textClassificationService.runTextClassificationIns(id));
}
}

+ 59
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/textClassfication/TextClassificationInsController.java View File

@@ -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<Page<TextClassificationIns>> queryByPage(TextClassificationIns textClassificationIns, int page, int size){
PageRequest pageRequest = PageRequest.of(page, size);
return genericsSuccess(this.textClassificationInsService.queryByPage(textClassificationIns, pageRequest));
}

@PostMapping
@ApiOperation("新增实验实例")
public GenericsAjaxResult<TextClassificationIns> add(@RequestBody TextClassificationIns textClassificationIns) {
return genericsSuccess(this.textClassificationInsService.insert(textClassificationIns));
}

@DeleteMapping("{id}")
@ApiOperation("删除实验实例")
public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) {
return genericsSuccess(this.textClassificationInsService.removeById(id));
}

@DeleteMapping("batchDelete")
@ApiOperation("批量删除实验实例")
public GenericsAjaxResult<String> batchDelete(@RequestBody List<Long> ids) {
return genericsSuccess(this.textClassificationInsService.batchDelete(ids));
}

@PutMapping("{id}")
@ApiOperation("终止实验实例")
public GenericsAjaxResult<Boolean> terminateTextClassificationIns(@PathVariable("id") Long id) throws Exception {
return genericsSuccess(this.textClassificationInsService.terminateTextClassificationIns(id));
}

@GetMapping("{id}")
@ApiOperation("查看实验实例详情")
public GenericsAjaxResult<TextClassificationIns> getDetailById(@PathVariable("id") Long id) {
return genericsSuccess(this.textClassificationInsService.getDetailById(id));
}
}

+ 50
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/TextClassification.java View File

@@ -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;
}

+ 41
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/TextClassificationIns.java View File

@@ -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;
}

+ 23
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/TextClassificationDao.java View File

@@ -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<TextClassification> 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<TextClassification> queryByDatasetId(@Param("datasetId") String datasetId);
}

+ 23
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/TextClassificationInsDao.java View File

@@ -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<TextClassificationIns> queryAllByLimit(@Param("textClassificationIns") TextClassificationIns textClassificationIns, @Param("pageable") Pageable pageable);

List<TextClassificationIns> getByTextClassificationId(@Param("textClassificationId") Long textClassificationId);

TextClassificationIns queryById(@Param("id") Long id);

int insert(@Param("textClassificationIns") TextClassificationIns textClassificationIns);

int update(@Param("textClassificationIns") TextClassificationIns textClassificationIns);

List<TextClassificationIns> queryByNotTerminated();
}

+ 26
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/TextClassificationInsService.java View File

@@ -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<TextClassificationIns> queryByPage(TextClassificationIns textClassificationIns, PageRequest pageRequest);

TextClassificationIns insert(TextClassificationIns textClassificationIns);

String removeById(Long id);

String batchDelete(List<Long> ids);

boolean terminateTextClassificationIns(Long id) throws Exception;

TextClassificationIns getDetailById(Long id);

List<TextClassificationIns> queryByNotTerminated();

TextClassificationIns queryStatusFromArgo(TextClassificationIns textClassificationIns);

void updateTextClassificationStatus(Long textClassificationId);
}

+ 21
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/TextClassificationService.java View File

@@ -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<TextClassification> 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;
}

+ 4
- 4
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java View File

@@ -126,7 +126,7 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService {
String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res)); String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res));
// 检查响应是否为空或无内容 // 检查响应是否为空或无内容
if (StringUtils.isEmpty(req)) { if (StringUtils.isEmpty(req)) {
throw new RuntimeException("终止响应内容为空");
throw new RuntimeException("终止响应内容为空");


} }
// 将响应的JSON字符串转换为Map对象 // 将响应的JSON字符串转换为Map对象
@@ -214,19 +214,19 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService {
String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res)); String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res));
// 检查响应是否为空或无内容 // 检查响应是否为空或无内容
if (req == null || StringUtils.isEmpty(req)) { if (req == null || StringUtils.isEmpty(req)) {
throw new RuntimeException("工作流状态响应为空");
throw new RuntimeException("工作流状态响应为空");
} }
// 将响应的JSON字符串转换为Map对象 // 将响应的JSON字符串转换为Map对象
Map<String, Object> runResMap = JsonUtils.jsonToMap(req); Map<String, Object> runResMap = JsonUtils.jsonToMap(req);
// 从响应Map中获取"data"部分 // 从响应Map中获取"data"部分
Map<String, Object> data = (Map<String, Object>) runResMap.get("data"); Map<String, Object> data = (Map<String, Object>) runResMap.get("data");
if (data == null || data.isEmpty()) { if (data == null || data.isEmpty()) {
throw new RuntimeException("工作流数据为空.");
throw new RuntimeException("工作流数据为空");
} }
// 从"data"中获取"status"部分,并返回"phase"的值 // 从"data"中获取"status"部分,并返回"phase"的值
Map<String, Object> status = (Map<String, Object>) data.get("status"); Map<String, Object> status = (Map<String, Object>) data.get("status");
if (status == null || status.isEmpty()) { if (status == null || status.isEmpty()) {
throw new RuntimeException("工作流状态为空");
throw new RuntimeException("工作流状态为空");
} }


//解析流水线结束时间 //解析流水线结束时间


+ 3
- 3
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java View File

@@ -60,13 +60,13 @@ public class ActiveLearnServiceImpl implements ActiveLearnService {


@Override @Override
public ActiveLearn save(ActiveLearnVo activeLearnVo) throws Exception { public ActiveLearn save(ActiveLearnVo activeLearnVo) throws Exception {
if (activeLearnVo.getName().length() >= 64) {
throw new RuntimeException("实验名称大于最大长度");
}
ActiveLearn activeLearnByName = activeLearnDao.getActiveLearnByName(activeLearnVo.getName()); ActiveLearn activeLearnByName = activeLearnDao.getActiveLearnByName(activeLearnVo.getName());
if (activeLearnByName != null) { if (activeLearnByName != null) {
throw new RuntimeException("实验名称已存在"); throw new RuntimeException("实验名称已存在");
} }
if (activeLearnVo.getName().length() >= 64) {
throw new RuntimeException("实验名称大于最大长度");
}


ActiveLearn activeLearn = new ActiveLearn(); ActiveLearn activeLearn = new ActiveLearn();
BeanUtils.copyProperties(activeLearnVo, activeLearn); BeanUtils.copyProperties(activeLearnVo, activeLearn);


+ 6
- 6
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlInsServiceImpl.java View File

@@ -108,19 +108,19 @@ public class AutoMlInsServiceImpl implements AutoMlInsService {
String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res)); String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res));
// 检查响应是否为空或无内容 // 检查响应是否为空或无内容
if (req == null || StringUtils.isEmpty(req)) { if (req == null || StringUtils.isEmpty(req)) {
throw new RuntimeException("工作流状态响应为空");
throw new RuntimeException("工作流状态响应为空");
} }
// 将响应的JSON字符串转换为Map对象 // 将响应的JSON字符串转换为Map对象
Map<String, Object> runResMap = JsonUtils.jsonToMap(req); Map<String, Object> runResMap = JsonUtils.jsonToMap(req);
// 从响应Map中获取"data"部分 // 从响应Map中获取"data"部分
Map<String, Object> data = (Map<String, Object>) runResMap.get("data"); Map<String, Object> data = (Map<String, Object>) runResMap.get("data");
if (data == null || data.isEmpty()) { if (data == null || data.isEmpty()) {
throw new RuntimeException("工作流数据为空.");
throw new RuntimeException("工作流数据为空");
} }
// 从"data"中获取"status"部分,并返回"phase"的值 // 从"data"中获取"status"部分,并返回"phase"的值
Map<String, Object> status = (Map<String, Object>) data.get("status"); Map<String, Object> status = (Map<String, Object>) data.get("status");
if (status == null || status.isEmpty()) { 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)); String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res));
// 检查响应是否为空或无内容 // 检查响应是否为空或无内容
if (StringUtils.isEmpty(req)) { if (StringUtils.isEmpty(req)) {
throw new RuntimeException("终止响应内容为空");
throw new RuntimeException("终止响应内容为空");


} }
// 将响应的JSON字符串转换为Map对象 // 将响应的JSON字符串转换为Map对象
@@ -211,8 +211,8 @@ public class AutoMlInsServiceImpl implements AutoMlInsService {
if (innerMap.containsKey("phase")) { if (innerMap.containsKey("phase")) {
String phaseValue = (String) innerMap.get("phase"); String phaseValue = (String) innerMap.get("phase");
// 如果值不等于 Succeeded,则赋值为 Failed // 如果值不等于 Succeeded,则赋值为 Failed
if (!StringUtils.equals("Succeeded", phaseValue)) {
innerMap.put("phase", "Failed");
if (!StringUtils.equals(Constant.Succeeded, phaseValue)) {
innerMap.put("phase", Constant.Failed);
} }
} }
} }


+ 5
- 7
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java View File

@@ -66,15 +66,13 @@ public class AutoMlServiceImpl implements AutoMlService {


@Override @Override
public AutoMl save(AutoMlVo autoMlVo) throws Exception { public AutoMl save(AutoMlVo autoMlVo) throws Exception {
if (autoMlVo.getMlName().length() >= 64) {
throw new RuntimeException("实验名称大于最大长度");
}
AutoMl autoMlByName = autoMlDao.getAutoMlByName(autoMlVo.getMlName()); AutoMl autoMlByName = autoMlDao.getAutoMlByName(autoMlVo.getMlName());
if (autoMlByName != null) { if (autoMlByName != null) {
throw new RuntimeException("实验名称已存在"); throw new RuntimeException("实验名称已存在");
} }

if (autoMlVo.getMlName().length() >= 64) {
throw new RuntimeException("实验名称大于最大长度");
}

AutoMl autoMl = new AutoMl(); AutoMl autoMl = new AutoMl();
BeanUtils.copyProperties(autoMlVo, autoMl); BeanUtils.copyProperties(autoMlVo, autoMl);
String username = SecurityUtils.getLoginUser().getUsername(); String username = SecurityUtils.getLoginUser().getUsername();
@@ -178,13 +176,13 @@ public class AutoMlServiceImpl implements AutoMlService {
String runRes = HttpUtils.sendPost(argoUrl + argoWorkflowRun, JsonUtils.mapToJson(runReqMap)); String runRes = HttpUtils.sendPost(argoUrl + argoWorkflowRun, JsonUtils.mapToJson(runReqMap));


if (runRes == null || StringUtils.isEmpty(runRes)) { if (runRes == null || StringUtils.isEmpty(runRes)) {
throw new RuntimeException("Failed to run workflow.");
throw new RuntimeException("运行流水线失败");
} }
Map<String, Object> runResMap = JsonUtils.jsonToMap(runRes); Map<String, Object> runResMap = JsonUtils.jsonToMap(runRes);
Map<String, Object> data = (Map<String, Object>) runResMap.get("data"); Map<String, Object> data = (Map<String, Object>) runResMap.get("data");
//判断data为空 //判断data为空
if (data == null || MapUtils.isEmpty(data)) { if (data == null || MapUtils.isEmpty(data)) {
throw new RuntimeException("Failed to run workflow.");
throw new RuntimeException("运行流水线失败");
} }
Map<String, Object> metadata = (Map<String, Object>) data.get("metadata"); Map<String, Object> metadata = (Map<String, Object>) data.get("metadata");
// 插入记录到实验实例表 // 插入记录到实验实例表


+ 4
- 4
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java View File

@@ -94,7 +94,7 @@ public class CodeConfigServiceImpl implements CodeConfigService {
List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(id, Constant.Asset_Type_Code, null); List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(id, Constant.Asset_Type_Code, null);
if (assetWorkflow != null && !assetWorkflow.isEmpty()) { if (assetWorkflow != null && !assetWorkflow.isEmpty()) {
String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet()));
throw new Exception("该代码配置被流水线:" + workflows + "使用,不能删除,请先删除流水线");
throw new Exception("该代码配置被流水线:" + workflows + "使用,不能删除,请先删除流水线");
} }


HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
@@ -102,19 +102,19 @@ public class CodeConfigServiceImpl implements CodeConfigService {
List<Ray> rayList = rayDao.queryByCodeConfig(JSON.toJSONString(map)); List<Ray> rayList = rayDao.queryByCodeConfig(JSON.toJSONString(map));
if (rayList != null && !rayList.isEmpty()) { if (rayList != null && !rayList.isEmpty()) {
String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet()));
throw new Exception("该代码配置被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
throw new Exception("该代码配置被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
} }


List<ActiveLearn> activeLearnList = activeLearnDao.queryByCodeConfig(JSON.toJSONString(map)); List<ActiveLearn> activeLearnList = activeLearnDao.queryByCodeConfig(JSON.toJSONString(map));
if (activeLearnList != null && !activeLearnList.isEmpty()) { if (activeLearnList != null && !activeLearnList.isEmpty()) {
String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet()));
throw new Exception("该代码配置被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
throw new Exception("该代码配置被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
} }


List<String> serviceVersionList = serviceDao.queryByCodeConfig(JSON.toJSONString(map)); List<String> serviceVersionList = serviceDao.queryByCodeConfig(JSON.toJSONString(map));
if (serviceVersionList != null && !serviceVersionList.isEmpty()) { if (serviceVersionList != null && !serviceVersionList.isEmpty()) {
String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet())); String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet()));
throw new Exception("该代码配置被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本");
throw new Exception("该代码配置被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本");
} }


LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();


+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java View File

@@ -121,7 +121,7 @@ public class ComponentServiceImpl implements ComponentService {
Integer existingCount = this.componentDao.countByNameAndCategoryId(component.getComponentName(),component.getCategoryId()); Integer existingCount = this.componentDao.countByNameAndCategoryId(component.getComponentName(),component.getCategoryId());


if(existingCount != null && existingCount > 0) { if(existingCount != null && existingCount > 0) {
throw new RuntimeException("该类别下已有同名组件");
throw new RuntimeException("该类别下已有同名组件");
} }


this.componentDao.insert(component); this.componentDao.insert(component);
@@ -140,7 +140,7 @@ public class ComponentServiceImpl implements ComponentService {
//只能更新当前存在的组件 //只能更新当前存在的组件


if (component == null){ if (component == null){
throw new RuntimeException("组件不存在,无法更新");
throw new RuntimeException("组件不存在,无法更新");
} }


//将object转成string类型 //将object转成string类型


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java View File

@@ -147,7 +147,7 @@ public class DatasetServiceImpl implements DatasetService {
public Dataset update(Dataset dataset) { public Dataset update(Dataset dataset) {
int currentState = dataset.getState(); int currentState = dataset.getState();
if (currentState == 0) { if (currentState == 0) {
throw new RuntimeException("数据集已被删除,无法更新");
throw new RuntimeException("数据集已被删除,无法更新");
} }
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
dataset.setUpdateBy(loginUser.getUsername()); dataset.setUpdateBy(loginUser.getUsername());


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java View File

@@ -101,7 +101,7 @@ public class DatasetVersionServiceImpl implements DatasetVersionService {
public DatasetVersion update(DatasetVersion datasetVersion) { public DatasetVersion update(DatasetVersion datasetVersion) {
int currentState = datasetVersion.getState(); int currentState = datasetVersion.getState();
if (currentState == 0){ if (currentState == 0){
throw new RuntimeException("数据集版本已被删除,无法更新");
throw new RuntimeException("数据集版本已被删除,无法更新");
} }
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
datasetVersion.setUpdateBy(loginUser.getUsername()); datasetVersion.setUpdateBy(loginUser.getUsername());


+ 5
- 5
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java View File

@@ -285,7 +285,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res)); String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res));
// 检查响应是否为空或无内容 // 检查响应是否为空或无内容
if (req == null || StringUtils.isEmpty(req)) { if (req == null || StringUtils.isEmpty(req)) {
throw new RuntimeException("工作流状态响应为空");
throw new RuntimeException("工作流状态响应为空");
} }


// 将响应的JSON字符串转换为Map对象 // 将响应的JSON字符串转换为Map对象
@@ -293,12 +293,12 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
// 从响应Map中获取"data"部分 // 从响应Map中获取"data"部分
Map<String, Object> data = (Map<String, Object>) runResMap.get("data"); Map<String, Object> data = (Map<String, Object>) runResMap.get("data");
if (data == null || data.isEmpty()) { if (data == null || data.isEmpty()) {
throw new RuntimeException("工作流数据为空.");
throw new RuntimeException("工作流数据为空");
} }
// 从"data"中获取"status"部分,并返回"phase"的值 // 从"data"中获取"status"部分,并返回"phase"的值
Map<String, Object> status = (Map<String, Object>) data.get("status"); Map<String, Object> status = (Map<String, Object>) data.get("status");
if (status == null || status.isEmpty()) { 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)); String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res));
// 检查响应是否为空或无内容 // 检查响应是否为空或无内容
if (StringUtils.isEmpty(req)) { if (StringUtils.isEmpty(req)) {
throw new RuntimeException("终止响应内容为空");
throw new RuntimeException("终止响应内容为空");


} }
// 将响应的JSON字符串转换为Map对象 // 将响应的JSON字符串转换为Map对象
@@ -509,7 +509,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
// 从响应Map中获取"data"的值,也就是日志的值 // 从响应Map中获取"data"的值,也就是日志的值
String experimentInsLog = (String) runResMap.get("data"); String experimentInsLog = (String) runResMap.get("data");
if (experimentInsLog == null) { if (experimentInsLog == null) {
throw new RuntimeException("日志为空");
throw new RuntimeException("日志为空");
} }
//返回日志内容 //返回日志内容
return experimentInsLog; return experimentInsLog;


+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java View File

@@ -264,13 +264,13 @@ public class ExperimentServiceImpl implements ExperimentService {
String runRes = HttpUtils.sendPost(argoUrl + argoWorkflowRun, JsonUtils.mapToJson(runReqMap)); String runRes = HttpUtils.sendPost(argoUrl + argoWorkflowRun, JsonUtils.mapToJson(runReqMap));


if (runRes == null || StringUtils.isEmpty(runRes)) { if (runRes == null || StringUtils.isEmpty(runRes)) {
throw new RuntimeException("Failed to run workflow.");
throw new RuntimeException("运行流水线失败");
} }
Map<String, Object> runResMap = JsonUtils.jsonToMap(runRes); Map<String, Object> runResMap = JsonUtils.jsonToMap(runRes);
Map<String, Object> data = (Map<String, Object>) runResMap.get("data"); Map<String, Object> data = (Map<String, Object>) runResMap.get("data");
//判断data为空 //判断data为空
if (data == null || MapUtils.isEmpty(data)) { if (data == null || MapUtils.isEmpty(data)) {
throw new RuntimeException("Failed to run workflow.");
throw new RuntimeException("运行流水线失败");
} }






+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/GitServiceImpl.java View File

@@ -140,7 +140,7 @@ public class GitServiceImpl implements GitService {
String req = httpUtils.sendGetWithToken(gitendpoint + "/api/v1/" + owner + "/" + projectName + "/branches/all.json", null, token); String req = httpUtils.sendGetWithToken(gitendpoint + "/api/v1/" + owner + "/" + projectName + "/branches/all.json", null, token);
// 解析响应JSON // 解析响应JSON
if (StringUtils.isEmpty(req)) { if (StringUtils.isEmpty(req)) {
throw new RuntimeException("终止响应内容为空");
throw new RuntimeException("终止响应内容为空");
} }
// 将响应的JSON字符串转换为List<Map>对象 // 将响应的JSON字符串转换为List<Map>对象
List<Map<String, Object>> mapList = JacksonUtil.parseJSONStr2MapList(req); List<Map<String, Object>> mapList = JacksonUtil.parseJSONStr2MapList(req);


+ 6
- 6
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java View File

@@ -144,7 +144,7 @@ public class ImageServiceImpl implements ImageService {
public Image update(Image image) { public Image update(Image image) {
int currentState = image.getState(); int currentState = image.getState();
if (currentState == 0) { if (currentState == 0) {
throw new RuntimeException("镜像已被删除,无法更新");
throw new RuntimeException("镜像已被删除,无法更新");
} }
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
image.setUpdateBy(loginUser.getUsername()); image.setUpdateBy(loginUser.getUsername());
@@ -175,7 +175,7 @@ public class ImageServiceImpl implements ImageService {
List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(id), Constant.Asset_Type_Image, null); List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(id), Constant.Asset_Type_Image, null);
if (assetWorkflow != null && !assetWorkflow.isEmpty()) { if (assetWorkflow != null && !assetWorkflow.isEmpty()) {
String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet()));
throw new Exception("该镜像被流水线:" + workflows + "使用,不能删除,请先删除流水线");
throw new Exception("该镜像被流水线:" + workflows + "使用,不能删除,请先删除流水线");
} }


HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
@@ -183,25 +183,25 @@ public class ImageServiceImpl implements ImageService {
List<Ray> rayList = rayDao.queryByImageId(JSON.toJSONString(map)); List<Ray> rayList = rayDao.queryByImageId(JSON.toJSONString(map));
if (rayList != null && !rayList.isEmpty()) { if (rayList != null && !rayList.isEmpty()) {
String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet()));
throw new Exception("该镜像被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
throw new Exception("该镜像被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
} }


List<ActiveLearn> activeLearnList = activeLearnDao.queryByImageId(JSON.toJSONString(map)); List<ActiveLearn> activeLearnList = activeLearnDao.queryByImageId(JSON.toJSONString(map));
if (activeLearnList != null && !activeLearnList.isEmpty()) { if (activeLearnList != null && !activeLearnList.isEmpty()) {
String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet()));
throw new Exception("该镜像被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
throw new Exception("该镜像被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
} }


List<DevEnvironment> devEnvironmentList = devEnvironmentDao.queryByImageId(JSON.toJSONString(map)); List<DevEnvironment> devEnvironmentList = devEnvironmentDao.queryByImageId(JSON.toJSONString(map));
if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) { if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) {
String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet())); String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet()));
throw new Exception("该镜像被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境");
throw new Exception("该镜像被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境");
} }


List<String> serviceVersionList = serviceDao.queryByImageId(JSON.toJSONString(map)); List<String> serviceVersionList = serviceDao.queryByImageId(JSON.toJSONString(map));
if (serviceVersionList != null && !serviceVersionList.isEmpty()) { if (serviceVersionList != null && !serviceVersionList.isEmpty()) {
String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet())); String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet()));
throw new Exception("该镜像被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本");
throw new Exception("该镜像被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本");
} }


//判断权限,只有admin和创建者本身可以删除该数据集 //判断权限,只有admin和创建者本身可以删除该数据集


+ 6
- 6
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageVersionServiceImpl.java View File

@@ -86,7 +86,7 @@ public class ImageVersionServiceImpl implements ImageVersionService {
List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(imageVersion.getImageId()), Constant.Asset_Type_Image, imageVersion.getTagName()); List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(imageVersion.getImageId()), Constant.Asset_Type_Image, imageVersion.getTagName());
if (assetWorkflow != null && !assetWorkflow.isEmpty()) { if (assetWorkflow != null && !assetWorkflow.isEmpty()) {
String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet()));
return GenericsAjaxResult.error("该镜像版本被流水线:" + workflows + "使用,不能删除,请先删除流水线");
return GenericsAjaxResult.error("该镜像版本被流水线:" + workflows + "使用,不能删除,请先删除流水线");
} }


HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
@@ -94,25 +94,25 @@ public class ImageVersionServiceImpl implements ImageVersionService {
List<Ray> rayList = rayDao.queryByImageId(JSON.toJSONString(map)); List<Ray> rayList = rayDao.queryByImageId(JSON.toJSONString(map));
if (rayList != null && !rayList.isEmpty()) { if (rayList != null && !rayList.isEmpty()) {
String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet()));
return GenericsAjaxResult.error("该镜像版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
return GenericsAjaxResult.error("该镜像版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
} }


List<ActiveLearn> activeLearnList = activeLearnDao.queryByImageId(JSON.toJSONString(map)); List<ActiveLearn> activeLearnList = activeLearnDao.queryByImageId(JSON.toJSONString(map));
if (activeLearnList != null && !activeLearnList.isEmpty()) { if (activeLearnList != null && !activeLearnList.isEmpty()) {
String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet()));
return GenericsAjaxResult.error("该镜像版本被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
return GenericsAjaxResult.error("该镜像版本被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
} }


List<DevEnvironment> devEnvironmentList = devEnvironmentDao.queryByImageId(JSON.toJSONString(map)); List<DevEnvironment> devEnvironmentList = devEnvironmentDao.queryByImageId(JSON.toJSONString(map));
if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) { if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) {
String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet())); String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet()));
throw new Exception("该镜像版本被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境");
throw new Exception("该镜像版本被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境");
} }


List<String> serviceVersionList = serviceDao.queryByImageId(JSON.toJSONString(map)); List<String> serviceVersionList = serviceDao.queryByImageId(JSON.toJSONString(map));
if (serviceVersionList != null && !serviceVersionList.isEmpty()) { if (serviceVersionList != null && !serviceVersionList.isEmpty()) {
String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet())); String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet()));
throw new Exception("该镜像版本被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本");
throw new Exception("该镜像版本被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本");
} }


//判断权限,只有admin和创建者本身可以删除该数据集 //判断权限,只有admin和创建者本身可以删除该数据集
@@ -156,7 +156,7 @@ public class ImageVersionServiceImpl implements ImageVersionService {
public ImageVersion update(ImageVersion imageVersion) { public ImageVersion update(ImageVersion imageVersion) {
int currentState = imageVersion.getState(); int currentState = imageVersion.getState();
if (currentState == 0) { if (currentState == 0) {
throw new RuntimeException("镜像版本已被删除,无法更新");
throw new RuntimeException("镜像版本已被删除,无法更新");
} }
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
imageVersion.setUpdateBy(loginUser.getUsername()); imageVersion.setUpdateBy(loginUser.getUsername());


+ 11
- 11
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java View File

@@ -190,7 +190,7 @@ public class ModelsServiceImpl implements ModelsService {
public Models update(Models models) { public Models update(Models models) {
int currentState = models.getState(); int currentState = models.getState();
if (currentState == 0) { if (currentState == 0) {
throw new RuntimeException("模型已被删除,无法更新");
throw new RuntimeException("模型已被删除,无法更新");
} }
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
models.setUpdateBy(loginUser.getUsername()); models.setUpdateBy(loginUser.getUsername());
@@ -1161,7 +1161,7 @@ public class ModelsServiceImpl implements ModelsService {
List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(repoId), Constant.Asset_Type_Model, null); List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(repoId), Constant.Asset_Type_Model, null);
if (assetWorkflow != null && !assetWorkflow.isEmpty()) { if (assetWorkflow != null && !assetWorkflow.isEmpty()) {
String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet()));
throw new Exception("该模型被流水线:" + workflows + "使用,不能删除,请先删除流水线");
throw new Exception("该模型被流水线:" + workflows + "使用,不能删除,请先删除流水线");
} }


HashMap<String, String> queryMap = new HashMap<>(); HashMap<String, String> queryMap = new HashMap<>();
@@ -1169,25 +1169,25 @@ public class ModelsServiceImpl implements ModelsService {
List<Ray> rayList = rayDao.queryByModelId(JSON.toJSONString(queryMap)); List<Ray> rayList = rayDao.queryByModelId(JSON.toJSONString(queryMap));
if (rayList != null && !rayList.isEmpty()) { if (rayList != null && !rayList.isEmpty()) {
String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet()));
throw new Exception("该模型被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
throw new Exception("该模型被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
} }


List<ActiveLearn> activeLearnList = activeLearnDao.queryByModelId(JSON.toJSONString(queryMap)); List<ActiveLearn> activeLearnList = activeLearnDao.queryByModelId(JSON.toJSONString(queryMap));
if (activeLearnList != null && !activeLearnList.isEmpty()) { if (activeLearnList != null && !activeLearnList.isEmpty()) {
String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet()));
throw new Exception("该模型被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
throw new Exception("该模型被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
} }


List<DevEnvironment> devEnvironmentList = devEnvironmentDao.queryByModelId(JSON.toJSONString(queryMap)); List<DevEnvironment> devEnvironmentList = devEnvironmentDao.queryByModelId(JSON.toJSONString(queryMap));
if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) { if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) {
String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet())); String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet()));
throw new Exception("该模型被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境");
throw new Exception("该模型被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境");
} }


List<String> serviceVersionList = serviceDao.queryByModelId(JSON.toJSONString(queryMap)); List<String> serviceVersionList = serviceDao.queryByModelId(JSON.toJSONString(queryMap));
if (serviceVersionList != null && !serviceVersionList.isEmpty()) { if (serviceVersionList != null && !serviceVersionList.isEmpty()) {
String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet())); String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet()));
throw new Exception("该模型被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本");
throw new Exception("该模型被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本");
} }


String token = gitService.checkoutToken(); String token = gitService.checkoutToken();
@@ -1210,7 +1210,7 @@ public class ModelsServiceImpl implements ModelsService {
List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(repoId), Constant.Asset_Type_Model, version); List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(repoId), Constant.Asset_Type_Model, version);
if (assetWorkflow != null && !assetWorkflow.isEmpty()) { if (assetWorkflow != null && !assetWorkflow.isEmpty()) {
String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet()));
throw new Exception("该模型版本被流水线:" + workflows + "使用,不能删除,请先删除流水线");
throw new Exception("该模型版本被流水线:" + workflows + "使用,不能删除,请先删除流水线");
} }


HashMap<String, String> queryMap = new HashMap<>(); HashMap<String, String> queryMap = new HashMap<>();
@@ -1219,25 +1219,25 @@ public class ModelsServiceImpl implements ModelsService {
List<Ray> rayList = rayDao.queryByModelId(JSON.toJSONString(queryMap)); List<Ray> rayList = rayDao.queryByModelId(JSON.toJSONString(queryMap));
if (rayList != null && !rayList.isEmpty()) { if (rayList != null && !rayList.isEmpty()) {
String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet()));
throw new Exception("该模型版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
throw new Exception("该模型版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
} }


List<ActiveLearn> activeLearnList = activeLearnDao.queryByModelId(JSON.toJSONString(queryMap)); List<ActiveLearn> activeLearnList = activeLearnDao.queryByModelId(JSON.toJSONString(queryMap));
if (activeLearnList != null && !activeLearnList.isEmpty()) { if (activeLearnList != null && !activeLearnList.isEmpty()) {
String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet()));
throw new Exception("该模型版本被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
throw new Exception("该模型版本被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
} }


List<DevEnvironment> devEnvironmentList = devEnvironmentDao.queryByModelId(JSON.toJSONString(queryMap)); List<DevEnvironment> devEnvironmentList = devEnvironmentDao.queryByModelId(JSON.toJSONString(queryMap));
if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) { if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) {
String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet())); String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet()));
throw new Exception("该模型版本被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境");
throw new Exception("该模型版本被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境");
} }


List<String> serviceVersionList = serviceDao.queryByModelId(JSON.toJSONString(queryMap)); List<String> serviceVersionList = serviceDao.queryByModelId(JSON.toJSONString(queryMap));
if (serviceVersionList != null && !serviceVersionList.isEmpty()) { if (serviceVersionList != null && !serviceVersionList.isEmpty()) {
String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet())); String serviceVersions = String.join(",", serviceVersionList.stream().collect(Collectors.toSet()));
throw new Exception("该模型版本被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本");
throw new Exception("该模型版本被服务版本:" + serviceVersions + "使用,不能删除,请先删除服务版本");
} }


String token = gitService.checkoutToken(); String token = gitService.checkoutToken();


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsVersionServiceImpl.java View File

@@ -99,7 +99,7 @@ public class ModelsVersionServiceImpl implements ModelsVersionService {
public ModelsVersion update(ModelsVersion modelsVersion) { public ModelsVersion update(ModelsVersion modelsVersion) {
int currentState = modelsVersion.getState(); int currentState = modelsVersion.getState();
if(currentState == 0){ if(currentState == 0){
throw new RuntimeException("模型版本已被删除,无法更新");
throw new RuntimeException("模型版本已被删除,无法更新");
} }
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
modelsVersion.setUpdateBy(loginUser.getUsername()); modelsVersion.setUpdateBy(loginUser.getUsername());


+ 10
- 10
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java View File

@@ -415,7 +415,7 @@ public class NewDatasetServiceImpl implements NewDatasetService {
List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(repoId), Constant.Asset_Type_Dataset, null); List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(repoId), Constant.Asset_Type_Dataset, null);
if (assetWorkflow != null && !assetWorkflow.isEmpty()) { if (assetWorkflow != null && !assetWorkflow.isEmpty()) {
String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet()));
throw new Exception("该数据集被流水线:" + workflows + "使用,不能删除,请先删除流水线");
throw new Exception("该数据集被流水线:" + workflows + "使用,不能删除,请先删除流水线");
} }


HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
@@ -423,25 +423,25 @@ public class NewDatasetServiceImpl implements NewDatasetService {
List<AutoMl> autoMlList = autoMlDao.queryByDatasetId(JSON.toJSONString(map)); List<AutoMl> autoMlList = autoMlDao.queryByDatasetId(JSON.toJSONString(map));
if (autoMlList != null && !autoMlList.isEmpty()) { if (autoMlList != null && !autoMlList.isEmpty()) {
String autoMls = String.join(",", autoMlList.stream().map(AutoMl::getMlName).collect(Collectors.toSet())); String autoMls = String.join(",", autoMlList.stream().map(AutoMl::getMlName).collect(Collectors.toSet()));
throw new Exception("该数据集被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习");
throw new Exception("该数据集被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习");
} }


List<Ray> rayList = rayDao.queryByDatasetId(JSON.toJSONString(map)); List<Ray> rayList = rayDao.queryByDatasetId(JSON.toJSONString(map));
if (rayList != null && !rayList.isEmpty()) { if (rayList != null && !rayList.isEmpty()) {
String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet()));
throw new Exception("该数据集被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
throw new Exception("该数据集被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
} }


List<ActiveLearn> activeLearnList = activeLearnDao.queryByDatasetId(JSON.toJSONString(map)); List<ActiveLearn> activeLearnList = activeLearnDao.queryByDatasetId(JSON.toJSONString(map));
if (activeLearnList != null && !activeLearnList.isEmpty()) { if (activeLearnList != null && !activeLearnList.isEmpty()) {
String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet()));
throw new Exception("该数据集被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
throw new Exception("该数据集被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
} }


List<DevEnvironment> devEnvironmentList = devEnvironmentDao.queryByDatasetId(JSON.toJSONString(map)); List<DevEnvironment> devEnvironmentList = devEnvironmentDao.queryByDatasetId(JSON.toJSONString(map));
if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) { if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) {
String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet())); String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet()));
throw new Exception("该数据集被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境");
throw new Exception("该数据集被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境");
} }


String token = gitService.checkoutToken(); String token = gitService.checkoutToken();
@@ -457,7 +457,7 @@ public class NewDatasetServiceImpl implements NewDatasetService {
List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(repoId), Constant.Asset_Type_Dataset, version); List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(repoId), Constant.Asset_Type_Dataset, version);
if (assetWorkflow != null && !assetWorkflow.isEmpty()) { if (assetWorkflow != null && !assetWorkflow.isEmpty()) {
String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet()));
throw new Exception("该数据集版本被流水线:" + workflows + "使用,不能删除,请先删除流水线");
throw new Exception("该数据集版本被流水线:" + workflows + "使用,不能删除,请先删除流水线");
} }


HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
@@ -466,25 +466,25 @@ public class NewDatasetServiceImpl implements NewDatasetService {
List<AutoMl> autoMlList = autoMlDao.queryByDatasetId(JSON.toJSONString(map)); List<AutoMl> autoMlList = autoMlDao.queryByDatasetId(JSON.toJSONString(map));
if (autoMlList != null && !autoMlList.isEmpty()) { if (autoMlList != null && !autoMlList.isEmpty()) {
String autoMls = String.join(",", autoMlList.stream().map(AutoMl::getMlName).collect(Collectors.toSet())); String autoMls = String.join(",", autoMlList.stream().map(AutoMl::getMlName).collect(Collectors.toSet()));
throw new Exception("该数据集版本被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习");
throw new Exception("该数据集版本被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习");
} }


List<Ray> rayList = rayDao.queryByDatasetId(JSON.toJSONString(map)); List<Ray> rayList = rayDao.queryByDatasetId(JSON.toJSONString(map));
if (rayList != null && !rayList.isEmpty()) { if (rayList != null && !rayList.isEmpty()) {
String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet()));
throw new Exception("该数据集版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
throw new Exception("该数据集版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优");
} }


List<ActiveLearn> activeLearnList = activeLearnDao.queryByDatasetId(JSON.toJSONString(map)); List<ActiveLearn> activeLearnList = activeLearnDao.queryByDatasetId(JSON.toJSONString(map));
if (activeLearnList != null && !activeLearnList.isEmpty()) { if (activeLearnList != null && !activeLearnList.isEmpty()) {
String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet())); String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet()));
throw new Exception("该数据集版本被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
throw new Exception("该数据集版本被主动学习:" + activeLearns + "使用,不能删除,请先删除主动学习");
} }


List<DevEnvironment> devEnvironmentList = devEnvironmentDao.queryByDatasetId(JSON.toJSONString(map)); List<DevEnvironment> devEnvironmentList = devEnvironmentDao.queryByDatasetId(JSON.toJSONString(map));
if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) { if (devEnvironmentList != null && !devEnvironmentList.isEmpty()) {
String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet())); String devEnvironments = String.join(",", devEnvironmentList.stream().map(DevEnvironment::getName).collect(Collectors.toSet()));
throw new Exception("该数据集版本被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境");
throw new Exception("该数据集版本被开发环境:" + devEnvironments + "使用,不能删除,请先删除开发环境");
} }


String token = gitService.checkoutToken(); String token = gitService.checkoutToken();


+ 4
- 4
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayInsServiceImpl.java View File

@@ -139,7 +139,7 @@ public class RayInsServiceImpl implements RayInsService {
String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res)); String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res));
// 检查响应是否为空或无内容 // 检查响应是否为空或无内容
if (StringUtils.isEmpty(req)) { if (StringUtils.isEmpty(req)) {
throw new RuntimeException("终止响应内容为空");
throw new RuntimeException("终止响应内容为空");


} }
// 将响应的JSON字符串转换为Map对象 // 将响应的JSON字符串转换为Map对象
@@ -227,19 +227,19 @@ public class RayInsServiceImpl implements RayInsService {
String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res)); String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res));
// 检查响应是否为空或无内容 // 检查响应是否为空或无内容
if (req == null || StringUtils.isEmpty(req)) { if (req == null || StringUtils.isEmpty(req)) {
throw new RuntimeException("工作流状态响应为空");
throw new RuntimeException("工作流状态响应为空");
} }
// 将响应的JSON字符串转换为Map对象 // 将响应的JSON字符串转换为Map对象
Map<String, Object> runResMap = JsonUtils.jsonToMap(req); Map<String, Object> runResMap = JsonUtils.jsonToMap(req);
// 从响应Map中获取"data"部分 // 从响应Map中获取"data"部分
Map<String, Object> data = (Map<String, Object>) runResMap.get("data"); Map<String, Object> data = (Map<String, Object>) runResMap.get("data");
if (data == null || data.isEmpty()) { if (data == null || data.isEmpty()) {
throw new RuntimeException("工作流数据为空.");
throw new RuntimeException("工作流数据为空");
} }
// 从"data"中获取"status"部分,并返回"phase"的值 // 从"data"中获取"status"部分,并返回"phase"的值
Map<String, Object> status = (Map<String, Object>) data.get("status"); Map<String, Object> status = (Map<String, Object>) data.get("status");
if (status == null || status.isEmpty()) { if (status == null || status.isEmpty()) {
throw new RuntimeException("工作流状态为空");
throw new RuntimeException("工作流状态为空");
} }


//解析流水线结束时间 //解析流水线结束时间


+ 3
- 4
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java View File

@@ -63,15 +63,14 @@ public class RayServiceImpl implements RayService {


@Override @Override
public Ray save(RayVo rayVo) throws Exception { public Ray save(RayVo rayVo) throws Exception {
if (rayVo.getName().length() >= 64) {
throw new RuntimeException("实验名称大于最大长度");
}
Ray rayByName = rayDao.getRayByName(rayVo.getName()); Ray rayByName = rayDao.getRayByName(rayVo.getName());
if (rayByName != null) { if (rayByName != null) {
throw new RuntimeException("实验名称已存在"); throw new RuntimeException("实验名称已存在");
} }


if (rayVo.getName().length() >= 64) {
throw new RuntimeException("实验名称大于最大长度");
}

Ray ray = new Ray(); Ray ray = new Ray();
BeanUtils.copyProperties(rayVo, ray); BeanUtils.copyProperties(rayVo, ray);
String username = SecurityUtils.getLoginUser().getUsername(); String username = SecurityUtils.getLoginUser().getUsername();


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java View File

@@ -229,7 +229,7 @@ public class ServiceServiceImpl implements ServiceService {
List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(id), Constant.Asset_Type_Service, null); List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(id), Constant.Asset_Type_Service, null);
if (assetWorkflow != null && !assetWorkflow.isEmpty()) { if (assetWorkflow != null && !assetWorkflow.isEmpty()) {
String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet()));
throw new Exception("该服务被流水线:" + workflows + "使用,不能删除,请先删除流水线");
throw new Exception("该服务被流水线:" + workflows + "使用,不能删除,请先删除流水线");
} }


LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();


+ 179
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/TextClassificationServiceImpl.java View File

@@ -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<TextClassification> queryByPage(String name, PageRequest pageRequest) {
long total = textClassificationDao.count(name);
List<TextClassification> 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<String, Object> converMap = JsonUtils.jsonToMap(convertRes);
// 组装运行接口json
Map<String, Object> output = (Map<String, Object>) converMap.get("output");
Map<String, Object> 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<String, Object> runResMap = JsonUtils.jsonToMap(runRes);
Map<String, Object> data = (Map<String, Object>) runResMap.get("data");
//判断data为空
if (data == null || MapUtils.isEmpty(data)) {
throw new RuntimeException("运行流水线失败");
}
Map<String, Object> metadata = (Map<String, Object>) 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<String, Object> param_output = (Map<String, Object>) output.get("param_output");
List output1 = (ArrayList) param_output.values().toArray()[0];
Map<String, String> output2 = (Map<String, String>) 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 "执行成功";
}
}

+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java View File

@@ -201,7 +201,7 @@ public class WorkflowServiceImpl implements WorkflowService {
// 从响应Map中获取"data"的值,也就是日志的值 // 从响应Map中获取"data"的值,也就是日志的值
String newDag = (String) runResMap.get("data"); String newDag = (String) runResMap.get("data");
if (newDag == null) { if (newDag == null) {
throw new RuntimeException("响应内容为空");
throw new RuntimeException("响应内容为空");
} }
duplicateWorkflow.setDag(newDag); duplicateWorkflow.setDag(newDag);
duplicateWorkflow.setDescription(workflow.getDescription()); duplicateWorkflow.setDescription(workflow.getDescription());


+ 31
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/TextClassificationParamVo.java View File

@@ -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<String, Object> dataset;

@ApiModelProperty(value = "epochs")
private Integer epochs;

@ApiModelProperty(value = "batch_size")
private Integer batchSize;

@ApiModelProperty(value = "学习率")
private Float lr;
}

+ 51
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/TextClassificationVo.java View File

@@ -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<String, Object> 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;
}

+ 1
- 4
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.platform.mapper.AutoMlDao"> <mapper namespace="com.ruoyi.platform.mapper.AutoMlDao">
<insert id="save">
<insert id="save" keyProperty="id" useGeneratedKeys="true">
insert into auto_ml(ml_name, ml_description, task_type, dataset, time_left_for_this_task, 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, per_run_time_limit, ensemble_size, ensemble_class, ensemble_nbest, max_models_on_disc, seed,
memory_limit, memory_limit,
@@ -37,9 +37,6 @@
<if test="autoMl.statusList != null and autoMl.statusList !=''"> <if test="autoMl.statusList != null and autoMl.statusList !=''">
status_list = #{autoMl.statusList}, status_list = #{autoMl.statusList},
</if> </if>
<!-- <if test="autoMl.progress != null">-->
<!-- progress = #{autoMl.progress},-->
<!-- </if>-->
<if test="autoMl.taskType != null and autoMl.taskType !=''"> <if test="autoMl.taskType != null and autoMl.taskType !=''">
task_type = #{autoMl.taskType}, task_type = #{autoMl.taskType},
</if> </if>


+ 87
- 0
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/TextClassificationDaoMapper.xml View File

@@ -0,0 +1,87 @@
<?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.TextClassificationDao">
<select id="count" resultType="java.lang.Long">
select count(1) from text_classification
<include refid="common_condition"></include>
</select>

<select id="queryByPage" resultType="com.ruoyi.platform.domain.TextClassification">
select * from text_classification
<include refid="common_condition"></include>
order by create_time desc limit #{pageable.offset}, #{pageable.pageSize}
</select>

<select id="getByName" resultType="com.ruoyi.platform.domain.TextClassification">
select *
from text_classification
where name = #{name}
and state = 1
</select>

<select id="getById" resultType="com.ruoyi.platform.domain.TextClassification">
select *
from text_classification
where id = #{id}
</select>

<insert id="save" keyProperty="id" useGeneratedKeys="true">
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},)
</insert>

<update id="edit">
update text_classification
<set>
<if test="textClassification.name != null and textClassification.name !=''">
name = #{textClassification.name},
</if>
<if test="textClassification.description != null and textClassification.description !=''">
description = #{textClassification.description},
</if>
<if test="textClassification.model != null and textClassification.model !=''">
model = #{textClassification.model},
</if>
<if test="textClassification.dataset != null and textClassification.dataset !=''">
dataset = #{textClassification.dataset},
</if>
<if test="textClassification.epochs != null">
epochs = #{textClassification.epochs},
</if>
<if test="textClassification.batchSize != null">
batch_size = #{textClassification.batchSize},
</if>
<if test="textClassification.lr != null">
lr = #{textClassification.lr},
</if>
<if test="textClassification.updateBy != null and textClassification.updateBy !=''">
update_by = #{textClassification.updateBy},
</if>
<if test="textClassification.statusList != null and textClassification.statusList !=''">
status_list = #{textClassification.statusList},
</if>
<if test="textClassification.state != null">
state = #{textClassification.state},
</if>
</set>
where id = #{textClassification.id}
</update>

<select id="queryByDatasetId" resultType="com.ruoyi.platform.domain.TextClassification">
select *
from text_classification
where JSON_CONTAINS(dataset, #{datasetId})
and state = 1
</select>

<sql id="common_condition">
<where>
state = 1
<if test="name != null and name != ''">
and name like concat('%', #{name}, '%')
</if>
</where>
</sql>
</mapper>

+ 85
- 0
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/TextClassificationInsDaoMapper.xml View File

@@ -0,0 +1,85 @@
<?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.TextClassificationInsDao">
<select id="count" resultType="java.lang.Long">
select count(1)
from text_classification_ins
<where>
state = 1
and text_classification_id = #{textClassificationIns.textClassificationId}
</where>
</select>

<select id="queryAllByLimit" resultType="com.ruoyi.platform.domain.TextClassificationIns">
select * from text_classification_ins
<where>
state = 1
and text_classification_id = #{textClassificationIns.textClassificationId}
</where>
order by update_time DESC
limit #{pageable.offset}, #{pageable.pageSize}
</select>

<select id="getByTextClassificationId" resultType="com.ruoyi.platform.domain.TextClassificationIns">
select *
from text_classification_ins
where text_classification_id = #{textClassificationId}
and state = 1
order by update_time DESC limit 5
</select>

<select id="queryById" resultType="com.ruoyi.platform.domain.TextClassificationIns">
select * from text_classification_ins
<where>
state = 1 and id = #{id}
</where>
</select>

<insert id="insert" keyProperty="id" useGeneratedKeys="true">
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})
</insert>

<update id="update">
update text_classification_ins
<set>
<if test="autoMlIns.modelPath != null and autoMlIns.modelPath != ''">
model_path = #{autoMlIns.modelPath},
</if>
<if test="autoMlIns.resultPath != null and autoMlIns.resultPath != ''">
result_path = #{autoMlIns.resultPath},
</if>
<if test="autoMlIns.status != null and autoMlIns.status != ''">
status = #{autoMlIns.status},
</if>
<if test="autoMlIns.nodeStatus != null and autoMlIns.nodeStatus != ''">
node_status = #{autoMlIns.nodeStatus},
</if>
<if test="autoMlIns.nodeResult != null and autoMlIns.nodeResult != ''">
node_result = #{autoMlIns.nodeResult},
</if>
<if test="autoMlIns.state != null">
state = #{autoMlIns.state},
</if>
<if test="autoMlIns.updateTime != null">
update_time = #{autoMlIns.updateTime},
</if>
<if test="autoMlIns.finishTime != null">
finish_time = #{autoMlIns.finishTime},
</if>
</set>
where id = #{textClassificationIns.id}
</update>

<select id="queryByAutoMlInsIsNotTerminated" resultType="com.ruoyi.platform.domain.TextClassificationIns">
select *
from text_classification_ins
where (status NOT IN ('Terminated', 'Succeeded', 'Failed')
OR status IS NULL)
and state = 1
</select>
</mapper>

Loading…
Cancel
Save