Browse Source

优化主动学习,优化数据资产删除判断

dev-active_learn
chenzhihang 11 months ago
parent
commit
01c1eab5ad
48 changed files with 912 additions and 240 deletions
  1. +4
    -0
      ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/Constant.java
  2. +8
    -8
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnController.java
  3. +12
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java
  4. +1
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/image/ImageController.java
  5. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/ray/RayController.java
  6. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/service/ServiceController.java
  7. +15
    -8
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ActiveLearn.java
  8. +10
    -9
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ActiveLearnIns.java
  9. +5
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ResourceOccupy.java
  10. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ActiveLearnDao.java
  11. +4
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ActiveLearnInsDao.java
  12. +6
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/DevEnvironmentDao.java
  13. +2
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ResourceOccupyDao.java
  14. +6
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ServiceDao.java
  15. +116
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ActiveLearnInsStatusTask.java
  16. +10
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnInsService.java
  17. +4
    -5
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnService.java
  18. +1
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/RayInsService.java
  19. +2
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ResourceOccupyService.java
  20. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ServiceService.java
  21. +171
    -19
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java
  22. +103
    -31
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java
  23. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlInsServiceImpl.java
  24. +11
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java
  25. +13
    -11
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DevEnvironmentServiceImpl.java
  26. +5
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java
  27. +4
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java
  28. +26
    -5
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java
  29. +25
    -3
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageVersionServiceImpl.java
  30. +42
    -3
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java
  31. +15
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java
  32. +5
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayInsServiceImpl.java
  33. +5
    -3
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java
  34. +5
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ResourceOccupyServiceImpl.java
  35. +15
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java
  36. +5
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java
  37. +65
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ActiveLearnParamVo.java
  38. +19
    -12
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ActiveLearnVo.java
  39. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/DevEnvironmentVo.java
  40. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ImageVo.java
  41. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/serviceVos/ServiceVersionVo.java
  42. +50
    -39
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnDaoMapper.xml
  43. +44
    -30
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnInsDaoMapper.xml
  44. +1
    -3
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml
  45. +21
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/DevEnvironmentDaoMapper.xml
  46. +3
    -2
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/RayDaoMapper.xml
  47. +11
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ResourceOccupy.xml
  48. +30
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ServiceDaoMapper.xml

+ 4
- 0
ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/Constant.java View File

@@ -39,6 +39,10 @@ public class Constant {
public final static String Init = "Init"; public final static String Init = "Init";
public final static String Stopped = "Stopped"; public final static String Stopped = "Stopped";
public final static String Succeeded = "Succeeded"; public final static String Succeeded = "Succeeded";
public final static String Error = "Error";

public final static String Unknown = "Unknown";
public final static String Available = "available";


public final static String Type_Train = "train"; public final static String Type_Train = "train";
public final static String Type_Evaluate = "evaluate"; public final static String Type_Evaluate = "evaluate";


+ 8
- 8
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnController.java View File

@@ -7,9 +7,9 @@ import com.ruoyi.platform.service.ActiveLearnService;
import com.ruoyi.platform.vo.ActiveLearnVo; import com.ruoyi.platform.vo.ActiveLearnVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
@@ -17,29 +17,29 @@ import java.io.IOException;
@RestController @RestController
@RequestMapping("activeLearn") @RequestMapping("activeLearn")
@Api("主动学习") @Api("主动学习")
public class ActiveLearnController extends BaseController {

public class ActiveLearnController extends BaseController {
@Resource @Resource
private ActiveLearnService activeLearnService; private ActiveLearnService activeLearnService;


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


@PostMapping @PostMapping
@ApiOperation("新增主动学习") @ApiOperation("新增主动学习")
public GenericsAjaxResult<ActiveLearn> addActiveLearn(@RequestBody ActiveLearnVo activeLearnServiceVo) {
return genericsSuccess(this.activeLearnService.save(activeLearnServiceVo));
public GenericsAjaxResult<ActiveLearn> addActiveLearn(@RequestBody ActiveLearnVo activeLearnVo) throws Exception {
return genericsSuccess(this.activeLearnService.save(activeLearnVo));
} }


@PutMapping @PutMapping
@ApiOperation("编辑主动学习") @ApiOperation("编辑主动学习")
public GenericsAjaxResult<String> editActiveLearn(@RequestBody ActiveLearnVo activeLearnServiceVo) {
return genericsSuccess(this.activeLearnService.edit(activeLearnServiceVo));
public GenericsAjaxResult<String> editActiveLearn(@RequestBody ActiveLearnVo activeLearnVo) throws Exception {
return genericsSuccess(this.activeLearnService.edit(activeLearnVo));
} }


@GetMapping("/getActiveLearnDetail") @GetMapping("/getActiveLearnDetail")


+ 12
- 6
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java View File

@@ -6,9 +6,9 @@ import com.ruoyi.platform.domain.ActiveLearnIns;
import com.ruoyi.platform.service.ActiveLearnInsService; import com.ruoyi.platform.service.ActiveLearnInsService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
@@ -23,15 +23,21 @@ public class ActiveLearnInsController extends BaseController {


@GetMapping @GetMapping
@ApiOperation("分页查询") @ApiOperation("分页查询")
public GenericsAjaxResult<Page<ActiveLearnIns>> queryByPage(ActiveLearnIns activeLearnIns, int page, int size) throws IOException {
public GenericsAjaxResult<Page<ActiveLearnIns>> queryByPage(Long activeLearnId, int page, int size) throws IOException {
PageRequest pageRequest = PageRequest.of(page, size); PageRequest pageRequest = PageRequest.of(page, size);
return genericsSuccess(this.activeLearnInsService.queryByPage(activeLearnIns, pageRequest));
return genericsSuccess(this.activeLearnInsService.queryByPage(activeLearnId, pageRequest));
}

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


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


@DeleteMapping("batchDelete") @DeleteMapping("batchDelete")
@@ -42,13 +48,13 @@ public class ActiveLearnInsController extends BaseController {


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


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

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

@@ -115,6 +115,7 @@ public class ImageController extends BaseController {
* @return 删除是否成功 * @return 删除是否成功
*/ */
@DeleteMapping("{id}") @DeleteMapping("{id}")
@ApiOperation("删除镜像")
public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) throws Exception { public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) throws Exception {
return genericsSuccess(this.imageService.removeById(id)); return genericsSuccess(this.imageService.removeById(id));
} }


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/ray/RayController.java View File

@@ -50,7 +50,7 @@ public class RayController extends BaseController {


@DeleteMapping("{id}") @DeleteMapping("{id}")
@ApiOperation("删除自动超参数寻优") @ApiOperation("删除自动超参数寻优")
public GenericsAjaxResult<String> deleteRay(@PathVariable("id") Long id) {
public GenericsAjaxResult<String> deleteRay(@PathVariable("id") Long id) {
return genericsSuccess(this.rayService.delete(id)); return genericsSuccess(this.rayService.delete(id));
} }




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

@@ -85,13 +85,13 @@ public class ServiceController extends BaseController {


@GetMapping("/serviceVersionDetail/{id}") @GetMapping("/serviceVersionDetail/{id}")
@ApiOperation("查询服务版本详细信息") @ApiOperation("查询服务版本详细信息")
public GenericsAjaxResult<ServiceVersionVo> getServiceVersion(@PathVariable("id") Long id) {
public GenericsAjaxResult<ServiceVersionVo> getServiceVersion(@PathVariable("id") Long id) throws IOException {
return genericsSuccess(serviceService.getServiceVersion(id)); return genericsSuccess(serviceService.getServiceVersion(id));
} }


@GetMapping("serviceVersionCompare") @GetMapping("serviceVersionCompare")
@ApiOperation("服务版本版本对比") @ApiOperation("服务版本版本对比")
public GenericsAjaxResult<Map<String, Object>> serviceVersionCompare(@RequestParam("id1") Long id1, @RequestParam("id2") Long id2) throws IllegalAccessException {
public GenericsAjaxResult<Map<String, Object>> serviceVersionCompare(@RequestParam("id1") Long id1, @RequestParam("id2") Long id2) throws IllegalAccessException, IOException {
return genericsSuccess(serviceService.serviceVersionCompare(id1, id2)); return genericsSuccess(serviceService.serviceVersionCompare(id1, id2));
} }




+ 15
- 8
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ActiveLearn.java View File

@@ -20,10 +20,16 @@ public class ActiveLearn {
@ApiModelProperty(value = "实验描述") @ApiModelProperty(value = "实验描述")
private String description; private String description;


@ApiModelProperty(value = "任务类型:classification, regression")
@ApiModelProperty(value = "任务类型:classification或regression")
private String taskType; private String taskType;


@ApiModelProperty(value = "预训练模型")
@ApiModelProperty(value = "框架类型: sklearn, keras, pytorch")
private String frameworkType;

@ApiModelProperty(value = "代码配置")
private String codeConfig;

@ApiModelProperty(value = "预训练的模型")
private String model; private String model;


@ApiModelProperty(value = "模型文件路径") @ApiModelProperty(value = "模型文件路径")
@@ -38,13 +44,13 @@ public class ActiveLearn {
@ApiModelProperty(value = "回归算法") @ApiModelProperty(value = "回归算法")
private String regressorAlg; private String regressorAlg;


@ApiModelProperty(value = "dataset文件路径")
@ApiModelProperty(value = "dataset处理文件路径")
private String datasetPy; private String datasetPy;


@ApiModelProperty(value = "dataset类名") @ApiModelProperty(value = "dataset类名")
private String datasetClassName; private String datasetClassName;


@ApiModelProperty(value = "数据集文件路径")
@ApiModelProperty(value = "数据集")
private String dataset; private String dataset;


@ApiModelProperty(value = "数据量") @ApiModelProperty(value = "数据量")
@@ -53,6 +59,7 @@ public class ActiveLearn {
@ApiModelProperty(value = "镜像") @ApiModelProperty(value = "镜像")
private String image; private String image;


@ApiModelProperty(value = "计算资源id")
private Integer computingResourceId; private Integer computingResourceId;


@ApiModelProperty(value = "是否随机打乱") @ApiModelProperty(value = "是否随机打乱")
@@ -91,16 +98,16 @@ public class ActiveLearn {
@ApiModelProperty(value = "学习率") @ApiModelProperty(value = "学习率")
private Float lr; private Float lr;


private Integer state;

private String createBy; private String createBy;


private Date createTime;

private String updateBy; private String updateBy;


private Date createTime;

private Date updateTime; private Date updateTime;


private Integer state;

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

+ 10
- 9
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ActiveLearnIns.java View File

@@ -3,7 +3,6 @@ package com.ruoyi.platform.domain;
import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming; import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;


import java.util.Date; import java.util.Date;
@@ -16,23 +15,25 @@ public class ActiveLearnIns {


private Long activeLearnId; private Long activeLearnId;


private Integer state;

private String status;

private String param; private String param;


private String resultPath;
private Date createTime;


private Integer state;
private Date updateTime;


private String status;
private Date finishTime;


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


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


private Date createTime;
private String resultPath;


private Date updateTime;
private String nodeStatus;


private Date finishTime;
private String nodeResult;
} }

+ 5
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ResourceOccupy.java View File

@@ -49,9 +49,12 @@ public class ResourceOccupy {
@ApiModelProperty("流水线id") @ApiModelProperty("流水线id")
private Long workflowId; private Long workflowId;


@ApiModelProperty("流水线节点id")
private String nodeId;

@ApiModelProperty("任务名称") @ApiModelProperty("任务名称")
private String taskName; private String taskName;


@ApiModelProperty("流水线节点id")
private String nodeId;
@ApiModelProperty("任务状态")
private Integer taskState;
} }

+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ActiveLearnDao.java View File

@@ -2,14 +2,14 @@ package com.ruoyi.platform.mapper;


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


import java.util.List; import java.util.List;


public interface ActiveLearnDao { public interface ActiveLearnDao {
long count(@Param("name") String name); long count(@Param("name") String name);


List<ActiveLearn> queryByPage(@Param("name") String name, @Param("pageable") Pageable pageable);
List<ActiveLearn> queryByPage(@Param("name") String name, @Param("pageable") PageRequest pageRequest);


ActiveLearn getActiveLearnByName(@Param("name") String name); ActiveLearn getActiveLearnByName(@Param("name") String name);




+ 4
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ActiveLearnInsDao.java View File

@@ -7,9 +7,9 @@ import org.springframework.data.domain.Pageable;
import java.util.List; import java.util.List;


public interface ActiveLearnInsDao { public interface ActiveLearnInsDao {
long count(@Param("activeLearnIns") ActiveLearnIns activeLearnIns);
long count(@Param("activeLearnId") Long activeLearnId);


List<ActiveLearnIns> queryAllByLimit(@Param("activeLearnIns") ActiveLearnIns activeLearnIns, @Param("pageable") Pageable pageable);
List<ActiveLearnIns> queryAllByLimit(@Param("activeLearnId") Long activeLearnId, @Param("pageable") Pageable pageable);


int insert(@Param("activeLearnIns") ActiveLearnIns activeLearnIns); int insert(@Param("activeLearnIns") ActiveLearnIns activeLearnIns);


@@ -18,4 +18,6 @@ public interface ActiveLearnInsDao {
ActiveLearnIns queryById(@Param("id") Long id); ActiveLearnIns queryById(@Param("id") Long id);


List<ActiveLearnIns> getByActiveLearnId(@Param("activeLearnId") Long activeLearnId); List<ActiveLearnIns> getByActiveLearnId(@Param("activeLearnId") Long activeLearnId);

List<ActiveLearnIns> queryActiveLearnInsIsNotTerminated();
} }

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

@@ -63,5 +63,11 @@ public interface DevEnvironmentDao {
int deleteById(Integer id); int deleteById(Integer id);


List<DevEnvironment> getRunning(); List<DevEnvironment> getRunning();

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

List<DevEnvironment> queryByModelId(@Param("modelId") String modelId);

List<DevEnvironment> queryByImageId(@Param("imageId") String imageId);
} }



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

@@ -29,4 +29,6 @@ public interface ResourceOccupyDao {
Double getUserCredit(@Param("userId") Long userId); Double getUserCredit(@Param("userId") Long userId);


Double getDeduceCredit(@Param("userId") Long userId); Double getDeduceCredit(@Param("userId") Long userId);

int deleteTaskState(String taskType, Long taskId, Long taskInsId);
} }

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

@@ -38,4 +38,10 @@ public interface ServiceDao {
ServiceVersion getSvByVersion(@Param("version") String version, @Param("serviceId") Long serviceId); ServiceVersion getSvByVersion(@Param("version") String version, @Param("serviceId") Long serviceId);


List<ServiceVersion> getRunning(); List<ServiceVersion> getRunning();

List<String> queryByModelId(@Param("modelId") String modelId);

List<String> queryByImageId(@Param("imageId") String imageId);

List<String> queryByCodeConfig(@Param("codeConfig") String codeConfig);
} }

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

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

import com.ruoyi.platform.domain.ActiveLearn;
import com.ruoyi.platform.domain.ActiveLearnIns;
import com.ruoyi.platform.mapper.ActiveLearnDao;
import com.ruoyi.platform.mapper.ActiveLearnInsDao;
import com.ruoyi.platform.mapper.ResourceOccupyDao;
import com.ruoyi.platform.service.ActiveLearnInsService;
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 ActiveLearnInsStatusTask {

@Resource
private ActiveLearnInsService activeLearnInsService;
@Resource
private ActiveLearnInsDao activeLearnInsDao;
@Resource
private ActiveLearnDao activeLearnDao;
@Resource
private ResourceOccupyDao resourceOccupyDao;
@Resource
private ResourceOccupyService resourceOccupyService;

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

@Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次
public void executeActiveLearnInsStatus() {
List<ActiveLearnIns> activeLearnInsList = activeLearnInsService.queryActiveLearnInsIsNotTerminated();

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

@Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次
public void executeActiveLearnStatus() {
if (activeLearnIds.size() == 0) {
return;
}
// 存储需要更新的实验对象列表
List<ActiveLearn> updateActiveLearns = new ArrayList<>();
for (Long activeLearnId : activeLearnIds) {
// 获取当前实验的所有实例列表
List<ActiveLearnIns> insList = activeLearnInsDao.getByActiveLearnId(activeLearnId);
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);
ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(activeLearnId);
if (!StringUtils.equals(activeLearn.getStatusList(), subStatus)) {
activeLearn.setStatusList(subStatus);
updateActiveLearns.add(activeLearn);
activeLearnDao.edit(activeLearn);
}
}

if (!updateActiveLearns.isEmpty()) {
// 使用Iterator进行安全的删除操作
Iterator<Long> iterator = activeLearnIds.iterator();
while (iterator.hasNext()) {
Long activeLearnId = iterator.next();
for (ActiveLearn activeLearn : updateActiveLearns) {
if (activeLearn.getId().equals(activeLearnId)) {
iterator.remove();
}
}
}
}
}
}

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

@@ -8,15 +8,21 @@ import java.io.IOException;
import java.util.List; import java.util.List;


public interface ActiveLearnInsService { public interface ActiveLearnInsService {
Page<ActiveLearnIns> queryByPage(ActiveLearnIns activeLearnIns, PageRequest pageRequest) throws IOException;
Page<ActiveLearnIns> queryByPage(Long activeLearnId, PageRequest pageRequest) throws IOException;


ActiveLearnIns insert(ActiveLearnIns activeLearnIns); ActiveLearnIns insert(ActiveLearnIns activeLearnIns);


String removeById(Long id);
String deleteById(Long id);


String batchDelete(List<Long> ids); String batchDelete(List<Long> ids);


boolean terminateActiveLearnIns(Long id);
boolean terminateActiveLearnIns(Long id) throws Exception;


ActiveLearnIns getDetailById(Long id);
ActiveLearnIns getDetailById(Long id) throws Exception;

void updateActiveLearnStatus(Long activeLearnId);

ActiveLearnIns queryStatusFromArgo(ActiveLearnIns ins);

List<ActiveLearnIns> queryActiveLearnInsIsNotTerminated();
} }

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

@@ -2,22 +2,21 @@ package com.ruoyi.platform.service;


import com.ruoyi.platform.domain.ActiveLearn; import com.ruoyi.platform.domain.ActiveLearn;
import com.ruoyi.platform.vo.ActiveLearnVo; import com.ruoyi.platform.vo.ActiveLearnVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Page;


import java.io.IOException; import java.io.IOException;


public interface ActiveLearnService { public interface ActiveLearnService {
Page<ActiveLearn> queryByPage(String name, PageRequest pageRequest); Page<ActiveLearn> queryByPage(String name, PageRequest pageRequest);


ActiveLearn save(ActiveLearnVo activeLearnServiceVo);
ActiveLearn save(ActiveLearnVo activeLearnVo) throws Exception;


String edit(ActiveLearnVo activeLearnServiceVo);
String edit(ActiveLearnVo activeLearnVo) throws Exception;


ActiveLearnVo getActiveLearnDetail(Long id) throws IOException; ActiveLearnVo getActiveLearnDetail(Long id) throws IOException;


String delete(Long id); String delete(Long id);


String runActiveLearnIns(Long id) throws Exception;

String runActiveLearnIns (Long id) throws Exception;
} }

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

@@ -4,6 +4,7 @@ import org.springframework.data.domain.PageRequest;
import com.ruoyi.platform.domain.RayIns; import com.ruoyi.platform.domain.RayIns;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;

public interface RayInsService { public interface RayInsService {
Page<RayIns> queryByPage(Long rayId, PageRequest pageRequest) throws IOException; Page<RayIns> queryByPage(Long rayId, PageRequest pageRequest) throws IOException;




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

@@ -22,4 +22,6 @@ public interface ResourceOccupyService {
Map<String, Double> queryCredit(); Map<String, Double> queryCredit();


void update(String taskType, Long taskId, Long taskInsId, Integer computingResourceId, Integer replicas); void update(String taskType, Long taskId, Long taskInsId, Integer computingResourceId, Integer replicas);

void deleteTaskState(String taskType, Long taskId, Long taskInsId);
} }

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

@@ -26,9 +26,9 @@ public interface ServiceService {


Service getService(Long id); Service getService(Long id);


ServiceVersionVo getServiceVersion(Long id);
ServiceVersionVo getServiceVersion(Long id) throws IOException;


Map<String, Object> serviceVersionCompare(Long id1, Long id2) throws IllegalAccessException;
Map<String, Object> serviceVersionCompare(Long id1, Long id2) throws IllegalAccessException, IOException;


String deleteService(Long id) throws Exception; String deleteService(Long id) throws Exception;




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

@@ -5,50 +5,70 @@ import com.ruoyi.platform.domain.ActiveLearnIns;
import com.ruoyi.platform.mapper.ActiveLearnDao; import com.ruoyi.platform.mapper.ActiveLearnDao;
import com.ruoyi.platform.mapper.ActiveLearnInsDao; import com.ruoyi.platform.mapper.ActiveLearnInsDao;
import com.ruoyi.platform.service.ActiveLearnInsService; import com.ruoyi.platform.service.ActiveLearnInsService;
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 com.ruoyi.system.api.constant.Constant;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.*;


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

@Resource @Resource
private ActiveLearnInsDao activeLearnInsDao; private ActiveLearnInsDao activeLearnInsDao;
@Resource @Resource
private ActiveLearnDao activeLearnDao; private ActiveLearnDao activeLearnDao;
@Resource
private ResourceOccupyService resourceOccupyService;


@Override @Override
public Page<ActiveLearnIns> queryByPage(ActiveLearnIns activeLearnIns, PageRequest pageRequest) throws IOException {
long total = this.activeLearnInsDao.count(activeLearnIns);
List<ActiveLearnIns> activeLearnInsList = this.activeLearnInsDao.queryAllByLimit(activeLearnIns, pageRequest);
public Page<ActiveLearnIns> queryByPage(Long activeLearnId, PageRequest pageRequest) throws IOException {
long total = this.activeLearnInsDao.count(activeLearnId);
List<ActiveLearnIns> activeLearnInsList = activeLearnInsDao.queryAllByLimit(activeLearnId, pageRequest);
return new PageImpl<>(activeLearnInsList, pageRequest, total); return new PageImpl<>(activeLearnInsList, pageRequest, total);
} }


@Override @Override
public ActiveLearnIns insert(ActiveLearnIns activeLearnIns) { public ActiveLearnIns insert(ActiveLearnIns activeLearnIns) {
this.activeLearnInsDao.insert(activeLearnIns);
activeLearnInsDao.insert(activeLearnIns);
return activeLearnIns; return activeLearnIns;
} }


@Override @Override
public String removeById(Long id) {
@Transactional
public String deleteById(Long id) {
ActiveLearnIns activeLearnIns = activeLearnInsDao.queryById(id); ActiveLearnIns activeLearnIns = activeLearnInsDao.queryById(id);
if (activeLearnIns == null) { if (activeLearnIns == null) {
return "实验实例不存在"; return "实验实例不存在";
} }

//todo queryStatusFromArgo
if (StringUtils.isEmpty(activeLearnIns.getStatus())) {
activeLearnIns = queryStatusFromArgo(activeLearnIns);
}
if (StringUtils.equals(activeLearnIns.getStatus(), Constant.Running)) {
return "实验实例正在运行,不可删除";
}


activeLearnIns.setState(Constant.State_invalid); activeLearnIns.setState(Constant.State_invalid);
int update = activeLearnInsDao.update(activeLearnIns); int update = activeLearnInsDao.update(activeLearnIns);
if (update > 0) { if (update > 0) {
resourceOccupyService.deleteTaskState(Constant.TaskType_ActiveLearn, activeLearnIns.getActiveLearnId(), id);
updateActiveLearnStatus(activeLearnIns.getActiveLearnId()); updateActiveLearnStatus(activeLearnIns.getActiveLearnId());
return "删除成功"; return "删除成功";
} else { } else {
@@ -59,7 +79,7 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService {
@Override @Override
public String batchDelete(List<Long> ids) { public String batchDelete(List<Long> ids) {
for (Long id : ids) { for (Long id : ids) {
String result = removeById(id);
String result = deleteById(id);
if (!"删除成功".equals(result)) { if (!"删除成功".equals(result)) {
return result; return result;
} }
@@ -68,34 +88,93 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService {
} }


@Override @Override
public boolean terminateActiveLearnIns(Long id) {
public boolean terminateActiveLearnIns(Long id) throws Exception {
ActiveLearnIns activeLearnIns = activeLearnInsDao.queryById(id); ActiveLearnIns activeLearnIns = activeLearnInsDao.queryById(id);
if (activeLearnIns == null) { if (activeLearnIns == null) {
throw new IllegalStateException("实验实例未查询到,id: " + id); throw new IllegalStateException("实验实例未查询到,id: " + id);
} }

String currentStatus = activeLearnIns.getStatus(); String currentStatus = activeLearnIns.getStatus();
String name = activeLearnIns.getArgoInsName(); String name = activeLearnIns.getArgoInsName();
String namespace = activeLearnIns.getArgoInsNs(); String namespace = activeLearnIns.getArgoInsNs();


//todo queryStatusFromArgo
// 获取当前状态,如果为空,则从Argo查询
if (StringUtils.isEmpty(currentStatus)) {
currentStatus = queryStatusFromArgo(activeLearnIns).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);


return false;
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,确保状态更新被保存到数据库
ActiveLearnIns ins = queryStatusFromArgo(activeLearnIns);
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());
activeLearnInsDao.update(ins);
updateActiveLearnStatus(ins.getActiveLearnId());
// 结束扣积分
resourceOccupyService.endDeduce(Constant.TaskType_ActiveLearn, null, id, null, null);
return true;
} else {
return false;
}
} catch (Exception e) {
throw new RuntimeException("终止实例错误: " + e.getMessage(), e);
}
} }


@Override @Override
public ActiveLearnIns getDetailById(Long id) {
public ActiveLearnIns getDetailById(Long id) throws Exception {
ActiveLearnIns activeLearnIns = activeLearnInsDao.queryById(id); ActiveLearnIns activeLearnIns = activeLearnInsDao.queryById(id);
if(Constant.Running.equals(activeLearnIns.getStatus()) || Constant.Pending.equals(activeLearnIns.getStatus())){
//todo queryStatusFromArgo
if (Constant.Running.equals(activeLearnIns.getStatus()) || Constant.Pending.equals(activeLearnIns.getStatus())) {
activeLearnIns = queryStatusFromArgo(activeLearnIns);
} }
return activeLearnIns; return activeLearnIns;
} }


@Override
public void updateActiveLearnStatus(Long activeLearnId) { public void updateActiveLearnStatus(Long activeLearnId) {
List<ActiveLearnIns> insList = activeLearnInsDao.getByActiveLearnId(activeLearnId); List<ActiveLearnIns> insList = activeLearnInsDao.getByActiveLearnId(activeLearnId);
List<String> statusList = new ArrayList<>(); List<String> statusList = new ArrayList<>();

// 更新实验状态列表 // 更新实验状态列表
for (int i = 0; i < insList.size(); i++) { for (int i = 0; i < insList.size(); i++) {
statusList.add(insList.get(i).getStatus()); statusList.add(insList.get(i).getStatus());
@@ -108,4 +187,77 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService {
} }
} }


@Override
public ActiveLearnIns queryStatusFromArgo(ActiveLearnIns 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 List<ActiveLearnIns> queryActiveLearnInsIsNotTerminated() {
return activeLearnInsDao.queryActiveLearnInsIsNotTerminated();
}
} }

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

@@ -2,27 +2,54 @@ package com.ruoyi.platform.service.impl;


import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.platform.domain.ActiveLearn; import com.ruoyi.platform.domain.ActiveLearn;
import com.ruoyi.platform.domain.ActiveLearnIns;
import com.ruoyi.platform.mapper.ActiveLearnDao; import com.ruoyi.platform.mapper.ActiveLearnDao;
import com.ruoyi.platform.mapper.ActiveLearnInsDao;
import com.ruoyi.platform.service.ActiveLearnInsService;
import com.ruoyi.platform.service.ActiveLearnService; import com.ruoyi.platform.service.ActiveLearnService;
import com.ruoyi.platform.service.ResourceOccupyService;
import com.ruoyi.platform.utils.HttpUtils;
import com.ruoyi.platform.utils.JacksonUtil; import com.ruoyi.platform.utils.JacksonUtil;
import com.ruoyi.platform.utils.JsonUtils; import com.ruoyi.platform.utils.JsonUtils;
import com.ruoyi.platform.vo.ActiveLearnParamVo;
import com.ruoyi.platform.vo.ActiveLearnVo; import com.ruoyi.platform.vo.ActiveLearnVo;
import com.ruoyi.system.api.constant.Constant; import com.ruoyi.system.api.constant.Constant;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


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


@Service("activeLearnService")
@Service
public class ActiveLearnServiceImpl implements ActiveLearnService { public class ActiveLearnServiceImpl implements ActiveLearnService {
@Value("${argo.url}")
private String argoUrl;
@Value("${argo.workflowRun}")
private String argoWorkflowRun;
@Value("${argo.convertActiveLearn}")
String convertActiveLearn;

@Resource
private ResourceOccupyService resourceOccupyService;

@Resource @Resource
private ActiveLearnDao activeLearnDao; private ActiveLearnDao activeLearnDao;
@Resource
private ActiveLearnInsDao activeLearnInsDao;
@Resource
private ActiveLearnInsService activeLearnInsService;



@Override @Override
public Page<ActiveLearn> queryByPage(String name, PageRequest pageRequest) { public Page<ActiveLearn> queryByPage(String name, PageRequest pageRequest) {
@@ -32,7 +59,7 @@ public class ActiveLearnServiceImpl implements ActiveLearnService {
} }


@Override @Override
public ActiveLearn save(ActiveLearnVo activeLearnVo) {
public ActiveLearn save(ActiveLearnVo activeLearnVo) throws Exception {
ActiveLearn activeLearnByName = activeLearnDao.getActiveLearnByName(activeLearnVo.getName()); ActiveLearn activeLearnByName = activeLearnDao.getActiveLearnByName(activeLearnVo.getName());
if (activeLearnByName != null) { if (activeLearnByName != null) {
throw new RuntimeException("实验名称已存在"); throw new RuntimeException("实验名称已存在");
@@ -42,33 +69,28 @@ public class ActiveLearnServiceImpl implements ActiveLearnService {
String username = SecurityUtils.getLoginUser().getUsername(); String username = SecurityUtils.getLoginUser().getUsername();
activeLearn.setCreateBy(username); activeLearn.setCreateBy(username);
activeLearn.setUpdateBy(username); activeLearn.setUpdateBy(username);

activeLearn.setImage(JacksonUtil.toJSONString(activeLearnVo.getImage()));
activeLearn.setModel(JacksonUtil.toJSONString(activeLearnVo.getModel()));
activeLearn.setDataset(JacksonUtil.toJSONString(activeLearnVo.getDataset())); activeLearn.setDataset(JacksonUtil.toJSONString(activeLearnVo.getDataset()));

activeLearn.setCodeConfig(JacksonUtil.toJSONString(activeLearnVo.getCodeConfig()));
activeLearn.setModel(JacksonUtil.toJSONString(activeLearnVo.getModel()));
activeLearn.setImage(JacksonUtil.toJSONString(activeLearnVo.getImage()));
activeLearnDao.save(activeLearn); activeLearnDao.save(activeLearn);
return activeLearn; return activeLearn;
} }


@Override @Override
public String edit(ActiveLearnVo activeLearnVo) {
ActiveLearn activeLearnByName = activeLearnDao.getActiveLearnByName(activeLearnVo.getName());
if (activeLearnByName != null && !activeLearnByName.getId().equals(activeLearnVo.getId())) {
public String edit(ActiveLearnVo activeLearnVo) throws Exception {
ActiveLearn oldActiveLearn = activeLearnDao.getActiveLearnByName(activeLearnVo.getName());
if (oldActiveLearn != null && !oldActiveLearn.getId().equals(activeLearnVo.getId())) {
throw new RuntimeException("实验名称已存在"); throw new RuntimeException("实验名称已存在");
} }

ActiveLearn activeLearn = new ActiveLearn(); ActiveLearn activeLearn = new ActiveLearn();
BeanUtils.copyProperties(activeLearnVo, activeLearn); BeanUtils.copyProperties(activeLearnVo, activeLearn);
String username = SecurityUtils.getLoginUser().getUsername();
activeLearn.setUpdateBy(username);

activeLearn.setImage(JacksonUtil.toJSONString(activeLearnVo.getImage()));
activeLearn.setModel(JacksonUtil.toJSONString(activeLearnVo.getModel()));
activeLearn.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
activeLearn.setDataset(JacksonUtil.toJSONString(activeLearnVo.getDataset())); activeLearn.setDataset(JacksonUtil.toJSONString(activeLearnVo.getDataset()));

activeLearn.setCodeConfig(JacksonUtil.toJSONString(activeLearnVo.getCodeConfig()));
activeLearn.setModel(JacksonUtil.toJSONString(activeLearnVo.getModel()));
activeLearn.setImage(JacksonUtil.toJSONString(activeLearnVo.getImage()));
activeLearnDao.edit(activeLearn); activeLearnDao.edit(activeLearn);

return "修改成功"; return "修改成功";
} }


@@ -77,15 +99,15 @@ public class ActiveLearnServiceImpl implements ActiveLearnService {
ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id); ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id);
ActiveLearnVo activeLearnVo = new ActiveLearnVo(); ActiveLearnVo activeLearnVo = new ActiveLearnVo();
BeanUtils.copyProperties(activeLearn, activeLearnVo); BeanUtils.copyProperties(activeLearn, activeLearnVo);
if (StringUtils.isNotEmpty(activeLearn.getDatasetPy())) {
if (StringUtils.isNotEmpty(activeLearn.getDataset())) {
activeLearnVo.setDataset(JsonUtils.jsonToMap(activeLearn.getDataset())); activeLearnVo.setDataset(JsonUtils.jsonToMap(activeLearn.getDataset()));
} }
if (StringUtils.isNotEmpty(activeLearn.getCodeConfig())) {
activeLearnVo.setCodeConfig(JsonUtils.jsonToMap(activeLearn.getCodeConfig()));
}
if (StringUtils.isNotEmpty(activeLearn.getModel())) { if (StringUtils.isNotEmpty(activeLearn.getModel())) {
activeLearnVo.setModel(JsonUtils.jsonToMap(activeLearn.getModel())); activeLearnVo.setModel(JsonUtils.jsonToMap(activeLearn.getModel()));
} }
if (StringUtils.isNotEmpty(activeLearn.getDataset())) {
activeLearnVo.setDataset(JsonUtils.jsonToMap(activeLearn.getDataset()));
}
if (StringUtils.isNotEmpty(activeLearn.getImage())) { if (StringUtils.isNotEmpty(activeLearn.getImage())) {
activeLearnVo.setImage(JsonUtils.jsonToMap(activeLearn.getImage())); activeLearnVo.setImage(JsonUtils.jsonToMap(activeLearn.getImage()));
} }
@@ -93,6 +115,7 @@ public class ActiveLearnServiceImpl implements ActiveLearnService {
} }


@Override @Override
@Transactional
public String delete(Long id) { public String delete(Long id) {
ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id); ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id);
if (activeLearn == null) { if (activeLearn == null) {
@@ -104,6 +127,7 @@ public class ActiveLearnServiceImpl implements ActiveLearnService {
throw new RuntimeException("无权限删除该实验"); throw new RuntimeException("无权限删除该实验");
} }
activeLearn.setState(Constant.State_invalid); activeLearn.setState(Constant.State_invalid);
resourceOccupyService.deleteTaskState(Constant.TaskType_ActiveLearn, id, null);
return activeLearnDao.edit(activeLearn) > 0 ? "删除成功" : "删除失败"; return activeLearnDao.edit(activeLearn) > 0 ? "删除成功" : "删除失败";
} }


@@ -114,16 +138,64 @@ public class ActiveLearnServiceImpl implements ActiveLearnService {
throw new Exception("主动学习配置不存在"); throw new Exception("主动学习配置不存在");
} }


ActiveLearnVo activeLearnParam = new ActiveLearnVo();
BeanUtils.copyProperties(activeLearn, activeLearnParam);
activeLearnParam.setDataset(JsonUtils.jsonToMap(activeLearn.getDataset()));
activeLearnParam.setImage(JsonUtils.jsonToMap(activeLearn.getImage()));
activeLearnParam.setModel(JsonUtils.jsonToMap(activeLearn.getModel()));

String param = JsonUtils.objectToJson(activeLearnParam);

// todo 调argo转换接口

// 记录开始扣积分
if (resourceOccupyService.haveResource(activeLearn.getComputingResourceId(), 1)) {
ActiveLearnParamVo activeLearnParamVo = new ActiveLearnParamVo();
BeanUtils.copyProperties(activeLearn, activeLearnParamVo);
activeLearnParamVo.setCodeConfig(JsonUtils.jsonToMap(activeLearn.getCodeConfig()));
activeLearnParamVo.setDataset(JsonUtils.jsonToMap(activeLearn.getDataset()));
activeLearnParamVo.setModel(JsonUtils.jsonToMap(activeLearn.getModel()));
activeLearnParamVo.setImage(JsonUtils.jsonToMap(activeLearn.getImage()));
String param = JsonUtils.objectToJson(activeLearnParamVo);

// 调argo转换接口
try {
String convertRes = HttpUtils.sendPost(argoUrl + convertActiveLearn, 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");

// 插入记录到实验实例表
ActiveLearnIns activeLearnIns = new ActiveLearnIns();
activeLearnIns.setActiveLearnId(id);
activeLearnIns.setArgoInsNs((String) metadata.get("namespace"));
activeLearnIns.setArgoInsName((String) metadata.get("name"));
activeLearnIns.setParam(param);
activeLearnIns.setStatus(Constant.Pending);
//替换argoInsName
String outputString = JsonUtils.mapToJson(output);
activeLearnIns.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 = output2.get("path").replace("{{workflow.name}}", (String) metadata.get("name")) + "/hpo";
activeLearnIns.setResultPath(outputPath);
activeLearnInsDao.insert(activeLearnIns);
activeLearnInsService.updateActiveLearnStatus(id);
// 记录开始扣除积分
resourceOccupyService.startDeduce(activeLearn.getComputingResourceId(), 1, Constant.TaskType_ActiveLearn, id, activeLearnIns.getId(), null, activeLearn.getName(), null, null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return "执行成功"; return "执行成功";
} }
} }

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

@@ -146,7 +146,7 @@ public class AutoMlInsServiceImpl implements AutoMlInsService {
if (!StringUtils.equals(ins.getStatus(), Constant.Terminated)) { if (!StringUtils.equals(ins.getStatus(), Constant.Terminated)) {
ins.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : Constant.Pending); ins.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : Constant.Pending);
} }
if (StringUtils.equals(ins.getStatus(), "Error")) {
if (StringUtils.equals(ins.getStatus(), Constant.Error)) {
ins.setStatus(Constant.Failed); ins.setStatus(Constant.Failed);
} }
return ins; return ins;


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

@@ -3,21 +3,18 @@ package com.ruoyi.platform.service.impl;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.platform.domain.ActiveLearn; import com.ruoyi.platform.domain.ActiveLearn;
import com.ruoyi.platform.mapper.*;
import com.ruoyi.system.api.constant.Constant;
import com.ruoyi.platform.domain.AssetWorkflow; import com.ruoyi.platform.domain.AssetWorkflow;
import com.ruoyi.platform.domain.CodeConfig; import com.ruoyi.platform.domain.CodeConfig;
import com.ruoyi.platform.domain.Ray;
import com.ruoyi.platform.mapper.ActiveLearnDao;
import com.ruoyi.platform.mapper.AssetWorkflowDao;
import com.ruoyi.platform.mapper.CodeConfigDao;
import com.ruoyi.platform.mapper.RayDao;
import com.ruoyi.platform.service.CodeConfigService; import com.ruoyi.platform.service.CodeConfigService;
import com.ruoyi.system.api.constant.Constant;
import com.ruoyi.system.api.model.LoginUser; import com.ruoyi.system.api.model.LoginUser;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.platform.domain.Ray;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
@@ -36,6 +33,8 @@ public class CodeConfigServiceImpl implements CodeConfigService {
private RayDao rayDao; private RayDao rayDao;
@Resource @Resource
private ActiveLearnDao activeLearnDao; private ActiveLearnDao activeLearnDao;
@Resource
private ServiceDao serviceDao;


@Override @Override
public Page<CodeConfig> queryByPage(CodeConfig codeConfig, PageRequest pageRequest) { public Page<CodeConfig> queryByPage(CodeConfig codeConfig, PageRequest pageRequest) {
@@ -112,6 +111,12 @@ public class CodeConfigServiceImpl implements CodeConfigService {
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 + "使用,不能删除,请先删除服务版本。");
}

LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
String username = loginUser.getUsername(); String username = loginUser.getUsername();
String createBy = codeConfig.getCreateBy(); String createBy = codeConfig.getCreateBy();


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

@@ -6,9 +6,11 @@ import com.ruoyi.platform.domain.PodStatus;
import com.ruoyi.platform.mapper.DevEnvironmentDao; import com.ruoyi.platform.mapper.DevEnvironmentDao;
import com.ruoyi.platform.service.DevEnvironmentService; import com.ruoyi.platform.service.DevEnvironmentService;
import com.ruoyi.platform.service.JupyterService; import com.ruoyi.platform.service.JupyterService;
import com.ruoyi.platform.service.ResourceOccupyService;
import com.ruoyi.platform.utils.JacksonUtil; import com.ruoyi.platform.utils.JacksonUtil;
import com.ruoyi.platform.vo.DevEnvironmentVo; import com.ruoyi.platform.vo.DevEnvironmentVo;
import com.ruoyi.platform.vo.PodStatusVo; import com.ruoyi.platform.vo.PodStatusVo;
import com.ruoyi.system.api.constant.Constant;
import com.ruoyi.system.api.model.LoginUser; import com.ruoyi.system.api.model.LoginUser;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
@@ -16,6 +18,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
@@ -35,6 +38,8 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService {
@Resource @Resource
@Lazy @Lazy
private JupyterService jupyterService; private JupyterService jupyterService;
@Resource
private ResourceOccupyService resourceOccupyService;


/** /**
* 通过ID查询单条数据 * 通过ID查询单条数据
@@ -94,22 +99,19 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
devEnvironment.setName(devEnvironmentVo.getName()); devEnvironment.setName(devEnvironmentVo.getName());
//状态先设为未知 //状态先设为未知
devEnvironment.setStatus("Unknown");
devEnvironment.setStatus(Constant.Unknown);
devEnvironment.setComputingResource(devEnvironmentVo.getComputingResource()); devEnvironment.setComputingResource(devEnvironmentVo.getComputingResource());
devEnvironment.setComputingResourceId(devEnvironmentVo.getComputingResourceId()); devEnvironment.setComputingResourceId(devEnvironmentVo.getComputingResourceId());
devEnvironment.setStandard(devEnvironmentVo.getStandard()); devEnvironment.setStandard(devEnvironmentVo.getStandard());
devEnvironment.setEnvVariable(devEnvironmentVo.getEnvVariable()); devEnvironment.setEnvVariable(devEnvironmentVo.getEnvVariable());
devEnvironment.setImage(devEnvironmentVo.getImage());
// 将 dataset 和 model 转换成 JSON 字符串
String datasetJson = JacksonUtil.toJSONString(devEnvironmentVo.getDataset());
String modelJson = JacksonUtil.toJSONString(devEnvironmentVo.getModel());
devEnvironment.setDataset(datasetJson);
devEnvironment.setModel(modelJson);
devEnvironment.setImage(JacksonUtil.toJSONString(devEnvironmentVo.getImage()));
devEnvironment.setDataset(JacksonUtil.toJSONString(devEnvironmentVo.getDataset()));
devEnvironment.setModel(JacksonUtil.toJSONString(devEnvironmentVo.getModel()));
devEnvironment.setCreateBy(loginUser.getUsername()); devEnvironment.setCreateBy(loginUser.getUsername());
devEnvironment.setUpdateBy(loginUser.getUsername()); devEnvironment.setUpdateBy(loginUser.getUsername());
devEnvironment.setUpdateTime(new Date()); devEnvironment.setUpdateTime(new Date());
devEnvironment.setCreateTime(new Date()); devEnvironment.setCreateTime(new Date());
devEnvironment.setState(1);
devEnvironment.setState(Constant.State_valid);
this.devEnvironmentDao.insert(devEnvironment); this.devEnvironmentDao.insert(devEnvironment);
return devEnvironment; return devEnvironment;
} }
@@ -140,6 +142,7 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService {
} }


@Override @Override
@Transactional
public String removeById(Integer id) throws Exception { public String removeById(Integer id) throws Exception {
DevEnvironment devEnvironment = this.devEnvironmentDao.queryById(id); DevEnvironment devEnvironment = this.devEnvironmentDao.queryById(id);
if (devEnvironment == null) { if (devEnvironment == null) {
@@ -155,9 +158,8 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService {
} }


jupyterService.stopJupyterService(id); jupyterService.stopJupyterService(id);
devEnvironment.setState(0);
devEnvironment.setState(Constant.State_invalid);
resourceOccupyService.deleteTaskState(Constant.TaskType_Dev, Long.valueOf(id), null);
return this.devEnvironmentDao.update(devEnvironment) > 0 ? "删除成功" : "删除失败"; return this.devEnvironmentDao.update(devEnvironment) > 0 ? "删除成功" : "删除失败";
} }


} }

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

@@ -2,7 +2,6 @@ package com.ruoyi.platform.service.impl;


import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.constant.Constant;
import com.ruoyi.platform.domain.DatasetTempStorage; import com.ruoyi.platform.domain.DatasetTempStorage;
import com.ruoyi.platform.domain.Experiment; import com.ruoyi.platform.domain.Experiment;
import com.ruoyi.platform.domain.ExperimentIns; import com.ruoyi.platform.domain.ExperimentIns;
@@ -16,6 +15,7 @@ import com.ruoyi.platform.service.ResourceOccupyService;
import com.ruoyi.platform.utils.*; import com.ruoyi.platform.utils.*;
import com.ruoyi.platform.vo.LogRequestVo; import com.ruoyi.platform.vo.LogRequestVo;
import com.ruoyi.platform.vo.PodLogVo; import com.ruoyi.platform.vo.PodLogVo;
import com.ruoyi.system.api.constant.Constant;
import com.ruoyi.system.api.model.LoginUser; import com.ruoyi.system.api.model.LoginUser;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@@ -23,6 +23,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
@@ -204,6 +205,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
} }


@Override @Override
@Transactional
public String removeById(Integer id) { public String removeById(Integer id) {
ExperimentIns experimentIns = experimentInsDao.queryById(id); ExperimentIns experimentIns = experimentInsDao.queryById(id);
if (experimentIns == null) { if (experimentIns == null) {
@@ -227,6 +229,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
experimentIns.setState(0); experimentIns.setState(0);
int update = this.experimentInsDao.update(experimentIns); int update = this.experimentInsDao.update(experimentIns);
if (update > 0) { if (update > 0) {
resourceOccupyService.deleteTaskState(Constant.TaskType_Workflow, Long.valueOf(experimentIns.getExperimentId()), Long.valueOf(id));
updateExperimentStatus(experimentIns.getExperimentId()); updateExperimentStatus(experimentIns.getExperimentId());
return "删除成功"; return "删除成功";
} else { } else {
@@ -323,7 +326,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
if (!StringUtils.equals(experimentIns.getStatus(), "Terminated")) { if (!StringUtils.equals(experimentIns.getStatus(), "Terminated")) {
experimentIns.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : "Pending"); experimentIns.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : "Pending");
} }
if (StringUtils.equals(experimentIns.getStatus(), "Error")) {
if (StringUtils.equals(experimentIns.getStatus(), Constant.Error)) {
experimentIns.setStatus("Failed"); experimentIns.setStatus("Failed");
} }




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

@@ -28,6 +28,7 @@ import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
@@ -184,6 +185,7 @@ public class ExperimentServiceImpl implements ExperimentService {
} }


@Override @Override
@Transactional
public String removeById(Integer id) throws Exception { public String removeById(Integer id) throws Exception {
Experiment experiment = experimentDao.queryById(id); Experiment experiment = experimentDao.queryById(id);
if (experiment == null) { if (experiment == null) {
@@ -202,7 +204,8 @@ public class ExperimentServiceImpl implements ExperimentService {
if (experimentInsList != null && experimentInsList.size() > 0) { if (experimentInsList != null && experimentInsList.size() > 0) {
throw new Exception("该实验存在实例,无法删除"); throw new Exception("该实验存在实例,无法删除");
} }
experiment.setState(0);
resourceOccupyService.deleteTaskState(Constant.TaskType_Workflow, Long.valueOf(id), null);
experiment.setState(Constant.State_invalid);
return this.experimentDao.update(experiment) > 0 ? "删除成功" : "删除失败"; return this.experimentDao.update(experiment) > 0 ? "删除成功" : "删除失败";






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

@@ -6,13 +6,12 @@ import com.ruoyi.common.core.web.domain.GenericsAjaxResult;
import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.platform.domain.*; import com.ruoyi.platform.domain.*;
import com.ruoyi.platform.mapper.*; import com.ruoyi.platform.mapper.*;
import com.ruoyi.platform.domain.*;
import com.ruoyi.platform.mapper.*;
import com.ruoyi.platform.service.ImageService; import com.ruoyi.platform.service.ImageService;
import com.ruoyi.platform.service.ImageVersionService; import com.ruoyi.platform.service.ImageVersionService;
import com.ruoyi.platform.service.MinioService; import com.ruoyi.platform.service.MinioService;
import com.ruoyi.platform.utils.DockerClientUtil; import com.ruoyi.platform.utils.DockerClientUtil;
import com.ruoyi.platform.utils.FileUtil; import com.ruoyi.platform.utils.FileUtil;
import com.ruoyi.platform.utils.JacksonUtil;
import com.ruoyi.platform.utils.K8sClientUtil; import com.ruoyi.platform.utils.K8sClientUtil;
import com.ruoyi.platform.vo.ImageVo; import com.ruoyi.platform.vo.ImageVo;
import com.ruoyi.system.api.constant.Constant; import com.ruoyi.system.api.constant.Constant;
@@ -59,7 +58,8 @@ public class ImageServiceImpl implements ImageService {
private ActiveLearnDao activeLearnDao; private ActiveLearnDao activeLearnDao;
@Resource @Resource
private ImageVersionService imageVersionService; private ImageVersionService imageVersionService;

@Resource
private ServiceDao serviceDao;
@Resource @Resource
private K8sClientUtil k8sClientUtil; private K8sClientUtil k8sClientUtil;
@Resource @Resource
@@ -194,6 +194,18 @@ public class ImageServiceImpl implements ImageService {
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 + "使用,不能删除,请先删除开发环境。");
}

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 + "使用,不能删除,请先删除服务版本。");
}

//判断权限,只有admin和创建者本身可以删除该数据集 //判断权限,只有admin和创建者本身可以删除该数据集
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
String username = loginUser.getUsername(); String username = loginUser.getUsername();
@@ -445,13 +457,22 @@ public class ImageServiceImpl implements ImageService {
imageVersion.setUpdateTime(new Date()); imageVersion.setUpdateTime(new Date());
imageVersion.setCreateTime(new Date()); imageVersion.setCreateTime(new Date());
imageVersion.setState(Constant.State_valid); imageVersion.setState(Constant.State_valid);
imageVersion.setStatus("available");
imageVersion.setStatus(Constant.Available);
imageVersionDao.insert(imageVersion); imageVersionDao.insert(imageVersion);


//更新dev环境的镜像信息 //更新dev环境的镜像信息
DevEnvironment devEnvironment = new DevEnvironment(); DevEnvironment devEnvironment = new DevEnvironment();
devEnvironment.setId(imageVo.getDevEnvironmentId()); devEnvironment.setId(imageVo.getDevEnvironmentId());
devEnvironment.setImage(resultMap.get("imageName"));


imageVo.setValue(resultMap.get("imageName"));
imageVo.setVersion(String.valueOf(imageVersion.getId()));

resultMap.put("id", String.valueOf(oldImage.getId()));
resultMap.put("version", String.valueOf(imageVersion.getId()));
resultMap.put("value",resultMap.get("imageName"));

devEnvironment.setImage(JacksonUtil.toJSONString(resultMap));
devEnvironmentDao.update(devEnvironment); devEnvironmentDao.update(devEnvironment);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("保存镜像失败:" + e); throw new RuntimeException("保存镜像失败:" + e);


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

@@ -9,10 +9,10 @@ import com.ruoyi.platform.service.ImageVersionService;
import com.ruoyi.system.api.constant.Constant; import com.ruoyi.system.api.constant.Constant;
import com.ruoyi.system.api.model.LoginUser; import com.ruoyi.system.api.model.LoginUser;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
@@ -36,6 +36,10 @@ public class ImageVersionServiceImpl implements ImageVersionService {
private RayDao rayDao; private RayDao rayDao;
@Resource @Resource
private ActiveLearnDao activeLearnDao; private ActiveLearnDao activeLearnDao;
@Resource
private DevEnvironmentDao devEnvironmentDao;
@Resource
private ServiceDao serviceDao;
/** /**
* 通过ID查询单条数据 * 通过ID查询单条数据
* *
@@ -79,18 +83,36 @@ public class ImageVersionServiceImpl implements ImageVersionService {
return GenericsAjaxResult.error("该版本下模型文件信息不存在"); return GenericsAjaxResult.error("该版本下模型文件信息不存在");
} }


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 + "使用,不能删除,请先删除流水线。");
}

HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
map.put("version", String.valueOf(id)); map.put("version", String.valueOf(id));
List<Ray> rayList = rayDao.queryByImageId(JSON.toJSONString(map)); List<Ray> rayList = rayDao.queryByImageId(JSON.toJSONString(map));
if (rayList != null && !rayList.isEmpty()) { if (rayList != null && !rayList.isEmpty()) {
String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet()));
throw new Exception("该镜像版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。");
return GenericsAjaxResult.error("该镜像版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。");
} }


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

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 + "使用,不能删除,请先删除服务版本。");
} }


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


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

@@ -67,10 +67,13 @@ public class ModelsServiceImpl implements ModelsService {
@Resource @Resource
private RayDao rayDao; private RayDao rayDao;
@Resource @Resource
private ModelsVersionService modelsVersionService;
@Resource
private ActiveLearnDao activeLearnDao; private ActiveLearnDao activeLearnDao;
@Resource @Resource
private ModelsVersionService modelsVersionService;

private DevEnvironmentDao devEnvironmentDao;
@Resource
private ServiceDao serviceDao;
@Resource @Resource
private ModelDependency1Dao modelDependency1Dao; private ModelDependency1Dao modelDependency1Dao;


@@ -1169,6 +1172,24 @@ public class ModelsServiceImpl implements ModelsService {
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 + "使用,不能删除,请先删除主动学习。");
}

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 + "使用,不能删除,请先删除开发环境。");
}

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 + "使用,不能删除,请先删除服务版本。");
}

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

List<ActiveLearn> activeLearnList = activeLearnDao.queryByModelId(JSON.toJSONString(queryMap));
if (activeLearnList != null && !activeLearnList.isEmpty()) {
String activeLearns = String.join(",", activeLearnList.stream().map(ActiveLearn::getName).collect(Collectors.toSet()));
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 + "使用,不能删除,请先删除开发环境。");
}

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 + "使用,不能删除,请先删除服务版本。");
} }


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


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

@@ -4,10 +4,7 @@ import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.platform.domain.*; import com.ruoyi.platform.domain.*;
import com.ruoyi.platform.mapper.ActiveLearnDao;
import com.ruoyi.platform.mapper.AssetWorkflowDao;
import com.ruoyi.platform.mapper.AutoMlDao;
import com.ruoyi.platform.mapper.RayDao;
import com.ruoyi.platform.mapper.*;
import com.ruoyi.platform.service.DatasetTempStorageService; import com.ruoyi.platform.service.DatasetTempStorageService;
import com.ruoyi.platform.service.GitService; import com.ruoyi.platform.service.GitService;
import com.ruoyi.platform.service.NewDatasetService; import com.ruoyi.platform.service.NewDatasetService;
@@ -59,6 +56,8 @@ public class NewDatasetServiceImpl implements NewDatasetService {
private RayDao rayDao; private RayDao rayDao;
@Resource @Resource
private ActiveLearnDao activeLearnDao; private ActiveLearnDao activeLearnDao;
@Resource
private DevEnvironmentDao devEnvironmentDao;


@Value("${spring.redis.host}") @Value("${spring.redis.host}")
private String redisHost; private String redisHost;
@@ -439,6 +438,12 @@ public class NewDatasetServiceImpl implements NewDatasetService {
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 + "使用,不能删除,请先删除开发环境。");
}

String token = gitService.checkoutToken(); String token = gitService.checkoutToken();
gitService.deleteProject(token, owner, repo); gitService.deleteProject(token, owner, repo);


@@ -476,6 +481,12 @@ public class NewDatasetServiceImpl implements NewDatasetService {
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 + "使用,不能删除,请先删除开发环境。");
}

String token = gitService.checkoutToken(); String token = gitService.checkoutToken();
String rootPath = Paths.get(localPathlocal + "/" + relativePath).getParent().toString(); String rootPath = Paths.get(localPathlocal + "/" + relativePath).getParent().toString();
gitService.deleteBranch(token, owner, repo, version, rootPath); gitService.deleteBranch(token, owner, repo, version, rootPath);


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

@@ -1,6 +1,5 @@
package com.ruoyi.platform.service.impl; package com.ruoyi.platform.service.impl;


import com.ruoyi.system.api.constant.Constant;
import com.ruoyi.platform.domain.Ray; import com.ruoyi.platform.domain.Ray;
import com.ruoyi.platform.domain.RayIns; import com.ruoyi.platform.domain.RayIns;
import com.ruoyi.platform.mapper.RayDao; import com.ruoyi.platform.mapper.RayDao;
@@ -8,6 +7,7 @@ import com.ruoyi.platform.mapper.RayInsDao;
import com.ruoyi.platform.service.RayInsService; import com.ruoyi.platform.service.RayInsService;
import com.ruoyi.platform.service.ResourceOccupyService; import com.ruoyi.platform.service.ResourceOccupyService;
import com.ruoyi.platform.utils.*; import com.ruoyi.platform.utils.*;
import com.ruoyi.system.api.constant.Constant;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -16,6 +16,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
@@ -69,6 +70,7 @@ public class RayInsServiceImpl implements RayInsService {
} }


@Override @Override
@Transactional
public String deleteById(Long id) { public String deleteById(Long id) {
RayIns rayIns = rayInsDao.queryById(id); RayIns rayIns = rayInsDao.queryById(id);
if (rayIns == null) { if (rayIns == null) {
@@ -84,6 +86,7 @@ public class RayInsServiceImpl implements RayInsService {
rayIns.setState(Constant.State_invalid); rayIns.setState(Constant.State_invalid);
int update = rayInsDao.update(rayIns); int update = rayInsDao.update(rayIns);
if (update > 0) { if (update > 0) {
resourceOccupyService.deleteTaskState(Constant.TaskType_Ray, rayIns.getRayId(), id);
updateRayStatus(rayIns.getRayId()); updateRayStatus(rayIns.getRayId());
return "删除成功"; return "删除成功";
} else { } else {
@@ -264,7 +267,7 @@ public class RayInsServiceImpl implements RayInsService {
if (!StringUtils.equals(ins.getStatus(), Constant.Terminated)) { if (!StringUtils.equals(ins.getStatus(), Constant.Terminated)) {
ins.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : Constant.Pending); ins.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : Constant.Pending);
} }
if (StringUtils.equals(ins.getStatus(), "Error")) {
if (StringUtils.equals(ins.getStatus(), Constant.Error)) {
ins.setStatus(Constant.Failed); ins.setStatus(Constant.Failed);
} }
return ins; return ins;


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

@@ -3,7 +3,6 @@ package com.ruoyi.platform.service.impl;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.constant.Constant;
import com.ruoyi.platform.domain.Ray; import com.ruoyi.platform.domain.Ray;
import com.ruoyi.platform.domain.RayIns; import com.ruoyi.platform.domain.RayIns;
import com.ruoyi.platform.mapper.RayDao; import com.ruoyi.platform.mapper.RayDao;
@@ -16,6 +15,7 @@ import com.ruoyi.platform.utils.JacksonUtil;
import com.ruoyi.platform.utils.JsonUtils; import com.ruoyi.platform.utils.JsonUtils;
import com.ruoyi.platform.vo.RayParamVo; import com.ruoyi.platform.vo.RayParamVo;
import com.ruoyi.platform.vo.RayVo; import com.ruoyi.platform.vo.RayVo;
import com.ruoyi.system.api.constant.Constant;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@@ -24,6 +24,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
@@ -131,6 +132,7 @@ public class RayServiceImpl implements RayService {
} }


@Override @Override
@Transactional
public String delete(Long id) { public String delete(Long id) {
Ray ray = rayDao.getRayById(id); Ray ray = rayDao.getRayById(id);
if (ray == null) { if (ray == null) {
@@ -142,6 +144,7 @@ public class RayServiceImpl implements RayService {
throw new RuntimeException("无权限删除该实验"); throw new RuntimeException("无权限删除该实验");
} }
ray.setState(Constant.State_invalid); ray.setState(Constant.State_invalid);
resourceOccupyService.deleteTaskState(Constant.TaskType_Ray, id, null);
return rayDao.edit(ray) > 0 ? "删除成功" : "删除失败"; return rayDao.edit(ray) > 0 ? "删除成功" : "删除失败";
} }


@@ -156,7 +159,6 @@ public class RayServiceImpl implements RayService {
if (resourceOccupyService.haveResource(ray.getComputingResourceId(), 1)) { if (resourceOccupyService.haveResource(ray.getComputingResourceId(), 1)) {
RayParamVo rayParamVo = new RayParamVo(); RayParamVo rayParamVo = new RayParamVo();
BeanUtils.copyProperties(ray, rayParamVo); BeanUtils.copyProperties(ray, rayParamVo);
rayParamVo.setComputingResourceId(ray.getComputingResourceId());
rayParamVo.setCodeConfig(JsonUtils.jsonToMap(ray.getCodeConfig())); rayParamVo.setCodeConfig(JsonUtils.jsonToMap(ray.getCodeConfig()));
rayParamVo.setDataset(JsonUtils.jsonToMap(ray.getDataset())); rayParamVo.setDataset(JsonUtils.jsonToMap(ray.getDataset()));
rayParamVo.setModel(JsonUtils.jsonToMap(ray.getModel())); rayParamVo.setModel(JsonUtils.jsonToMap(ray.getModel()));
@@ -189,7 +191,7 @@ public class RayServiceImpl implements RayService {


// 插入记录到实验实例表 // 插入记录到实验实例表
RayIns rayIns = new RayIns(); RayIns rayIns = new RayIns();
rayIns.setRayId(ray.getId());
rayIns.setRayId(id);
rayIns.setArgoInsNs((String) metadata.get("namespace")); rayIns.setArgoInsNs((String) metadata.get("namespace"));
rayIns.setArgoInsName((String) metadata.get("name")); rayIns.setArgoInsName((String) metadata.get("name"));
rayIns.setParam(param); rayIns.setParam(param);


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

@@ -168,4 +168,9 @@ public class ResourceOccupyServiceImpl implements ResourceOccupyService {
resourceOccupy.setComputingResourceId(computingResourceId); resourceOccupy.setComputingResourceId(computingResourceId);
resourceOccupyDao.edit(resourceOccupy); resourceOccupyDao.edit(resourceOccupy);
} }

@Override
public void deleteTaskState(String taskType, Long taskId, Long taskInsId) {
resourceOccupyDao.deleteTaskState(taskType,taskId,taskInsId);
}
} }

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

@@ -14,6 +14,7 @@ import com.ruoyi.platform.service.ServiceService;
import com.ruoyi.platform.utils.ConvertUtil; import com.ruoyi.platform.utils.ConvertUtil;
import com.ruoyi.platform.utils.HttpUtils; import com.ruoyi.platform.utils.HttpUtils;
import com.ruoyi.platform.utils.JacksonUtil; import com.ruoyi.platform.utils.JacksonUtil;
import com.ruoyi.platform.utils.JsonUtils;
import com.ruoyi.platform.vo.serviceVos.ServiceCodeConfigVo; import com.ruoyi.platform.vo.serviceVos.ServiceCodeConfigVo;
import com.ruoyi.platform.vo.serviceVos.ServiceModelVo; import com.ruoyi.platform.vo.serviceVos.ServiceModelVo;
import com.ruoyi.platform.vo.serviceVos.ServiceVersionVo; import com.ruoyi.platform.vo.serviceVos.ServiceVersionVo;
@@ -26,8 +27,10 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
@@ -64,7 +67,7 @@ public class ServiceServiceImpl implements ServiceService {
} }


@Override @Override
public Page<ServiceVersionVo> queryByPageServiceVersion(ServiceVersion serviceVersion, int page, int size) {
public Page<ServiceVersionVo> queryByPageServiceVersion(ServiceVersion serviceVersion, int page, int size) throws IOException {
PageRequest pageRequest; PageRequest pageRequest;
if (StringUtils.isNotEmpty(serviceVersion.getRunState())) { if (StringUtils.isNotEmpty(serviceVersion.getRunState())) {
pageRequest = PageRequest.of(page, Integer.MAX_VALUE); pageRequest = PageRequest.of(page, Integer.MAX_VALUE);
@@ -169,7 +172,7 @@ public class ServiceServiceImpl implements ServiceService {
} }


@Override @Override
public ServiceVersionVo getServiceVersion(Long id) {
public ServiceVersionVo getServiceVersion(Long id) throws IOException {
ServiceVersion serviceVersion = serviceDao.getServiceVersionById(id); ServiceVersion serviceVersion = serviceDao.getServiceVersionById(id);
ServiceVersionVo serviceVersionVo = getServiceVersionVo(serviceVersion); ServiceVersionVo serviceVersionVo = getServiceVersionVo(serviceVersion);
com.ruoyi.platform.domain.Service service = serviceDao.getServiceById(serviceVersion.getServiceId()); com.ruoyi.platform.domain.Service service = serviceDao.getServiceById(serviceVersion.getServiceId());
@@ -195,7 +198,7 @@ public class ServiceServiceImpl implements ServiceService {
} }


@Override @Override
public Map<String, Object> serviceVersionCompare(Long id1, Long id2) throws IllegalAccessException {
public Map<String, Object> serviceVersionCompare(Long id1, Long id2) throws IllegalAccessException, IOException {
HashMap<String, Object> result = new HashMap<>(); HashMap<String, Object> result = new HashMap<>();


ServiceVersion serviceVersion1 = serviceDao.getServiceVersionById(id1); ServiceVersion serviceVersion1 = serviceDao.getServiceVersionById(id1);
@@ -243,11 +246,13 @@ public class ServiceServiceImpl implements ServiceService {
throw new RuntimeException("该服务下还有版本,不能删除"); throw new RuntimeException("该服务下还有版本,不能删除");
} }


resourceOccupyService.deleteTaskState(Constant.TaskType_Service, id, null);
service.setState(Constant.State_invalid); service.setState(Constant.State_invalid);
return serviceDao.updateService(service) > 0 ? "删除成功" : "删除失败"; return serviceDao.updateService(service) > 0 ? "删除成功" : "删除失败";
} }


@Override @Override
@Transactional
public String deleteServiceVersion(Long id) { public String deleteServiceVersion(Long id) {
ServiceVersion serviceVersion = serviceDao.getServiceVersionById(id); ServiceVersion serviceVersion = serviceDao.getServiceVersionById(id);
serviceVersion.setState(Constant.State_invalid); serviceVersion.setState(Constant.State_invalid);
@@ -260,6 +265,7 @@ public class ServiceServiceImpl implements ServiceService {
// if ((Integer) reqMap.get("code") == 200) { // if ((Integer) reqMap.get("code") == 200) {
// 结束扣积分 // 结束扣积分
resourceOccupyService.endDeduce(Constant.TaskType_Service, null, id, null, null); resourceOccupyService.endDeduce(Constant.TaskType_Service, null, id, null, null);
resourceOccupyService.deleteTaskState(Constant.TaskType_Service, serviceVersion.getServiceId(), id);
return serviceDao.updateServiceVersion(serviceVersion) > 0 ? "删除成功" : "删除失败"; return serviceDao.updateServiceVersion(serviceVersion) > 0 ? "删除成功" : "删除失败";
// } // }
} }
@@ -278,7 +284,8 @@ public class ServiceServiceImpl implements ServiceService {
paramMap.put("replicas", serviceVersion.getReplicas()); paramMap.put("replicas", serviceVersion.getReplicas());
paramMap.put("env", JSONObject.parseObject(serviceVersion.getEnvVariables())); paramMap.put("env", JSONObject.parseObject(serviceVersion.getEnvVariables()));
paramMap.put("code_config", JSONObject.parseObject(serviceVersion.getCodeConfig())); paramMap.put("code_config", JSONObject.parseObject(serviceVersion.getCodeConfig()));
paramMap.put("image", serviceVersion.getImage());
String image = (String)JsonUtils.jsonToMap(serviceVersion.getImage()).get("value");
paramMap.put("image", image);
paramMap.put("model", JSONObject.parseObject(serviceVersion.getModel())); paramMap.put("model", JSONObject.parseObject(serviceVersion.getModel()));
paramMap.put("service_type", service.getServiceType()); paramMap.put("service_type", service.getServiceType());
paramMap.put("deploy_type", serviceVersion.getDeployType()); paramMap.put("deploy_type", serviceVersion.getDeployType());
@@ -401,11 +408,12 @@ public class ServiceServiceImpl implements ServiceService {
serviceVersion.setModel(JSON.toJSONString(serviceVersionVo.getModel())); serviceVersion.setModel(JSON.toJSONString(serviceVersionVo.getModel()));
serviceVersion.setCodeConfig(JSON.toJSONString(serviceVersionVo.getCodeConfig())); serviceVersion.setCodeConfig(JSON.toJSONString(serviceVersionVo.getCodeConfig()));
serviceVersion.setEnvVariables(JSON.toJSONString(serviceVersionVo.getEnvVariables())); serviceVersion.setEnvVariables(JSON.toJSONString(serviceVersionVo.getEnvVariables()));
serviceVersion.setImage(JacksonUtil.toJSONString(serviceVersionVo.getImage()));


return serviceVersion; return serviceVersion;
} }


List<ServiceVersionVo> getServiceVersionVoList(List<ServiceVersion> serviceVersionList) {
List<ServiceVersionVo> getServiceVersionVoList(List<ServiceVersion> serviceVersionList) throws IOException {
List<ServiceVersionVo> result = new ArrayList<>(); List<ServiceVersionVo> result = new ArrayList<>();


for (ServiceVersion sv : serviceVersionList) { for (ServiceVersion sv : serviceVersionList) {
@@ -415,7 +423,7 @@ public class ServiceServiceImpl implements ServiceService {
return result; return result;
} }


ServiceVersionVo getServiceVersionVo(ServiceVersion sv) {
ServiceVersionVo getServiceVersionVo(ServiceVersion sv) throws IOException {
ServiceVersionVo serviceVersionVo = new ServiceVersionVo(); ServiceVersionVo serviceVersionVo = new ServiceVersionVo();
BeanUtils.copyProperties(sv, serviceVersionVo); BeanUtils.copyProperties(sv, serviceVersionVo);
ServiceModelVo serviceModelVo = JSON.parseObject(sv.getModel(), ServiceModelVo.class); ServiceModelVo serviceModelVo = JSON.parseObject(sv.getModel(), ServiceModelVo.class);
@@ -425,6 +433,7 @@ public class ServiceServiceImpl implements ServiceService {
serviceVersionVo.setCodeConfig(serviceCodeConfigVo); serviceVersionVo.setCodeConfig(serviceCodeConfigVo);


serviceVersionVo.setEnvVariables(JacksonUtil.parseJSONStr2Map(sv.getEnvVariables())); serviceVersionVo.setEnvVariables(JacksonUtil.parseJSONStr2Map(sv.getEnvVariables()));
serviceVersionVo.setImage(JsonUtils.jsonToMap(sv.getImage()));
return serviceVersionVo; return serviceVersionVo;
} }




+ 5
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java View File

@@ -23,6 +23,7 @@ import org.springframework.stereotype.Component;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.*; import java.util.*;


@@ -400,7 +401,7 @@ public class K8sClientUtil {
} }


// 创建配置好的Pod // 创建配置好的Pod
public Integer createConfiguredPod(String podName, String namespace, Integer port, String mountPath, V1PersistentVolumeClaim pvc, DevEnvironment devEnvironment, String dataPvcName, String datasetPath, String modelPath) {
public Integer createConfiguredPod(String podName, String namespace, Integer port, String mountPath, V1PersistentVolumeClaim pvc, DevEnvironment devEnvironment, String dataPvcName, String datasetPath, String modelPath) throws IOException {


//设置选择节点,pod反亲和性 //设置选择节点,pod反亲和性
Map<String, String> selector = new LinkedHashMap<>(); Map<String, String> selector = new LinkedHashMap<>();
@@ -494,6 +495,8 @@ public class K8sClientUtil {
//配置资源 //配置资源
V1ResourceRequirements v1ResourceRequirements = setPodResource(devEnvironment.getComputingResourceId()); V1ResourceRequirements v1ResourceRequirements = setPodResource(devEnvironment.getComputingResourceId());


String image = (String)JsonUtils.jsonToMap(devEnvironment.getImage()).get("value");

V1Pod pod = new V1PodBuilder() V1Pod pod = new V1PodBuilder()
.withNewMetadata() .withNewMetadata()
.withName(podName) .withName(podName)
@@ -502,7 +505,7 @@ public class K8sClientUtil {
.withNewSpec() .withNewSpec()
.addNewContainer() .addNewContainer()
.withName(podName) .withName(podName)
.withImage(devEnvironment.getImage())
.withImage(image)
.withPorts(new V1ContainerPort().containerPort(port).protocol("TCP")) .withPorts(new V1ContainerPort().containerPort(port).protocol("TCP"))
.withVolumeMounts(volumeMounts) .withVolumeMounts(volumeMounts)
.withResources(v1ResourceRequirements) .withResources(v1ResourceRequirements)


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

@@ -0,0 +1,65 @@
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 lombok.Data;

import java.util.Map;

@Data
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(description = "主动学习参数")
public class ActiveLearnParamVo {
private Map<String,Object> codeConfig;

private Map<String,Object> dataset;

private Map<String,Object> image;

private Map<String,Object> model;

private String taskType;

private String modelPy;

private String modelClassName;

private String classifierAlg;

private String regressorAlg;

private String datasetPy;

private String datasetClassName;

private Integer dataSize;

private Integer computingResourceId;

private Boolean shuffle;

private Integer trainSize;

private Integer nInitial;

private Integer nQueries;

private Integer nInstances;

private String queryStrategy;

private String lossPy;

private String lossClassName;

private Integer nCheckpoint;

private Integer batchSize;

private Integer epochs;

private Float lr;
}

+ 19
- 12
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ActiveLearnVo.java View File

@@ -21,22 +21,25 @@ public class ActiveLearnVo {
@ApiModelProperty(value = "实验描述") @ApiModelProperty(value = "实验描述")
private String description; private String description;


@ApiModelProperty(value = "任务类型:classification, regression")
@ApiModelProperty(value = "任务类型:classification或regression")
private String taskType; private String taskType;


@ApiModelProperty(value = "预训练模型")
private Map<String,Object> model;
@ApiModelProperty(value = "代码")
private Map<String, Object> codeConfig;

@ApiModelProperty(value = "预训练的模型")
private Map<String, Object> model;


@ApiModelProperty(value = "模型文件路径") @ApiModelProperty(value = "模型文件路径")
private String modelPy; private String modelPy;


@ApiModelProperty(value = "模型类名称")
@ApiModelProperty(value = "类名称")
private String modelClassName; private String modelClassName;


@ApiModelProperty(value = "分类算法") @ApiModelProperty(value = "分类算法")
private String classifierAlg; private String classifierAlg;


@ApiModelProperty(value = "分类算法")
@ApiModelProperty(value = "回归算法")
private String regressorAlg; private String regressorAlg;


@ApiModelProperty(value = "dataset文件路径") @ApiModelProperty(value = "dataset文件路径")
@@ -45,15 +48,16 @@ public class ActiveLearnVo {
@ApiModelProperty(value = "dataset类名") @ApiModelProperty(value = "dataset类名")
private String datasetClassName; private String datasetClassName;


@ApiModelProperty(value = "数据集")
private Map<String,Object> dataset;
@ApiModelProperty(value = "数据集文件路径")
private Map<String, Object> dataset;


@ApiModelProperty(value = "数据量") @ApiModelProperty(value = "数据量")
private Integer dataSize; private Integer dataSize;


@ApiModelProperty(value = "镜像") @ApiModelProperty(value = "镜像")
private Map<String,Object> image;
private Map<String, Object> image;


@ApiModelProperty(value = "计算资源id")
private Integer computingResourceId; private Integer computingResourceId;


@ApiModelProperty(value = "是否随机打乱") @ApiModelProperty(value = "是否随机打乱")
@@ -92,13 +96,16 @@ public class ActiveLearnVo {
@ApiModelProperty(value = "学习率") @ApiModelProperty(value = "学习率")
private Float lr; private Float lr;


private Integer state;

private String createBy; private String createBy;


private Date createTime;

private String updateBy; private String updateBy;


private Date createTime;

private Date updateTime; private Date updateTime;

private Integer state;

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

+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/DevEnvironmentVo.java View File

@@ -34,7 +34,7 @@ public class DevEnvironmentVo implements Serializable {
/** /**
* 所用镜像 * 所用镜像
*/ */
private String image;
private Map<String,Object> image;
/** /**
* 对应数据集 * 对应数据集
*/ */


+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ImageVo.java View File

@@ -39,8 +39,8 @@ public class ImageVo implements Serializable {
/** /**
* 镜像推送地址 * 镜像推送地址
*/ */
// @ApiModelProperty(name = "url")
// private String url;
@ApiModelProperty(name = "value")
private String value;


/** /**
* 镜像tag名称 * 镜像tag名称


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/serviceVos/ServiceVersionVo.java View File

@@ -24,7 +24,7 @@ public class ServiceVersionVo {


private ServiceModelVo model; private ServiceModelVo model;


private String image;
private Map<String, Object> image;


private String resource; private String resource;




+ 50
- 39
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnDaoMapper.xml View File

@@ -1,23 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.platform.mapper.ActiveLearnDao"> <mapper namespace="com.ruoyi.platform.mapper.ActiveLearnDao">
<insert id="save">
insert into active_learn(name, description, task_type, model, model_py, model_class_name, classifier_alg,
regressor_alg, dataset_py, dataset_class_name, dataset, data_size, image,
computing_resource_id,
shuffle, train_size, n_initial, n_queries, n_instances, query_strategy,
loss_path, loss_class_name, n_checkpoint, batch_size, epochs, lr, create_by, update_by)
values (#{activeLearn.name}, #{activeLearn.description}, #{activeLearn.taskType}, #{activeLearn.model},
#{activeLearn.modelPy},
#{activeLearn.modelClassName}, #{activeLearn.classifierAlg}, #{activeLearn.regressorAlg},
#{activeLearn.datasetPy}, #{activeLearn.datasetClassName}, #{activeLearn.dataset},
#{activeLearn.dataSize}, #{activeLearn.image}, #{activeLearn.computingResourceId},
#{activeLearn.shuffle}, #{activeLearn.trainSize},
#{activeLearn.nInitial}, #{activeLearn.nQueries}, #{activeLearn.nInstances},
#{activeLearn.queryStrategy},
#{activeLearn.lossPath}, #{activeLearn.lossClassName}, #{activeLearn.nCheckpoint},
#{activeLearn.batchSize}, #{activeLearn.epochs}, #{activeLearn.lr},
#{activeLearn.createBy}, #{activeLearn.updateBy})
<select id="count" resultType="java.lang.Long">
select count(1) from active_learn
<include refid="common_condition"></include>
</select>

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

<select id="getActiveLearnByName" resultType="com.ruoyi.platform.domain.ActiveLearn">
select *
from active_learn
where name = #{name}
and state = 1
</select>

<insert id="save" keyProperty="id" useGeneratedKeys="true">
insert into active_learn(name, description, task_type, framework_type,
code_config,
model, model_py, model_class_name,
classifier_alg, regressor_alg, dataset_py, dataset_class_name,
dataset, data_size, image, computing_resource_id, shuffle,
train_size, n_initial, n_queries, n_instances, query_strategy,
loss_py, loss_class_name, n_checkpoint, batch_size, epochs,
lr, create_by, update_by)
values (#{activeLearn.name}, #{activeLearn.description}, #{activeLearn.taskType}, #{activeLearn.frameworkType}, #{activeLearn.codeConfig},
#{activeLearn.model},
#{activeLearn.modelPy}, #{activeLearn.modelClassName}, #{activeLearn.classifierAlg},
#{activeLearn.regressorAlg},
#{activeLearn.datasetPy}, #{activeLearn.datasetClassName},
#{activeLearn.dataset}, #{activeLearn.dataSize},
#{activeLearn.image},
#{activeLearn.computingResourceId}, #{activeLearn.shuffle},
#{activeLearn.trainSize}, #{activeLearn.nInitial}, #{activeLearn.nQueries}, #{activeLearn.nInstances},
#{activeLearn.queryStrategy}, #{activeLearn.lossPy},
#{activeLearn.lossClassName}, #{activeLearn.nCheckpoint}, #{activeLearn.batchSize},
#{activeLearn.epochs}, #{activeLearn.lr}, #{activeLearn.createBy}, #{activeLearn.updateBy})
</insert> </insert>


<update id="edit"> <update id="edit">
@@ -32,6 +54,12 @@
<if test="activeLearn.taskType != null and activeLearn.taskType !=''"> <if test="activeLearn.taskType != null and activeLearn.taskType !=''">
task_type = #{activeLearn.taskType}, task_type = #{activeLearn.taskType},
</if> </if>
<if test="activeLearn.frameworkType != null and activeLearn.frameworkType !=''">
framework_type = #{activeLearn.frameworkType},
</if>
<if test="activeLearn.codeConfig != null and activeLearn.codeConfig !=''">
code_config = #{activeLearn.codeConfig},
</if>
<if test="activeLearn.model != null and activeLearn.model !=''"> <if test="activeLearn.model != null and activeLearn.model !=''">
model = #{activeLearn.model}, model = #{activeLearn.model},
</if> </if>
@@ -47,15 +75,15 @@
<if test="activeLearn.regressorAlg != null and activeLearn.regressorAlg !=''"> <if test="activeLearn.regressorAlg != null and activeLearn.regressorAlg !=''">
regressor_alg = #{activeLearn.regressorAlg}, regressor_alg = #{activeLearn.regressorAlg},
</if> </if>
<if test="activeLearn.dataset != null and activeLearn.dataset !=''">
dataset = #{activeLearn.dataset},
</if>
<if test="activeLearn.datasetPy != null and activeLearn.datasetPy !=''"> <if test="activeLearn.datasetPy != null and activeLearn.datasetPy !=''">
dataset_py = #{activeLearn.datasetPy}, dataset_py = #{activeLearn.datasetPy},
</if> </if>
<if test="activeLearn.datasetClassName != null and activeLearn.datasetClassName !=''"> <if test="activeLearn.datasetClassName != null and activeLearn.datasetClassName !=''">
dataset_class_name = #{activeLearn.datasetClassName}, dataset_class_name = #{activeLearn.datasetClassName},
</if> </if>
<if test="activeLearn.dataset != null and activeLearn.dataset !=''">
dataset = #{activeLearn.dataset},
</if>
<if test="activeLearn.dataSize != null"> <if test="activeLearn.dataSize != null">
data_size = #{activeLearn.dataSize}, data_size = #{activeLearn.dataSize},
</if> </if>
@@ -83,8 +111,8 @@
<if test="activeLearn.queryStrategy != null and activeLearn.queryStrategy !=''"> <if test="activeLearn.queryStrategy != null and activeLearn.queryStrategy !=''">
query_strategy = #{activeLearn.queryStrategy}, query_strategy = #{activeLearn.queryStrategy},
</if> </if>
<if test="activeLearn.lossPath != null and activeLearn.lossPath !=''">
loss_path = #{activeLearn.lossPath},
<if test="activeLearn.lossPy != null and activeLearn.lossPy !=''">
loss_py = #{activeLearn.lossPy},
</if> </if>
<if test="activeLearn.lossClassName != null and activeLearn.lossClassName !=''"> <if test="activeLearn.lossClassName != null and activeLearn.lossClassName !=''">
loss_class_name = #{activeLearn.lossClassName}, loss_class_name = #{activeLearn.lossClassName},
@@ -114,23 +142,6 @@
where id = #{activeLearn.id} where id = #{activeLearn.id}
</update> </update>


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

<select id="queryByPage" resultType="com.ruoyi.platform.domain.ActiveLearn">
select * from active_learn
<include refid="common_condition"></include>
</select>

<select id="getActiveLearnByName" resultType="com.ruoyi.platform.domain.ActiveLearn">
select *
from active_learn
where name = #{name}
and state = 1
</select>

<select id="getActiveLearnById" resultType="com.ruoyi.platform.domain.ActiveLearn"> <select id="getActiveLearnById" resultType="com.ruoyi.platform.domain.ActiveLearn">
select * select *
from active_learn from active_learn


+ 44
- 30
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnInsDaoMapper.xml View File

@@ -1,40 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.platform.mapper.ActiveLearnInsDao"> <mapper namespace="com.ruoyi.platform.mapper.ActiveLearnInsDao">
<insert id="insert">
insert into active_learn_ins(active_learn_id, status, param, argo_ins_name, argo_ins_ns, result_path)
values (#{activeLearnIns.activeLearnId}, #{activeLearnIns.status}, #{activeLearnIns.param},
#{activeLearnIns.argoInsName}, #{activeLearnIns.argoInsNs}, #{activeLearnIns.resultPath})
</insert>

<update id="update">
update active_learn_ins
<set>
<if test="activeLearnIns.state != null">
state = #{activeLearnIns.state},
</if>
<if test="activeLearnIns.updateTime != null">
update_time = #{activeLearnIns.updateTime},
</if>
<if test="activeLearnIns.finishTime != null">
finish_time = #{activeLearnIns.finishTime},
</if>
<if test="activeLearnIns.status != null and activeLearnIns.status != ''">
status = #{activeLearnIns.status},
</if>
<if test="activeLearnIns.resultPath != null and activeLearnIns.resultPath != ''">
result_path = #{activeLearnIns.resultPath},
</if>
</set>
where id = #{activeLearnIns.id}
</update>

<select id="count" resultType="java.lang.Long"> <select id="count" resultType="java.lang.Long">
select count(1) select count(1)
from active_learn_ins from active_learn_ins
<where> <where>
state = 1 state = 1
and active_learn_id = #{autoMlIns.activeLearnId}
and active_learn_id = #{activeLearnId}
</where> </where>
</select> </select>


@@ -42,12 +14,46 @@
select * from active_learn_ins select * from active_learn_ins
<where> <where>
state = 1 state = 1
and active_learn_id = #{autoMlIns.activeLearnId}
and active_learn_id = #{activeLearnId}
</where> </where>
order by update_time DESC order by update_time DESC
limit #{pageable.offset}, #{pageable.pageSize} limit #{pageable.offset}, #{pageable.pageSize}
</select> </select>


<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into active_learn_ins(active_learn_id, param, argo_ins_name, argo_ins_ns, node_status, node_result,
result_path, status)
values (#{activeLearnIns.activeLearnId}, #{activeLearnIns.param}, #{activeLearnIns.argoInsName},
#{activeLearnIns.argoInsNs},
#{activeLearnIns.nodeStatus}, #{activeLearnIns.nodeResult}, #{activeLearnIns.resultPath},
#{activeLearnIns.status})
</insert>

<update id="update">
update active_learn_ins
<set>
<if test="activeLearnIns.resultPath != null and activeLearnIns.resultPath != ''">
result_path = #{activeLearnIns.resultPath},
</if>
<if test="activeLearnIns.status != null and activeLearnIns.status != ''">
status = #{activeLearnIns.status},
</if>
<if test="activeLearnIns.nodeStatus != null and activeLearnIns.nodeStatus != ''">
node_status = #{activeLearnIns.nodeStatus},
</if>
<if test="activeLearnIns.nodeResult != null and activeLearnIns.nodeResult != ''">
node_result = #{activeLearnIns.nodeResult},
</if>
<if test="activeLearnIns.state != null">
state = #{activeLearnIns.state},
</if>
<if test="activeLearnIns.finishTime != null">
finish_time = #{activeLearnIns.finishTime},
</if>
</set>
where id = #{activeLearnIns.id}
</update>

<select id="queryById" resultType="com.ruoyi.platform.domain.ActiveLearnIns"> <select id="queryById" resultType="com.ruoyi.platform.domain.ActiveLearnIns">
select * from active_learn_ins select * from active_learn_ins
<where> <where>
@@ -62,4 +68,12 @@
and state = 1 and state = 1
order by update_time DESC limit 5 order by update_time DESC limit 5
</select> </select>

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

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

@@ -105,9 +105,6 @@
<if test="autoMl.targetColumns != null and autoMl.targetColumns !=''"> <if test="autoMl.targetColumns != null and autoMl.targetColumns !=''">
target_columns = #{autoMl.targetColumns}, target_columns = #{autoMl.targetColumns},
</if> </if>
<if test="autoMl.updateBy != null and autoMl.updateBy !=''">
update_by = #{autoMl.updateBy},
</if>
<if test="autoMl.state != null"> <if test="autoMl.state != null">
state = #{autoMl.state}, state = #{autoMl.state},
</if> </if>
@@ -123,6 +120,7 @@
<select id="queryByPage" resultType="com.ruoyi.platform.domain.AutoMl"> <select id="queryByPage" resultType="com.ruoyi.platform.domain.AutoMl">
select * from auto_ml select * from auto_ml
<include refid="common_condition"></include> <include refid="common_condition"></include>
order by create_time desc limit #{pageable.offset}, #{pageable.pageSize}
</select> </select>


<select id="getAutoMlById" resultType="com.ruoyi.platform.domain.AutoMl"> <select id="getAutoMlById" resultType="com.ruoyi.platform.domain.AutoMl">


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

@@ -214,5 +214,26 @@
delete from dev_environment where id = #{id} delete from dev_environment where id = #{id}
</delete> </delete>


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

<select id="queryByModelId" resultType="com.ruoyi.platform.domain.DevEnvironment">
select *
from dev_environment
where JSON_CONTAINS(model, #{modelId})
and state = 1
</select>

<select id="queryByImageId" resultType="com.ruoyi.platform.domain.DevEnvironment">
select *
from dev_environment
where JSON_CONTAINS(image, #{imageId})
and state = 1
</select>
</mapper> </mapper>



+ 3
- 2
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/RayDaoMapper.xml View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.platform.mapper.RayDao"> <mapper namespace="com.ruoyi.platform.mapper.RayDao">
<insert id="save">
<insert id="save" keyProperty="id" useGeneratedKeys="true">
insert into ray(name, description, dataset, model, code_config, main_py, num_samples, parameters, insert into ray(name, description, dataset, model, code_config, main_py, num_samples, parameters,
points_to_evaluate, storage_path, points_to_evaluate, storage_path,
search_alg, scheduler, metric, mode, max_t, search_alg, scheduler, metric, mode, max_t,
@@ -94,11 +94,12 @@
<select id="queryByPage" resultType="com.ruoyi.platform.domain.Ray"> <select id="queryByPage" resultType="com.ruoyi.platform.domain.Ray">
select * from ray select * from ray
<include refid="common_condition"></include> <include refid="common_condition"></include>
order by create_time desc limit #{pageable.offset}, #{pageable.pageSize}
</select> </select>


<select id="getRayByName" resultType="com.ruoyi.platform.domain.Ray"> <select id="getRayByName" resultType="com.ruoyi.platform.domain.Ray">
select * select *
from ray _
from ray
where name = #{name} where name = #{name}
and state = 1 and state = 1
</select> </select>


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

@@ -60,6 +60,17 @@
where id = #{id} where id = #{id}
</update> </update>


<update id="deleteTaskState">
update resource_occupy set task_state = 0
where task_type = #{taskType}
<if test="taskId != null and taskId !=''">
and task_id = #{taskId}
</if>
<if test="taskInsId != null and taskInsId !=''">
and task_ins_id = #{taskInsId}
</if>
</update>

<select id="haveResource" resultType="java.lang.Boolean"> <select id="haveResource" resultType="java.lang.Boolean">
select case when used + #{need} &lt;= total then TRUE else FALSE end select case when used + #{need} &lt;= total then TRUE else FALSE end
from resource from resource


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

@@ -190,4 +190,34 @@
set run_state = #{runState} set run_state = #{runState}
where deployment_name = #{deploymentName} where deployment_name = #{deploymentName}
</update> </update>

<select id="queryByModelId" resultType="java.lang.String">
select concat(b.service_name, ':', a.version)
from service_version a,
service b
where JSON_CONTAINS(a.model, #{modelId})
and a.state = 1
and b.state = 1
and a.service_id = b.id
</select>

<select id="queryByImageId" resultType="java.lang.String">
select concat(b.service_name, ':', a.version)
from service_version a,
service b
where JSON_CONTAINS(a.image, #{imageId})
and a.state = 1
and b.state = 1
and a.service_id = b.id
</select>

<select id="queryByCodeConfig" resultType="java.lang.String">
select concat(b.service_name, ':', a.version)
from service_version a,
service b
where JSON_CONTAINS(a.code_config, #{codeConfig})
and a.state = 1
and b.state = 1
and a.service_id = b.id
</select>
</mapper> </mapper>

Loading…
Cancel
Save