Browse Source

数据集删除时,判断是否有自动机器学习使用

dev-complex-computation
chenzhihang 1 year ago
parent
commit
78d4bad733
3 changed files with 32 additions and 0 deletions
  1. +2
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/AutoMlDao.java
  2. +23
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java
  3. +7
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml

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

@@ -18,4 +18,6 @@ public interface AutoMlDao {
int save(@Param("autoMl") AutoMl autoMl);

int edit(@Param("autoMl") AutoMl autoMl);

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

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

@@ -1,12 +1,16 @@
package com.ruoyi.platform.service.impl;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.platform.constant.Constant;
import com.ruoyi.platform.domain.AssetWorkflow;
import com.ruoyi.platform.domain.AutoMl;
import com.ruoyi.platform.domain.Dataset;
import com.ruoyi.platform.domain.DatasetTempStorage;
import com.ruoyi.platform.domain.dependencydomain.TrainTaskDepency;
import com.ruoyi.platform.mapper.AssetWorkflowDao;
import com.ruoyi.platform.mapper.AutoMlDao;
import com.ruoyi.platform.service.DatasetTempStorageService;
import com.ruoyi.platform.service.GitService;
import com.ruoyi.platform.service.NewDatasetService;
@@ -54,6 +58,8 @@ public class NewDatasetServiceImpl implements NewDatasetService {
private GitService gitService;
@Resource
private AssetWorkflowDao assetWorkflowDao;
@Resource
private AutoMlDao autoMlDao;

@Value("${spring.redis.host}")
private String redisHost;
@@ -408,6 +414,14 @@ public class NewDatasetServiceImpl implements NewDatasetService {
throw new Exception("该数据集被流水线:" + workflows + "使用,不能删除,请先删除流水线。");
}

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

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

@@ -424,6 +438,15 @@ public class NewDatasetServiceImpl implements NewDatasetService {
throw new Exception("该数据集版本被流水线:" + workflows + "使用,不能删除,请先删除流水线。");
}

HashMap<String, String> map = new HashMap<>();
map.put("id", String.valueOf(repoId));
map.put("version", version);
List<AutoMl> autoMlList = autoMlDao.queryByDatasetId(JSON.toJSONString(map));
if(autoMlList !=null && !autoMlList.isEmpty()) {
String autoMls = String.join(",", autoMlList.stream().map(AutoMl::getMlName).collect(Collectors.toSet()));
throw new Exception("该数据集版本被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习。");
}

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


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

@@ -135,6 +135,13 @@
and state = 1
</select>

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

<sql id="common_condition">
<where>
state = 1


Loading…
Cancel
Save