Browse Source

Merge branch 'dev-text_classfication' into dev

pull/225/head
chenzhihang 9 months ago
parent
commit
a113e0313c
51 changed files with 2300 additions and 93 deletions
  1. +1
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/autoML/AutoMlController.java
  2. +61
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/machineLearn/MachineLearnController.java
  3. +60
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/machineLearn/MachineLearnInsController.java
  4. +62
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/textClassfication/TextClassificationController.java
  5. +59
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/textClassfication/TextClassificationInsController.java
  6. +42
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/MachineLearn.java
  7. +51
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/MachineLearnIns.java
  8. +52
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/TextClassification.java
  9. +41
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/TextClassificationIns.java
  10. +23
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/MachineLearnDao.java
  11. +23
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/MachineLearnInsDao.java
  12. +23
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/TextClassificationDao.java
  13. +23
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/TextClassificationInsDao.java
  14. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/AutoMlInsStatusTask.java
  15. +119
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/MLStatusTask.java
  16. +116
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/TextClassificationInsTask.java
  17. +28
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/MachineLearnInsService.java
  18. +19
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/MachineLearnService.java
  19. +27
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/TextClassificationInsService.java
  20. +22
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/TextClassificationService.java
  21. +4
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java
  22. +3
    -3
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java
  23. +6
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlInsServiceImpl.java
  24. +5
    -7
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java
  25. +4
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java
  26. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java
  27. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java
  28. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java
  29. +5
    -5
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java
  30. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java
  31. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/GitServiceImpl.java
  32. +6
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java
  33. +6
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageVersionServiceImpl.java
  34. +259
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MachineLearnInsServiceImpl.java
  35. +220
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MachineLearnServiceImpl.java
  36. +11
    -11
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java
  37. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsVersionServiceImpl.java
  38. +25
    -17
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java
  39. +4
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayInsServiceImpl.java
  40. +3
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java
  41. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java
  42. +259
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/TextClassificationInsServiceImpl.java
  43. +191
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/TextClassificationServiceImpl.java
  44. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java
  45. +33
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/TextClassificationParamVo.java
  46. +51
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/TextClassificationVo.java
  47. +1
    -4
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml
  48. +82
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/MachineLearnDaoMapper.xml
  49. +83
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/MachineLearnInsDaoMapper.xml
  50. +90
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/TextClassificationDaoMapper.xml
  51. +85
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/TextClassificationInsDaoMapper.xml

+ 1
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/autoML/AutoMlController.java View File

@@ -44,6 +44,7 @@ public class AutoMlController extends BaseController {
public GenericsAjaxResult<String> editAutoMl(@RequestBody AutoMlVo autoMlVo) throws Exception {
return genericsSuccess(this.autoMlService.edit(autoMlVo));
}

@GetMapping("/getAutoMlDetail")
@ApiOperation("获取自动机器学习详细信息")
public GenericsAjaxResult<AutoMlVo> getAutoMlDetail(@RequestParam("id") Long id) throws IOException {


+ 61
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/machineLearn/MachineLearnController.java View File

@@ -0,0 +1,61 @@
package com.ruoyi.platform.controller.machineLearn;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.GenericsAjaxResult;
import com.ruoyi.platform.domain.MachineLearn;
import com.ruoyi.platform.service.MachineLearnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("machineLearn")
@Api("自动机器学习")
public class MachineLearnController extends BaseController {
@Resource
private MachineLearnService machineLearnService;

@GetMapping
@ApiOperation("分页查询")
public GenericsAjaxResult<Page<MachineLearn>> queryByPage(@RequestParam("page") int page,
@RequestParam("size") int size,
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "type", required = false) String type) {
PageRequest pageRequest = PageRequest.of(page, size);
return genericsSuccess(this.machineLearnService.queryByPage(name, type, pageRequest));
}

@PostMapping
@ApiOperation("新增自动机器学习")
public GenericsAjaxResult<MachineLearn> add(@RequestBody MachineLearn machineLearn) {
return genericsSuccess(this.machineLearnService.add(machineLearn));
}

@PutMapping
@ApiOperation("编辑自动机器学习")
public GenericsAjaxResult<String> edit(@RequestBody MachineLearn machineLearn) throws Exception {
return genericsSuccess(this.machineLearnService.edit(machineLearn));
}

@GetMapping("/getMLDetail")
@ApiOperation("获取自动机器学习详细信息")
public GenericsAjaxResult<MachineLearn> getMLDetail(@RequestParam("id") Long id) {
return genericsSuccess(this.machineLearnService.getMLDetail(id));
}

@DeleteMapping("{id}")
@ApiOperation("删除自动机器学习")
public GenericsAjaxResult<String> delete(@PathVariable("id") Long id) {
return genericsSuccess(this.machineLearnService.delete(id));
}

@PostMapping("/run/{id}")
@ApiOperation("运行自动机器学习")
public GenericsAjaxResult<String> runMachineLearn(@PathVariable("id") Long id) throws Exception {
return genericsSuccess(this.machineLearnService.runMachineLearn(id));
}
}

+ 60
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/machineLearn/MachineLearnInsController.java View File

@@ -0,0 +1,60 @@
package com.ruoyi.platform.controller.machineLearn;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.GenericsAjaxResult;
import com.ruoyi.platform.domain.MachineLearnIns;
import com.ruoyi.platform.service.MachineLearnInsService;
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("machineLearnIns")
@Api("自动机器学习实验实例")
public class MachineLearnInsController extends BaseController {

@Resource
private MachineLearnInsService machineLearnInsService;

@GetMapping
@ApiOperation("分页查询")
public GenericsAjaxResult<Page<MachineLearnIns>> queryByPage(Long machineLearnId, int page, int size) {
PageRequest pageRequest = PageRequest.of(page, size);
return genericsSuccess(this.machineLearnInsService.queryByPage(machineLearnId, pageRequest));
}

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

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

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

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

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

+ 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));
}
}

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

@@ -0,0 +1,42 @@
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 MachineLearn {
private Long id;

private Long experimentId;

@ApiModelProperty(value = "类型")
private String type;

@ApiModelProperty(value = "实验名称")
private String name;

@ApiModelProperty(value = "实验描述")
private String description;

private String param;

private String createBy;

private Date createTime;

private String updateBy;

private Date updateTime;

private Integer state;

@ApiModelProperty(value = "状态列表")
private String statusList;
}

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

@@ -0,0 +1,51 @@
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 MachineLearnIns {

private Long id;

private Long machineLearnId;

private String type;

private String resultPath;

private String modelPath;

private String imgPath;

private String runHistoryPath;

private Integer state;

private String status;

private String nodeStatus;

private String nodeResult;

private String param;

@ApiModelProperty(value = "Argo实例名称")
private String argoInsName;

@ApiModelProperty(value = "Argo命名空间")
private String argoInsNs;

private Date createTime;

private Date updateTime;

private Date finishTime;
}

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

@@ -0,0 +1,52 @@
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 = "模型类型:TextCNN, TextRNN, FastText, TextRCNN, TextRNN_Att, DPCNN, Transformer")
private String modelType;

@ApiModelProperty(value = "数据集")
private String dataset;

private Integer computingResourceId;

@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/MachineLearnDao.java View File

@@ -0,0 +1,23 @@
package com.ruoyi.platform.mapper;

import com.ruoyi.platform.domain.MachineLearn;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;

import java.util.List;

public interface MachineLearnDao {
long count(@Param("name") String name, @Param("type") String type);

List<MachineLearn> queryByPage(@Param("name") String name, @Param("type") String type, @Param("pageable") Pageable pageable);

int save(@Param("machineLearn") MachineLearn machineLearn);

int edit(@Param("machineLearn") MachineLearn machineLearn);

MachineLearn getMachineLearnById(@Param("id") Long id);

MachineLearn getMachineLearnByName(@Param("name") String name);

List<MachineLearn> queryByDatasetId(@Param("datasetId") String datasetId);
}

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

@@ -0,0 +1,23 @@
package com.ruoyi.platform.mapper;

import com.ruoyi.platform.domain.MachineLearnIns;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;

import java.util.List;

public interface MachineLearnInsDao {
long count(@Param("machineLearnId") Long machineLearnId);

List<MachineLearnIns> queryAllByLimit(@Param("machineLearnId") Long machineLearnId, @Param("pageable") Pageable pageable);

List<MachineLearnIns> getByMachineLearnId(@Param("machineLearnId") Long machineLearnId);

int insert(@Param("machineLearnIns") MachineLearnIns machineLearnIns);

int update(@Param("machineLearnIns") MachineLearnIns machineLearnIns);

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

List<MachineLearnIns> queryNotTerminated();
}

+ 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();
}

+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/AutoMlInsStatusTask.java View File

@@ -30,7 +30,7 @@ public class AutoMlInsStatusTask {
private List<Long> autoMlIds = new ArrayList<>();

@Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次
public void executeAutoMlInsStatus() throws Exception {
public void executeAutoMlInsStatus() {
// 首先查到所有非终止态的实验实例
List<AutoMlIns> autoMlInsList = autoMlInsService.queryByAutoMlInsIsNotTerminated();

@@ -59,7 +59,7 @@ public class AutoMlInsStatusTask {
}

@Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次
public void executeAutoMlStatus() throws Exception {
public void executeAutoMlStatus() {
if (autoMlIds.size() == 0) {
return;
}


+ 119
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/MLStatusTask.java View File

@@ -0,0 +1,119 @@
package com.ruoyi.platform.scheduling;

import com.ruoyi.platform.domain.*;
import com.ruoyi.platform.mapper.MachineLearnDao;
import com.ruoyi.platform.mapper.MachineLearnInsDao;
import com.ruoyi.platform.mapper.ResourceOccupyDao;
import com.ruoyi.platform.service.MachineLearnInsService;
import com.ruoyi.platform.service.ResourceOccupyService;
import com.ruoyi.system.api.constant.Constant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

@Component()
public class MLStatusTask {
@Resource
private MachineLearnInsService machineLearnInsService;
@Resource
private MachineLearnInsDao machineLearnInsDao;
@Resource
private MachineLearnDao machineLearnDao;
@Resource
private ResourceOccupyDao resourceOccupyDao;
@Resource
private ResourceOccupyService resourceOccupyService;

private List<Long> machineLearnIds = new ArrayList<>();

@Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次
public void executeMachineLearnInsStatus() {
// 首先查到所有非终止态的实验实例
List<MachineLearnIns> insList = machineLearnInsService.queryNotTerminated();

// 去argo查询状态
List<MachineLearnIns> updateList = new ArrayList<>();
if (insList != null && insList.size() > 0) {
for (MachineLearnIns ins : insList) {
//当原本状态为null或非终止态时才调用argo接口
try {
Long userId = resourceOccupyDao.getResourceOccupyByTask(Constant.TaskType_ML, ins.getMachineLearnId(), ins.getId(), null).get(0).getUserId();
if (userId != null) {
if (resourceOccupyDao.getUserCredit(userId) <= 0) {
ins.setStatus(Constant.Failed);
machineLearnInsService.terminateMLIns(ins.getId());
} else {
ins = machineLearnInsService.queryStatusFromArgo(ins);
// 扣除积分
if (Constant.Running.equals(ins.getStatus())) {
resourceOccupyService.deducing(Constant.TaskType_ML, null, ins.getId(), null, null);
} else if (Constant.Failed.equals(ins.getStatus()) || Constant.Terminated.equals(ins.getStatus())
|| Constant.Succeeded.equals(ins.getStatus())) {
resourceOccupyService.endDeduce(Constant.TaskType_ML, null, ins.getId(), null, null);
}
}
} else {
ins = machineLearnInsService.queryStatusFromArgo(ins);
}
} catch (Exception e) {
ins.setStatus(Constant.Failed);
// 结束扣除积分
resourceOccupyService.endDeduce(Constant.TaskType_ML, null, ins.getId(), null, null);
}
// 线程安全的添加操作
synchronized (machineLearnIds) {
machineLearnIds.add(ins.getMachineLearnId());
}
updateList.add(ins);
if (updateList.size() > 0) {
for (MachineLearnIns machineLearnIns : updateList) {
machineLearnInsDao.update(machineLearnIns);
}
}
}
}
}

@Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次
public void executeMachineLearn() {
if (machineLearnIds.size() == 0) {
return;
}
// 存储需要更新的实验对象列表
List<MachineLearn> updateMLs = new ArrayList<>();
for (Long machineLearnId : machineLearnIds) {
// 获取当前实验的所有实例列表
List<MachineLearnIns> insList = machineLearnInsDao.getByMachineLearnId(machineLearnId);
List<String> statusList = new ArrayList<>();
// 更新实验状态列表
for (int i = 0; i < insList.size(); i++) {
statusList.add(insList.get(i).getStatus());
}
String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1);
MachineLearn machineLearn = machineLearnDao.getMachineLearnById(machineLearnId);
if (!StringUtils.equals(machineLearn.getStatusList(), subStatus)) {
machineLearn.setStatusList(subStatus);
updateMLs.add(machineLearn);
machineLearnDao.edit(machineLearn);
}
}

if (!updateMLs.isEmpty()) {
// 使用Iterator进行安全的删除操作
Iterator<Long> iterator = machineLearnIds.iterator();
while (iterator.hasNext()) {
Long machineLearnId = iterator.next();
for (MachineLearn machineLearn : updateMLs) {
if (machineLearn.getId().equals(machineLearnId)) {
iterator.remove();
}
}
}
}
}
}

+ 116
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/TextClassificationInsTask.java View File

@@ -0,0 +1,116 @@
package com.ruoyi.platform.scheduling;

import com.ruoyi.platform.domain.TextClassification;
import com.ruoyi.platform.domain.TextClassificationIns;
import com.ruoyi.platform.mapper.ResourceOccupyDao;
import com.ruoyi.platform.mapper.TextClassificationDao;
import com.ruoyi.platform.mapper.TextClassificationInsDao;
import com.ruoyi.platform.service.ResourceOccupyService;
import com.ruoyi.platform.service.TextClassificationInsService;
import com.ruoyi.system.api.constant.Constant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

@Component()
public class TextClassificationInsTask {
@Resource
private TextClassificationInsService textClassificationInsService;
@Resource
private TextClassificationInsDao textClassificationInsDao;
@Resource
private TextClassificationDao textClassificationDao;
@Resource
private ResourceOccupyDao resourceOccupyDao;
@Resource
private ResourceOccupyService resourceOccupyService;

private List<Long> textClassificationIds = new ArrayList<>();

@Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次
public void executeTextClassificationInsStatus() {
// 首先查到所有非终止态的实验实例
List<TextClassificationIns> insList = textClassificationInsService.queryByNotTerminated();

// 去argo查询状态
List<TextClassificationIns> updateList = new ArrayList<>();
if (insList != null && insList.size() > 0) {
for (TextClassificationIns ins : insList) {
//当原本状态为null或非终止态时才调用argo接口
try {
Long userId = resourceOccupyDao.getResourceOccupyByTask(Constant.TaskType_TextClassification, ins.getTextClassificationId(), ins.getId(), null).get(0).getUserId();
if (resourceOccupyDao.getUserCredit(userId) <= 0) {
ins.setStatus(Constant.Failed);
textClassificationInsService.terminateTextClassificationIns(ins.getId());
} else {
ins = textClassificationInsService.queryStatusFromArgo(ins);
// 扣除积分
if (Constant.Running.equals(ins.getStatus())) {
resourceOccupyService.deducing(Constant.TaskType_TextClassification, null, ins.getId(), null, null);
} else if (Constant.Failed.equals(ins.getStatus()) || Constant.Terminated.equals(ins.getStatus())
|| Constant.Succeeded.equals(ins.getStatus())) {
resourceOccupyService.endDeduce(Constant.TaskType_TextClassification, null, ins.getId(), null, null);
}
}
} catch (Exception e) {
ins.setStatus(Constant.Failed);
// 结束扣除积分
resourceOccupyService.endDeduce(Constant.TaskType_TextClassification, null, ins.getId(), null, null);
}
// 线程安全的添加操作
synchronized (textClassificationIds) {
textClassificationIds.add(ins.getTextClassificationId());
}
updateList.add(ins);
}
if (updateList.size() > 0) {
for (TextClassificationIns ins : updateList) {
textClassificationInsDao.update(ins);
}
}
}
}

@Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次
public void executeTextClassificationStatus() {
if (textClassificationIds.size() == 0) {
return;
}
// 存储需要更新的实验对象列表
List<TextClassification> updateTextClassifications = new ArrayList<>();
for (Long textClassificationId : textClassificationIds) {
// 获取当前实验的所有实例列表
List<TextClassificationIns> insList = textClassificationInsDao.getByTextClassificationId(textClassificationId);
List<String> statusList = new ArrayList<>();
// 更新实验状态列表
for (int i = 0; i < insList.size(); i++) {
statusList.add(insList.get(i).getStatus());
}
String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1);
TextClassification textClassification = textClassificationDao.getById(textClassificationId);
if (!StringUtils.equals(textClassification.getStatusList(), subStatus)) {
textClassification.setStatusList(subStatus);
updateTextClassifications.add(textClassification);
textClassificationDao.edit(textClassification);
}
}

if (!updateTextClassifications.isEmpty()) {
// 使用Iterator进行安全的删除操作
Iterator<Long> iterator = textClassificationIds.iterator();
while (iterator.hasNext()) {
Long textClassificationId = iterator.next();
for (TextClassification textClassification : updateTextClassifications) {
if (textClassification.getId().equals(textClassificationId)) {
iterator.remove();
}
}
}
}
}
}

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

@@ -0,0 +1,28 @@
package com.ruoyi.platform.service;

import com.ruoyi.platform.domain.MachineLearnIns;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

import java.util.List;

public interface MachineLearnInsService {

Page<MachineLearnIns> queryByPage(Long machineLearnId, PageRequest pageRequest);

MachineLearnIns insert(MachineLearnIns machineLearnIns);

String removeById(Long id);

String batchDelete(List<Long> ids);

List<MachineLearnIns> queryNotTerminated();

MachineLearnIns queryStatusFromArgo(MachineLearnIns machineLearnIns);

boolean terminateMLIns(Long id) throws Exception;

MachineLearnIns getDetailById(Long id);

void updateMLStatus(Long machineLearnId);
}

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

@@ -0,0 +1,19 @@
package com.ruoyi.platform.service;

import com.ruoyi.platform.domain.MachineLearn;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

public interface MachineLearnService {
Page<MachineLearn> queryByPage(String name, String type, PageRequest pageRequest);

MachineLearn add(MachineLearn machineLearn);

String edit(MachineLearn machineLearn);

MachineLearn getMLDetail(Long id);

String delete(Long id);

String runMachineLearn(Long id) throws Exception;
}

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

@@ -0,0 +1,27 @@
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);
}

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

@@ -0,0 +1,22 @@
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));
// 检查响应是否为空或无内容
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<String, Object> runResMap = JsonUtils.jsonToMap(req);
// 从响应Map中获取"data"部分
Map<String, Object> data = (Map<String, Object>) runResMap.get("data");
if (data == null || data.isEmpty()) {
throw new RuntimeException("工作流数据为空.");
throw new RuntimeException("工作流数据为空");
}
// 从"data"中获取"status"部分,并返回"phase"的值
Map<String, Object> status = (Map<String, Object>) data.get("status");
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
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);


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


+ 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
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<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("Failed to run workflow.");
throw new RuntimeException("运行流水线失败");
}
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);
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<String, String> map = new HashMap<>();
@@ -102,19 +102,19 @@ public class CodeConfigServiceImpl implements CodeConfigService {
List<Ray> 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<ActiveLearn> 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<String> 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();


+ 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());

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类型


+ 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) {
int currentState = dataset.getState();
if (currentState == 0) {
throw new RuntimeException("数据集已被删除,无法更新");
throw new RuntimeException("数据集已被删除,无法更新");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
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) {
int currentState = datasetVersion.getState();
if (currentState == 0){
throw new RuntimeException("数据集版本已被删除,无法更新");
throw new RuntimeException("数据集版本已被删除,无法更新");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
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));
// 检查响应是否为空或无内容
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<String, Object> data = (Map<String, Object>) runResMap.get("data");
if (data == null || data.isEmpty()) {
throw new RuntimeException("工作流数据为空.");
throw new RuntimeException("工作流数据为空");
}
// 从"data"中获取"status"部分,并返回"phase"的值
Map<String, Object> status = (Map<String, Object>) 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;


+ 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));

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> data = (Map<String, Object>) runResMap.get("data");
//判断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);
// 解析响应JSON
if (StringUtils.isEmpty(req)) {
throw new RuntimeException("终止响应内容为空");
throw new RuntimeException("终止响应内容为空");
}
// 将响应的JSON字符串转换为List<Map>对象
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) {
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> 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<String, String> map = new HashMap<>();
@@ -183,25 +183,25 @@ public class ImageServiceImpl implements ImageService {
List<Ray> 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<ActiveLearn> 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<DevEnvironment> 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<String> 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和创建者本身可以删除该数据集


+ 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());
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<String, String> map = new HashMap<>();
@@ -94,25 +94,25 @@ public class ImageVersionServiceImpl implements ImageVersionService {
List<Ray> 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<ActiveLearn> 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<DevEnvironment> 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<String> 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());


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

@@ -0,0 +1,259 @@
package com.ruoyi.platform.service.impl;

import com.ruoyi.platform.domain.MachineLearn;
import com.ruoyi.platform.domain.MachineLearnIns;
import com.ruoyi.platform.mapper.MachineLearnDao;
import com.ruoyi.platform.mapper.MachineLearnInsDao;
import com.ruoyi.platform.service.MachineLearnInsService;
import com.ruoyi.platform.service.ResourceOccupyService;
import com.ruoyi.platform.utils.DateUtils;
import com.ruoyi.platform.utils.HttpUtils;
import com.ruoyi.platform.utils.JsonUtils;
import com.ruoyi.system.api.constant.Constant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.*;

@Service
public class MachineLearnInsServiceImpl implements MachineLearnInsService {
@Value("${argo.url}")
private String argoUrl;
@Value("${argo.workflowStatus}")
private String argoWorkflowStatus;
@Value("${argo.workflowTermination}")
private String argoWorkflowTermination;

@Resource
private MachineLearnInsDao machineLearnInsDao;
@Resource
private MachineLearnDao machineLearnDao;
@Resource
private ResourceOccupyService resourceOccupyService;

@Override
public Page<MachineLearnIns> queryByPage(Long machineLearnId, PageRequest pageRequest) {
long count = machineLearnInsDao.count(machineLearnId);
List<MachineLearnIns> machineLearnInsList = machineLearnInsDao.queryAllByLimit(machineLearnId, pageRequest);
return new PageImpl<>(machineLearnInsList, pageRequest, count);
}

@Override
public MachineLearnIns insert(MachineLearnIns machineLearnIns) {
machineLearnInsDao.insert(machineLearnIns);
return machineLearnIns;
}

@Override
@Transactional
public String removeById(Long id) {
MachineLearnIns machineLearnIns = machineLearnInsDao.queryById(id);
if (machineLearnIns == null) {
return "实验实例不存在";
}
if (StringUtils.isEmpty(machineLearnIns.getStatus())) {
machineLearnIns = queryStatusFromArgo(machineLearnIns);
}
if (StringUtils.equals(machineLearnIns.getStatus(), Constant.Running)) {
return "实验实例正在运行,不可删除";
}
machineLearnIns.setState(Constant.State_invalid);
int update = machineLearnInsDao.update(machineLearnIns);
if (update > 0) {
resourceOccupyService.deleteTaskState(Constant.TaskType_ML, machineLearnIns.getMachineLearnId(), id);
updateMLStatus(machineLearnIns.getMachineLearnId());
return "删除成功";
} else {
return "删除失败";
}
}

@Override
public String batchDelete(List<Long> ids) {
for (Long id : ids) {
String result = removeById(id);
if (!"删除成功".equals(result)) {
return result;
}
}
return "删除成功";
}

@Override
public List<MachineLearnIns> queryNotTerminated() {
return machineLearnInsDao.queryNotTerminated();
}

@Override
public MachineLearnIns queryStatusFromArgo(MachineLearnIns ins) {
String namespace = ins.getArgoInsNs();
String name = ins.getArgoInsName();

// 创建请求数据map
Map<String, Object> requestData = new HashMap<>();
requestData.put("namespace", namespace);
requestData.put("name", name);

// 创建发送数据map,将请求数据作为"data"键的值
Map<String, Object> res = new HashMap<>();
res.put("data", requestData);

try {
// 发送POST请求到Argo工作流状态查询接口,并将请求数据转换为JSON
String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res));
// 检查响应是否为空或无内容
if (req == null || StringUtils.isEmpty(req)) {
throw new RuntimeException("工作流状态响应为空");
}
// 将响应的JSON字符串转换为Map对象
Map<String, Object> runResMap = JsonUtils.jsonToMap(req);
// 从响应Map中获取"data"部分
Map<String, Object> data = (Map<String, Object>) runResMap.get("data");
if (data == null || data.isEmpty()) {
throw new RuntimeException("工作流数据为空");
}
// 从"data"中获取"status"部分,并返回"phase"的值
Map<String, Object> status = (Map<String, Object>) data.get("status");
if (status == null || status.isEmpty()) {
throw new RuntimeException("工作流状态为空");
}
//解析流水线结束时间
String finishedAtString = (String) status.get("finishedAt");
if (finishedAtString != null && !finishedAtString.isEmpty()) {
Date finishTime = DateUtils.convertUTCtoShanghaiDate(finishedAtString);
ins.setFinishTime(finishTime);
}
// 解析nodes字段,提取节点状态并转换为JSON字符串
Map<String, Object> nodes = (Map<String, Object>) status.get("nodes");
Map<String, Object> modifiedNodes = new LinkedHashMap<>();
if (nodes != null) {
for (Map.Entry<String, Object> nodeEntry : nodes.entrySet()) {
Map<String, Object> nodeDetails = (Map<String, Object>) nodeEntry.getValue();
String templateName = (String) nodeDetails.get("displayName");
modifiedNodes.put(templateName, nodeDetails);
}
}

String nodeStatusJson = JsonUtils.mapToJson(modifiedNodes);
ins.setNodeStatus(nodeStatusJson);

//终止态为终止不改
if (!StringUtils.equals(ins.getStatus(), Constant.Terminated)) {
ins.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : Constant.Pending);
}
if (StringUtils.equals(ins.getStatus(), Constant.Error)) {
ins.setStatus(Constant.Failed);
}
return ins;
} catch (Exception e) {
throw new RuntimeException("查询状态失败: " + e.getMessage(), e);
}
}


@Override
public boolean terminateMLIns(Long id) throws Exception {
MachineLearnIns machineLearnIns = machineLearnInsDao.queryById(id);
if (machineLearnIns == null) {
throw new IllegalStateException("实验实例未查询到");
}
String currentStatus = machineLearnIns.getStatus();
String name = machineLearnIns.getArgoInsName();
String namespace = machineLearnIns.getArgoInsNs();

// 获取当前状态,如果为空,则从Argo查询
if (StringUtils.isEmpty(currentStatus)) {
currentStatus = queryStatusFromArgo(machineLearnIns).getStatus();
}
// 只有状态是"Running"时才能终止实例
if (!currentStatus.equalsIgnoreCase(Constant.Running)) {
throw new Exception("终止错误,只有运行状态的实例才能终止"); // 如果不是"Running"状态,则不执行终止操作
}

// 创建请求数据map
Map<String, Object> requestData = new HashMap<>();
requestData.put("namespace", namespace);
requestData.put("name", name);
// 创建发送数据map,将请求数据作为"data"键的值
Map<String, Object> res = new HashMap<>();
res.put("data", requestData);

try {
// 发送POST请求到Argo工作流状态查询接口,并将请求数据转换为JSON
String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res));
// 检查响应是否为空或无内容
if (StringUtils.isEmpty(req)) {
throw new RuntimeException("终止响应内容为空");

}
// 将响应的JSON字符串转换为Map对象
Map<String, Object> runResMap = JsonUtils.jsonToMap(req);
// 从响应Map中直接获取"errCode"的值
Integer errCode = (Integer) runResMap.get("errCode");
if (errCode != null && errCode == 0) {
MachineLearnIns ins = queryStatusFromArgo(machineLearnIns);
String nodeStatus = ins.getNodeStatus();
Map<String, Object> nodeMap = JsonUtils.jsonToMap(nodeStatus);

// 遍历 map
for (Map.Entry<String, Object> entry : nodeMap.entrySet()) {
// 获取每个 Map 中的值并强制转换为 Map
Map<String, Object> innerMap = (Map<String, Object>) entry.getValue();
// 检查 phase 的值
if (innerMap.containsKey("phase")) {
String phaseValue = (String) innerMap.get("phase");
// 如果值不等于 Succeeded,则赋值为 Failed
if (!StringUtils.equals(Constant.Succeeded, phaseValue)) {
innerMap.put("phase", Constant.Failed);
}
}
}
ins.setNodeStatus(JsonUtils.mapToJson(nodeMap));
ins.setStatus(Constant.Terminated);
ins.setUpdateTime(new Date());
ins.setFinishTime(new Date());
machineLearnInsDao.update(ins);
updateMLStatus(ins.getMachineLearnId());
// 结束扣积分
resourceOccupyService.endDeduce(Constant.TaskType_ML, null, id, null, null);
return true;
} else {
return false;
}
} catch (Exception e) {
throw new RuntimeException("终止实例错误: " + e.getMessage(), e);
}
}

@Override
public MachineLearnIns getDetailById(Long id) {
MachineLearnIns machineLearnIns = machineLearnInsDao.queryById(id);
if (Constant.Running.equals(machineLearnIns.getStatus()) || Constant.Pending.equals(machineLearnIns.getStatus())) {
machineLearnIns = queryStatusFromArgo(machineLearnIns);
}
return machineLearnIns;
}

@Override
public void updateMLStatus(Long machineLearnId) {
List<MachineLearnIns> insList = machineLearnInsDao.getByMachineLearnId(machineLearnId);
List<String> statusList = new ArrayList<>();
// 更新实验状态列表
for (int i = 0; i < insList.size(); i++) {
statusList.add(insList.get(i).getStatus());
}
String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1);
MachineLearn machineLearn = machineLearnDao.getMachineLearnById(machineLearnId);

if (!StringUtils.equals(machineLearn.getStatusList(), subStatus)) {
machineLearn.setStatusList(subStatus);
machineLearnDao.edit(machineLearn);
}
}
}

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

@@ -0,0 +1,220 @@
package com.ruoyi.platform.service.impl;

import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.platform.domain.MachineLearn;
import com.ruoyi.platform.domain.MachineLearnIns;
import com.ruoyi.platform.mapper.MachineLearnDao;
import com.ruoyi.platform.mapper.MachineLearnInsDao;
import com.ruoyi.platform.service.MachineLearnInsService;
import com.ruoyi.platform.service.MachineLearnService;
import com.ruoyi.platform.service.ResourceOccupyService;
import com.ruoyi.platform.utils.HttpUtils;
import com.ruoyi.platform.utils.JsonUtils;
import com.ruoyi.platform.vo.AutoMlParamVo;
import com.ruoyi.platform.vo.TextClassificationParamVo;
import com.ruoyi.system.api.constant.Constant;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class MachineLearnServiceImpl implements MachineLearnService {
@Value("${argo.url}")
private String argoUrl;
@Value("${argo.convertAutoML}")
String convertAutoML;
@Value("${argo.convertTextClassification}")
String convertTextClassification;
@Value("${argo.workflowRun}")
private String argoWorkflowRun;
@Value("${minio.endpointIp}")
private String minioEndpoint;

@Resource
private MachineLearnDao machineLearnDao;
@Resource
private MachineLearnInsDao machineLearnInsDao;
@Resource
private ResourceOccupyService resourceOccupyService;
@Autowired
private MachineLearnInsService machineLearnInsService;

@Override
public Page<MachineLearn> queryByPage(String name, String type, PageRequest pageRequest) {
long total = machineLearnDao.count(name, type);
List<MachineLearn> autoMls = machineLearnDao.queryByPage(name, type, pageRequest);
return new PageImpl<>(autoMls, pageRequest, total);
}

@Override
public MachineLearn add(MachineLearn machineLearn) {
if (machineLearn.getName().length() >= 64) {
throw new RuntimeException("实验名称大于最大长度");
}
MachineLearn machineLearnByName = machineLearnDao.getMachineLearnByName(machineLearn.getName());
if (machineLearnByName != null) {
throw new RuntimeException("实验名称已存在");
}
String username = SecurityUtils.getLoginUser().getUsername();
machineLearn.setCreateBy(username);
machineLearn.setUpdateBy(username);
machineLearnDao.save(machineLearn);
return machineLearn;
}

@Override
public String edit(MachineLearn machineLearn) {
MachineLearn machineLearnByName = machineLearnDao.getMachineLearnByName(machineLearn.getName());
if (machineLearnByName != null && !machineLearnByName.getId().equals(machineLearn.getId())) {
throw new RuntimeException("实验名称已存在");
}
machineLearn.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
machineLearnDao.edit(machineLearn);
return "修改成功";
}

@Override
public MachineLearn getMLDetail(Long id) {
return machineLearnDao.getMachineLearnById(id);
}

@Override
@Transactional
public String delete(Long id) {
MachineLearn machineLearn = machineLearnDao.getMachineLearnById(id);
if (machineLearn == null) {
throw new RuntimeException("实验不存在");
}
String username = SecurityUtils.getLoginUser().getUsername();
String createBy = machineLearn.getCreateBy();
if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) {
throw new RuntimeException("无权限删除该实验");
}
machineLearn.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
machineLearn.setState(Constant.State_invalid);
resourceOccupyService.deleteTaskState(Constant.TaskType_ML, id, null);
return machineLearnDao.edit(machineLearn) > 0 ? "删除成功" : "删除失败";
}

@Override
@Transactional
public String runMachineLearn(Long id) throws Exception {
MachineLearn machineLearn = machineLearnDao.getMachineLearnById(id);
if (machineLearn == null) {
throw new Exception("自动机器学习配置不存在");
}
// 调argo转换接口
try {
String convertRes = null;
String param = null;
String modelType = null;
String taskType = null;
Integer seed = null;
Integer computingResourceId = null;
switch (machineLearn.getType()) {
case Constant.ML_CSV: {
AutoMlParamVo paramVo = JsonUtils.jsonToObject(machineLearn.getParam(), AutoMlParamVo.class);
taskType = paramVo.getTaskType();
seed = paramVo.getSeed();
param = JsonUtils.objectToJson(paramVo);
convertRes = HttpUtils.sendPost(argoUrl + convertAutoML, param);
break;
}
case Constant.ML_TextClassification: {
TextClassificationParamVo paramVo = JsonUtils.jsonToObject(machineLearn.getParam(), TextClassificationParamVo.class);
modelType = paramVo.getModelType();
computingResourceId = paramVo.getComputingResourceId();
if (resourceOccupyService.haveResource(computingResourceId, 1)) {
param = JsonUtils.getConvertParam(paramVo);
convertRes = HttpUtils.sendPost(argoUrl + convertTextClassification, param);
}
break;
}
case Constant.ML_VideoClassification: {
// todo
break;
}
}

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");
// 插入记录到实验实例表
MachineLearnIns machineLearnIns = new MachineLearnIns();
machineLearnIns.setMachineLearnId(id);
machineLearnIns.setType(machineLearn.getType());
machineLearnIns.setArgoInsNs((String) metadata.get("namespace"));
machineLearnIns.setArgoInsName((String) metadata.get("name"));
machineLearnIns.setParam(param);
machineLearnIns.setStatus(Constant.Pending);
//替换argoInsName
String outputString = JsonUtils.mapToJson(output);
machineLearnIns.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")) + "/";

switch (machineLearn.getType()) {
case Constant.ML_CSV: {
machineLearnIns.setModelPath(outputPath + "save_model.joblib");
if (Constant.AutoMl_Classification.equals(taskType)) {
machineLearnIns.setImgPath(outputPath + "Auto-sklearn_metric_over_time.png" + "," + outputPath + "Train_Confusion_Matrix.png" + "," + outputPath + "Test_Confusion_Matrix.png");
} else {
machineLearnIns.setImgPath(outputPath + "Auto-sklearn_metric_over_time.png" + "," + outputPath + "regression.png");
}
machineLearnIns.setResultPath(outputPath + "result.txt");
String seedStr = seed != null ? String.valueOf(seed) : "1";
machineLearnIns.setRunHistoryPath(outputPath + "smac3-output/run_" + seedStr + "/runhistory.json");
break;
}
case Constant.ML_TextClassification: {
machineLearnIns.setModelPath(outputPath + "/saved_dict/" + modelType + ".ckpt");
break;
}
case Constant.ML_VideoClassification: {
break;
}
}
machineLearnInsDao.insert(machineLearnIns);
machineLearnInsService.updateMLStatus(id);
if (computingResourceId != null) {
// 记录开始扣除积分
resourceOccupyService.startDeduce(computingResourceId, 1, Constant.TaskType_ML, id, machineLearnIns.getId(), null, machineLearn.getName(), null, null);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return "执行成功";
}
}

+ 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) {
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> 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<String, String> queryMap = new HashMap<>();
@@ -1169,25 +1169,25 @@ public class ModelsServiceImpl implements ModelsService {
List<Ray> 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<ActiveLearn> 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<DevEnvironment> 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<String> 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> 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<String, String> queryMap = new HashMap<>();
@@ -1219,25 +1219,25 @@ public class ModelsServiceImpl implements ModelsService {
List<Ray> 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<ActiveLearn> 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<DevEnvironment> 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<String> 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();


+ 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) {
int currentState = modelsVersion.getState();
if(currentState == 0){
throw new RuntimeException("模型版本已被删除,无法更新");
throw new RuntimeException("模型版本已被删除,无法更新");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
modelsVersion.setUpdateBy(loginUser.getUsername());


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

@@ -51,7 +51,7 @@ public class NewDatasetServiceImpl implements NewDatasetService {
@Resource
private AssetWorkflowDao assetWorkflowDao;
@Resource
private AutoMlDao autoMlDao;
private MachineLearnDao machineLearnDao;
@Resource
private RayDao rayDao;
@Resource
@@ -415,33 +415,37 @@ public class NewDatasetServiceImpl implements NewDatasetService {
List<AssetWorkflow> 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<String, String> map = new HashMap<>();
map.put("id", String.valueOf(repoId));
List<AutoMl> 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 + "使用,不能删除,请先删除自动机器学习。");

HashMap<Object, Object> mLQueryMap = new HashMap<>();
mLQueryMap.put("dataset", map);
List<MachineLearn> machineLearnList = machineLearnDao.queryByDatasetId(JSON.toJSONString(mLQueryMap));

if (machineLearnList != null && !machineLearnList.isEmpty()) {
String autoMls = String.join(",", machineLearnList.stream().map(MachineLearn::getName).collect(Collectors.toSet()));
throw new Exception("该数据集被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习");
}

List<Ray> 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<ActiveLearn> 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<DevEnvironment> 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,34 +461,38 @@ public class NewDatasetServiceImpl implements NewDatasetService {
List<AssetWorkflow> 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<String, String> map = new HashMap<>();
map.put("id", String.valueOf(repoId));
map.put("version", version);
List<AutoMl> 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 + "使用,不能删除,请先删除自动机器学习。");

HashMap<Object, Object> mLQueryMap = new HashMap<>();
mLQueryMap.put("dataset", map);
List<MachineLearn> machineLearnList = machineLearnDao.queryByDatasetId(JSON.toJSONString(mLQueryMap));

if (machineLearnList != null && !machineLearnList.isEmpty()) {
String autoMls = String.join(",", machineLearnList.stream().map(MachineLearn::getName).collect(Collectors.toSet()));
throw new Exception("该数据集版本被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习");
}

List<Ray> 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<ActiveLearn> 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<DevEnvironment> 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();


+ 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));
// 检查响应是否为空或无内容
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<String, Object> runResMap = JsonUtils.jsonToMap(req);
// 从响应Map中获取"data"部分
Map<String, Object> data = (Map<String, Object>) runResMap.get("data");
if (data == null || data.isEmpty()) {
throw new RuntimeException("工作流数据为空.");
throw new RuntimeException("工作流数据为空");
}
// 从"data"中获取"status"部分,并返回"phase"的值
Map<String, Object> status = (Map<String, Object>) data.get("status");
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
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();


+ 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);
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();


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

@@ -0,0 +1,259 @@
package com.ruoyi.platform.service.impl;

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.ResourceOccupyService;
import com.ruoyi.platform.service.TextClassificationInsService;
import com.ruoyi.platform.utils.DateUtils;
import com.ruoyi.platform.utils.HttpUtils;
import com.ruoyi.platform.utils.JsonUtils;
import com.ruoyi.system.api.constant.Constant;
import org.apache.commons.lang3.StringUtils;
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 org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.*;

@Service
public class TextClassificationInsServiceImpl implements TextClassificationInsService {
@Value("${argo.url}")
private String argoUrl;
@Value("${argo.workflowStatus}")
private String argoWorkflowStatus;
@Value("${argo.workflowTermination}")
private String argoWorkflowTermination;

@Resource
private TextClassificationDao textClassificationDao;
@Resource
private TextClassificationInsDao textClassificationInsDao;
@Resource
private ResourceOccupyService resourceOccupyService;

@Override
public Page<TextClassificationIns> queryByPage(TextClassificationIns textClassificationIns, PageRequest pageRequest) {
long total = this.textClassificationInsDao.count(textClassificationIns);
List<TextClassificationIns> textClassificationInsList = this.textClassificationInsDao.queryAllByLimit(textClassificationIns, pageRequest);
return new PageImpl<>(textClassificationInsList, pageRequest, total);
}

@Override
public TextClassificationIns insert(TextClassificationIns textClassificationIns) {
this.textClassificationInsDao.insert(textClassificationIns);
return textClassificationIns;
}

@Override
@Transactional
public String removeById(Long id) {
TextClassificationIns textClassificationIns = textClassificationInsDao.queryById(id);
if (textClassificationIns == null) {
return "实验实例不存在";
}
if (StringUtils.isEmpty(textClassificationIns.getStatus())) {
textClassificationIns = queryStatusFromArgo(textClassificationIns);
}
if (StringUtils.equals(textClassificationIns.getStatus(), Constant.Running)) {
return "实验实例正在运行,不可删除";
}
textClassificationIns.setState(Constant.State_invalid);
int update = textClassificationInsDao.update(textClassificationIns);
if (update > 0) {
resourceOccupyService.deleteTaskState(Constant.TaskType_TextClassification, textClassificationIns.getTextClassificationId(), id);
updateTextClassificationStatus(textClassificationIns.getTextClassificationId());
return "删除成功";
} else {
return "删除失败";
}
}

@Override
public String batchDelete(List<Long> ids) {
for (Long id : ids) {
String result = removeById(id);
if (!"删除成功".equals(result)) {
return result;
}
}
return "删除成功";
}

@Override
public boolean terminateTextClassificationIns(Long id) throws Exception {
TextClassificationIns textClassificationIns = textClassificationInsDao.queryById(id);
if (textClassificationIns == null) {
throw new IllegalStateException("实验实例未查询到,id: " + id);
}
String currentStatus = textClassificationIns.getStatus();
String name = textClassificationIns.getArgoInsName();
String namespace = textClassificationIns.getArgoInsNs();

// 获取当前状态,如果为空,则从Argo查询
if (StringUtils.isEmpty(currentStatus)) {
currentStatus = queryStatusFromArgo(textClassificationIns).getStatus();
}
// 只有状态是"Running"时才能终止实例
if (!currentStatus.equalsIgnoreCase(Constant.Running)) {
throw new Exception("终止错误,只有运行状态的实例才能终止"); // 如果不是"Running"状态,则不执行终止操作
}

// 创建请求数据map
Map<String, Object> requestData = new HashMap<>();
requestData.put("namespace", namespace);
requestData.put("name", name);
// 创建发送数据map,将请求数据作为"data"键的值
Map<String, Object> res = new HashMap<>();
res.put("data", requestData);

try {
// 发送POST请求到Argo工作流状态查询接口,并将请求数据转换为JSON
String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res));
// 检查响应是否为空或无内容
if (StringUtils.isEmpty(req)) {
throw new RuntimeException("终止响应内容为空");

}
// 将响应的JSON字符串转换为Map对象
Map<String, Object> runResMap = JsonUtils.jsonToMap(req);
// 从响应Map中直接获取"errCode"的值
Integer errCode = (Integer) runResMap.get("errCode");
if (errCode != null && errCode == 0) {
//更新autoMlIns,确保状态更新被保存到数据库
TextClassificationIns ins = queryStatusFromArgo(textClassificationIns);
String nodeStatus = ins.getNodeStatus();
Map<String, Object> nodeMap = JsonUtils.jsonToMap(nodeStatus);

// 遍历 map
for (Map.Entry<String, Object> entry : nodeMap.entrySet()) {
// 获取每个 Map 中的值并强制转换为 Map
Map<String, Object> innerMap = (Map<String, Object>) entry.getValue();
// 检查 phase 的值
if (innerMap.containsKey("phase")) {
String phaseValue = (String) innerMap.get("phase");
// 如果值不等于 Succeeded,则赋值为 Failed
if (!StringUtils.equals(Constant.Succeeded, phaseValue)) {
innerMap.put("phase", Constant.Failed);
}
}
}
ins.setNodeStatus(JsonUtils.mapToJson(nodeMap));
ins.setStatus(Constant.Terminated);
ins.setUpdateTime(new Date());
ins.setFinishTime(new Date());
this.textClassificationInsDao.update(ins);
updateTextClassificationStatus(textClassificationIns.getTextClassificationId());
// 结束扣积分
resourceOccupyService.endDeduce(Constant.TaskType_TextClassification, null, id, null, null);
return true;
} else {
return false;
}
} catch (Exception e) {
throw new RuntimeException("终止实例错误: " + e.getMessage(), e);
}
}

@Override
public TextClassificationIns getDetailById(Long id) {
TextClassificationIns textClassificationIns = textClassificationInsDao.queryById(id);
if (Constant.Running.equals(textClassificationIns.getStatus()) || Constant.Pending.equals(textClassificationIns.getStatus())) {
textClassificationIns = queryStatusFromArgo(textClassificationIns);
}
return textClassificationIns;
}

@Override
public List<TextClassificationIns> queryByNotTerminated() {
return textClassificationInsDao.queryByNotTerminated();
}

@Override
public TextClassificationIns queryStatusFromArgo(TextClassificationIns ins) {
String namespace = ins.getArgoInsNs();
String name = ins.getArgoInsName();

// 创建请求数据map
Map<String, Object> requestData = new HashMap<>();
requestData.put("namespace", namespace);
requestData.put("name", name);

// 创建发送数据map,将请求数据作为"data"键的值
Map<String, Object> res = new HashMap<>();
res.put("data", requestData);

try {
// 发送POST请求到Argo工作流状态查询接口,并将请求数据转换为JSON
String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res));
// 检查响应是否为空或无内容
if (req == null || StringUtils.isEmpty(req)) {
throw new RuntimeException("工作流状态响应为空");
}
// 将响应的JSON字符串转换为Map对象
Map<String, Object> runResMap = JsonUtils.jsonToMap(req);
// 从响应Map中获取"data"部分
Map<String, Object> data = (Map<String, Object>) runResMap.get("data");
if (data == null || data.isEmpty()) {
throw new RuntimeException("工作流数据为空");
}
// 从"data"中获取"status"部分,并返回"phase"的值
Map<String, Object> status = (Map<String, Object>) data.get("status");
if (status == null || status.isEmpty()) {
throw new RuntimeException("工作流状态为空");
}
//解析流水线结束时间
String finishedAtString = (String) status.get("finishedAt");
if (finishedAtString != null && !finishedAtString.isEmpty()) {
Date finishTime = DateUtils.convertUTCtoShanghaiDate(finishedAtString);
ins.setFinishTime(finishTime);
}
// 解析nodes字段,提取节点状态并转换为JSON字符串
Map<String, Object> nodes = (Map<String, Object>) status.get("nodes");
Map<String, Object> modifiedNodes = new LinkedHashMap<>();
if (nodes != null) {
for (Map.Entry<String, Object> nodeEntry : nodes.entrySet()) {
Map<String, Object> nodeDetails = (Map<String, Object>) nodeEntry.getValue();
String templateName = (String) nodeDetails.get("displayName");
modifiedNodes.put(templateName, nodeDetails);
}
}

String nodeStatusJson = JsonUtils.mapToJson(modifiedNodes);
ins.setNodeStatus(nodeStatusJson);

//终止态为终止不改
if (!StringUtils.equals(ins.getStatus(), Constant.Terminated)) {
ins.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : Constant.Pending);
}
if (StringUtils.equals(ins.getStatus(), Constant.Error)) {
ins.setStatus(Constant.Failed);
}
return ins;
} catch (Exception e) {
throw new RuntimeException("查询状态失败: " + e.getMessage(), e);
}
}

@Override
public void updateTextClassificationStatus(Long textClassificationId) {
List<TextClassificationIns> insList = textClassificationInsDao.getByTextClassificationId(textClassificationId);
List<String> statusList = new ArrayList<>();
// 更新实验状态列表
for (int i = 0; i < insList.size(); i++) {
statusList.add(insList.get(i).getStatus());
}
String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1);
TextClassification textClassification = textClassificationDao.getById(textClassificationId);

if (!StringUtils.equals(textClassification.getStatusList(), subStatus)) {
textClassification.setStatusList(subStatus);
textClassificationDao.edit(textClassification);
}
}
}

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

@@ -0,0 +1,191 @@
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.ResourceOccupyService;
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 org.springframework.transaction.annotation.Transactional;

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;
@Resource
private ResourceOccupyService resourceOccupyService;

@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
@Transactional
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);
resourceOccupyService.deleteTaskState(Constant.TaskType_TextClassification, id, null);
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("文本分类配置不存在");
}

// 记录开始扣积分
if (resourceOccupyService.haveResource(textClassification.getComputingResourceId(), 1)) {
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.getModelType() + ".ckpt");
textClassificationInsDao.insert(textClassificationIns);
textClassificationInsService.updateTextClassificationStatus(id);
// 记录开始扣除积分
resourceOccupyService.startDeduce(textClassification.getComputingResourceId(), 1, Constant.TaskType_TextClassification, id, textClassificationIns.getId(), null, textClassification.getName(), null, null);
} 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"的值,也就是日志的值
String newDag = (String) runResMap.get("data");
if (newDag == null) {
throw new RuntimeException("响应内容为空");
throw new RuntimeException("响应内容为空");
}
duplicateWorkflow.setDag(newDag);
duplicateWorkflow.setDescription(workflow.getDescription());


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

@@ -0,0 +1,33 @@
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 modelType;

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

+ 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 modelType;

@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"?>
<!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">
<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,
per_run_time_limit, ensemble_size, ensemble_class, ensemble_nbest, max_models_on_disc, seed,
memory_limit,
@@ -37,9 +37,6 @@
<if test="autoMl.statusList != null and autoMl.statusList !=''">
status_list = #{autoMl.statusList},
</if>
<!-- <if test="autoMl.progress != null">-->
<!-- progress = #{autoMl.progress},-->
<!-- </if>-->
<if test="autoMl.taskType != null and autoMl.taskType !=''">
task_type = #{autoMl.taskType},
</if>


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

@@ -0,0 +1,82 @@
<?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.MachineLearnDao">

<select id="count" resultType="java.lang.Long">
select count(1) from machine_learn
<include refid="common_condition"></include>
</select>

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

<insert id="save" keyProperty="id" useGeneratedKeys="true">
insert into machine_learn(name, description, type, param, create_by, update_by)
values (#{machineLearn.name}, #{machineLearn.description}, #{machineLearn.type},
#{machineLearn.param}, #{machineLearn.createBy}, #{machineLearn.updateBy})
</insert>

<update id="edit">
update machine_learn
<set>
<if test="machineLearn.name != null and machineLearn.name !=''">
name = #{machineLearn.name},
</if>
<if test="machineLearn.description != null and machineLearn.description !=''">
description = #{machineLearn.description},
</if>
<if test="machineLearn.type != null and machineLearn.type !=''">
type = #{machineLearn.type},
</if>
<if test="machineLearn.param != null and machineLearn.param !=''">
param = #{machineLearn.param},
</if>
<if test="machineLearn.statusList != null and machineLearn.statusList !=''">
status_list = #{machineLearn.statusList},
</if>
<if test="machineLearn.state != null">
state = #{machineLearn.state},
</if>
<if test="machineLearn.updateBy != null and machineLearn.updateBy !=''">
update_by = #{machineLearn.updateBy},
</if>
</set>
where id = #{machineLearn.id}
</update>


<select id="getMachineLearnById" resultType="com.ruoyi.platform.domain.MachineLearn">
select *
from machine_learn
where id = #{id}
</select>

<select id="getMachineLearnByName" resultType="com.ruoyi.platform.domain.MachineLearn">
select *
from machine_learn
where name = #{name}
and state = 1
</select>

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

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

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

@@ -0,0 +1,83 @@
<?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.MachineLearnInsDao">
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into machine_learn_ins(machine_learn_id, type, result_path, model_path, img_path, run_history_path, node_status,
node_result, param, argo_ins_name, argo_ins_ns, status)
values (#{machineLearnIns.machineLearnId}, #{machineLearnIns.type}, #{machineLearnIns.resultPath}, #{machineLearnIns.modelPath}, #{machineLearnIns.imgPath},
#{machineLearnIns.runHistoryPath}, #{machineLearnIns.nodeStatus},
#{machineLearnIns.nodeResult}, #{machineLearnIns.param},#{machineLearnIns.argoInsName},
#{machineLearnIns.argoInsNs}, #{machineLearnIns.status}
)
</insert>

<update id="update">
update machine_learn_ins
<set>
<if test="machineLearnIns.type != null and machineLearnIns.type != ''">
type = #{machineLearnIns.type},
</if>
<if test="machineLearnIns.status != null and machineLearnIns.status != ''">
status = #{machineLearnIns.status},
</if>
<if test="machineLearnIns.state != null">
state = #{machineLearnIns.state},
</if>
<if test="machineLearnIns.updateTime != null">
update_time = #{machineLearnIns.updateTime},
</if>
<if test="machineLearnIns.finishTime != null">
finish_time = #{machineLearnIns.finishTime},
</if>
<if test="machineLearnIns.nodeStatus != null and machineLearnIns.nodeStatus != ''">
node_status = #{machineLearnIns.nodeStatus},
</if>
<if test="machineLearnIns.nodeResult != null and machineLearnIns.nodeResult != ''">
node_result = #{machineLearnIns.nodeResult},
</if>
</set>
where id = #{machineLearnIns.id}
</update>

<select id="count" resultType="java.lang.Long">
select count(1)
from machine_learn_ins
<where>
state = 1
and machine_learn_id = #{machineLearnId}
</where>
</select>

<select id="queryAllByLimit" resultType="com.ruoyi.platform.domain.MachineLearnIns">
select * from machine_learn_ins
<where>
state = 1
and machine_learn_id = #{machineLearnId}
</where>
order by update_time DESC
limit #{pageable.offset}, #{pageable.pageSize}
</select>

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

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

<select id="getByMachineLearnId" resultType="com.ruoyi.platform.domain.MachineLearnIns">
select *
from machine_learn_ins
where machine_learn_id = #{machineLearnId}
and state = 1
order by update_time DESC limit 5
</select>
</mapper>

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

@@ -0,0 +1,90 @@
<?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_type, dataset, epochs, batch_size, lr, create_by, update_by, computing_resource_id)
values (#{textClassification.name}, #{textClassification.description}, #{textClassification.modelType},
#{textClassification.dataset}, #{textClassification.epochs}, #{textClassification.batchSize},
#{textClassification.lr}, #{textClassification.createBy}, #{textClassification.updateBy}, #{textClassification.computingResourceId})
</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.modelType != null and textClassification.modelType !=''">
model_type = #{textClassification.modelType},
</if>
<if test="textClassification.dataset != null and textClassification.dataset !=''">
dataset = #{textClassification.dataset},
</if>
<if test="textClassification.computingResourceId != null">
computing_resource_id = #{textClassification.computingResourceId},
</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="queryByNotTerminated" 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