| @@ -18,4 +18,12 @@ public interface RayDao { | |||||
| int save(@Param("ray") Ray ray); | int save(@Param("ray") Ray ray); | ||||
| int edit(@Param("ray") Ray ray); | int edit(@Param("ray") Ray ray); | ||||
| List<Ray> queryByDatasetId(@Param("datasetId") String datasetId); | |||||
| List<Ray> queryByModelId(@Param("modelId") String modelId); | |||||
| List<Ray> queryByImageId(@Param("imageId") String imageId); | |||||
| List<Ray> queryByCodeConfig(@Param("codeConfig") String codeConfig); | |||||
| } | } | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.ruoyi.platform.service.impl; | package com.ruoyi.platform.service.impl; | ||||
| import com.alibaba.fastjson2.JSON; | |||||
| import com.ruoyi.common.security.utils.SecurityUtils; | import com.ruoyi.common.security.utils.SecurityUtils; | ||||
| import com.ruoyi.platform.constant.Constant; | import com.ruoyi.platform.constant.Constant; | ||||
| import com.ruoyi.platform.domain.AssetWorkflow; | import com.ruoyi.platform.domain.AssetWorkflow; | ||||
| @@ -13,9 +14,12 @@ 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 com.ruoyi.platform.mapper.RayDao; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| @@ -26,6 +30,8 @@ public class CodeConfigServiceImpl implements CodeConfigService { | |||||
| private CodeConfigDao codeConfigDao; | private CodeConfigDao codeConfigDao; | ||||
| @Resource | @Resource | ||||
| private AssetWorkflowDao assetWorkflowDao; | private AssetWorkflowDao assetWorkflowDao; | ||||
| @Resource | |||||
| private RayDao rayDao; | |||||
| @Override | @Override | ||||
| public Page<CodeConfig> queryByPage(CodeConfig codeConfig, PageRequest pageRequest) { | public Page<CodeConfig> queryByPage(CodeConfig codeConfig, PageRequest pageRequest) { | ||||
| @@ -88,6 +94,14 @@ public class CodeConfigServiceImpl implements CodeConfigService { | |||||
| throw new Exception("该代码配置被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); | throw new Exception("该代码配置被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); | ||||
| } | } | ||||
| HashMap<String, String> map = new HashMap<>(); | |||||
| map.put("code_path", codeConfig.getGitUrl()); | |||||
| List<Ray> rayList = rayDao.queryByCodeConfig(JSON.toJSONString(map)); | |||||
| if (rayList != null && !rayList.isEmpty()) { | |||||
| String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); | |||||
| throw new Exception("该代码配置被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); | |||||
| } | |||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| String username = loginUser.getUsername(); | String username = loginUser.getUsername(); | ||||
| String createBy = codeConfig.getCreateBy(); | String createBy = codeConfig.getCreateBy(); | ||||
| @@ -1,16 +1,11 @@ | |||||
| package com.ruoyi.platform.service.impl; | package com.ruoyi.platform.service.impl; | ||||
| import com.alibaba.fastjson2.JSON; | |||||
| import com.alibaba.fastjson2.util.DateUtils; | import com.alibaba.fastjson2.util.DateUtils; | ||||
| import com.ruoyi.common.security.utils.SecurityUtils; | import com.ruoyi.common.security.utils.SecurityUtils; | ||||
| import com.ruoyi.platform.constant.Constant; | import com.ruoyi.platform.constant.Constant; | ||||
| import com.ruoyi.platform.domain.AssetWorkflow; | |||||
| import com.ruoyi.platform.domain.DevEnvironment; | |||||
| import com.ruoyi.platform.domain.Image; | |||||
| import com.ruoyi.platform.domain.ImageVersion; | |||||
| import com.ruoyi.platform.mapper.AssetWorkflowDao; | |||||
| import com.ruoyi.platform.mapper.DevEnvironmentDao; | |||||
| import com.ruoyi.platform.mapper.ImageDao; | |||||
| import com.ruoyi.platform.mapper.ImageVersionDao; | |||||
| 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; | ||||
| @@ -53,10 +48,10 @@ public class ImageServiceImpl implements ImageService { | |||||
| private ImageVersionDao imageVersionDao; | private ImageVersionDao imageVersionDao; | ||||
| @Resource | @Resource | ||||
| private DevEnvironmentDao devEnvironmentDao; | private DevEnvironmentDao devEnvironmentDao; | ||||
| @Resource | @Resource | ||||
| private AssetWorkflowDao assetWorkflowDao; | private AssetWorkflowDao assetWorkflowDao; | ||||
| @Resource | |||||
| private RayDao rayDao; | |||||
| @Resource | @Resource | ||||
| private ImageVersionService imageVersionService; | private ImageVersionService imageVersionService; | ||||
| @@ -182,6 +177,14 @@ public class ImageServiceImpl implements ImageService { | |||||
| throw new Exception("该镜像被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); | throw new Exception("该镜像被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); | ||||
| } | } | ||||
| HashMap<String, String> map = new HashMap<>(); | |||||
| map.put("id", String.valueOf(id)); | |||||
| List<Ray> rayList = rayDao.queryByImageId(JSON.toJSONString(map)); | |||||
| if (rayList != null && !rayList.isEmpty()) { | |||||
| String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); | |||||
| throw new Exception("该镜像被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); | |||||
| } | |||||
| //判断权限,只有admin和创建者本身可以删除该数据集 | //判断权限,只有admin和创建者本身可以删除该数据集 | ||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| String username = loginUser.getUsername(); | String username = loginUser.getUsername(); | ||||
| @@ -1,23 +1,25 @@ | |||||
| package com.ruoyi.platform.service.impl; | package com.ruoyi.platform.service.impl; | ||||
| import com.alibaba.fastjson2.JSON; | |||||
| import com.ruoyi.common.security.utils.SecurityUtils; | import com.ruoyi.common.security.utils.SecurityUtils; | ||||
| import com.ruoyi.platform.constant.Constant; | import com.ruoyi.platform.constant.Constant; | ||||
| import com.ruoyi.platform.domain.AssetWorkflow; | import com.ruoyi.platform.domain.AssetWorkflow; | ||||
| import com.ruoyi.platform.domain.ImageVersion; | import com.ruoyi.platform.domain.ImageVersion; | ||||
| import com.ruoyi.platform.domain.Ray; | |||||
| import com.ruoyi.platform.mapper.AssetWorkflowDao; | import com.ruoyi.platform.mapper.AssetWorkflowDao; | ||||
| import com.ruoyi.platform.mapper.ImageDao; | |||||
| import com.ruoyi.platform.mapper.ImageVersionDao; | import com.ruoyi.platform.mapper.ImageVersionDao; | ||||
| import com.ruoyi.platform.domain.ModelsVersion; | |||||
| import com.ruoyi.platform.mapper.RayDao; | |||||
| import com.ruoyi.platform.service.ImageVersionService; | import com.ruoyi.platform.service.ImageVersionService; | ||||
| 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; | ||||
| import java.util.HashMap; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| @@ -31,9 +33,10 @@ import java.util.stream.Collectors; | |||||
| public class ImageVersionServiceImpl implements ImageVersionService { | public class ImageVersionServiceImpl implements ImageVersionService { | ||||
| @Resource | @Resource | ||||
| private ImageVersionDao imageVersionDao; | private ImageVersionDao imageVersionDao; | ||||
| @Resource | @Resource | ||||
| private AssetWorkflowDao assetWorkflowDao; | private AssetWorkflowDao assetWorkflowDao; | ||||
| @Resource | |||||
| private RayDao rayDao; | |||||
| /** | /** | ||||
| * 通过ID查询单条数据 | * 通过ID查询单条数据 | ||||
| @@ -50,7 +53,7 @@ public class ImageVersionServiceImpl implements ImageVersionService { | |||||
| * 分页查询 | * 分页查询 | ||||
| * | * | ||||
| * @param imageVersion 筛选条件 | * @param imageVersion 筛选条件 | ||||
| * @param pageRequest 分页对象 | |||||
| * @param pageRequest 分页对象 | |||||
| * @return 查询结果 | * @return 查询结果 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| @@ -60,14 +63,14 @@ public class ImageVersionServiceImpl implements ImageVersionService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public List<ImageVersion> queryByImageId(Integer imageId){ | |||||
| public List<ImageVersion> queryByImageId(Integer imageId) { | |||||
| return imageVersionDao.queryByImageId(imageId); | return imageVersionDao.queryByImageId(imageId); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public String removeById(Integer id) throws Exception { | public String removeById(Integer id) throws Exception { | ||||
| ImageVersion imageVersion = this.imageVersionDao.queryById(id); | ImageVersion imageVersion = this.imageVersionDao.queryById(id); | ||||
| if (imageVersion == null){ | |||||
| if (imageVersion == null) { | |||||
| return "该版本下模型文件信息不存在"; | return "该版本下模型文件信息不存在"; | ||||
| } | } | ||||
| @@ -77,16 +80,24 @@ public class ImageVersionServiceImpl implements ImageVersionService { | |||||
| throw new Exception("该镜像版本被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); | throw new Exception("该镜像版本被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); | ||||
| } | } | ||||
| HashMap<String, String> map = new HashMap<>(); | |||||
| map.put("version", String.valueOf(id)); | |||||
| List<Ray> rayList = rayDao.queryByImageId(JSON.toJSONString(map)); | |||||
| if (rayList != null && !rayList.isEmpty()) { | |||||
| String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); | |||||
| throw new Exception("该镜像版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); | |||||
| } | |||||
| //判断权限,只有admin和创建者本身可以删除该数据集 | //判断权限,只有admin和创建者本身可以删除该数据集 | ||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| String username = loginUser.getUsername(); | String username = loginUser.getUsername(); | ||||
| String createdBy = imageVersion.getCreateBy(); | String createdBy = imageVersion.getCreateBy(); | ||||
| if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | |||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createdBy))) { | |||||
| return "无权限删除该版本下模型信息"; | return "无权限删除该版本下模型信息"; | ||||
| } | } | ||||
| imageVersion.setState(0); | imageVersion.setState(0); | ||||
| return this.imageVersionDao.update(imageVersion)>0?"删除成功":"删除失败"; | |||||
| return this.imageVersionDao.update(imageVersion) > 0 ? "删除成功" : "删除失败"; | |||||
| } | } | ||||
| @@ -117,7 +128,7 @@ public class ImageVersionServiceImpl implements ImageVersionService { | |||||
| @Override | @Override | ||||
| public ImageVersion update(ImageVersion imageVersion) { | public ImageVersion update(ImageVersion imageVersion) { | ||||
| int currentState = imageVersion.getState(); | int currentState = imageVersion.getState(); | ||||
| if(currentState == 0){ | |||||
| if (currentState == 0) { | |||||
| throw new RuntimeException("镜像版本已被删除,无法更新。"); | throw new RuntimeException("镜像版本已被删除,无法更新。"); | ||||
| } | } | ||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| @@ -9,10 +9,7 @@ import com.ruoyi.platform.annotations.CheckDuplicate; | |||||
| import com.ruoyi.platform.constant.Constant; | import com.ruoyi.platform.constant.Constant; | ||||
| import com.ruoyi.platform.domain.*; | import com.ruoyi.platform.domain.*; | ||||
| import com.ruoyi.platform.domain.dependencydomain.TrainTaskDepency; | import com.ruoyi.platform.domain.dependencydomain.TrainTaskDepency; | ||||
| import com.ruoyi.platform.mapper.AssetWorkflowDao; | |||||
| import com.ruoyi.platform.mapper.ModelDependency1Dao; | |||||
| import com.ruoyi.platform.mapper.ModelsDao; | |||||
| import com.ruoyi.platform.mapper.ModelsVersionDao; | |||||
| import com.ruoyi.platform.mapper.*; | |||||
| import com.ruoyi.platform.service.*; | import com.ruoyi.platform.service.*; | ||||
| import com.ruoyi.platform.utils.*; | import com.ruoyi.platform.utils.*; | ||||
| import com.ruoyi.platform.vo.*; | import com.ruoyi.platform.vo.*; | ||||
| @@ -67,7 +64,8 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| private ModelsDao modelsDao; | private ModelsDao modelsDao; | ||||
| @Resource | @Resource | ||||
| private ModelsVersionDao modelsVersionDao; | private ModelsVersionDao modelsVersionDao; | ||||
| @Resource | |||||
| private RayDao rayDao; | |||||
| @Resource | @Resource | ||||
| private ModelsVersionService modelsVersionService; | private ModelsVersionService modelsVersionService; | ||||
| @@ -1154,6 +1152,14 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| throw new Exception("该模型被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); | throw new Exception("该模型被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); | ||||
| } | } | ||||
| HashMap<String, String> queryMap = new HashMap<>(); | |||||
| queryMap.put("id", String.valueOf(repoId)); | |||||
| List<Ray> rayList = rayDao.queryByModelId(JSON.toJSONString(queryMap)); | |||||
| if (rayList != null && !rayList.isEmpty()) { | |||||
| String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); | |||||
| throw new Exception("该模型被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); | |||||
| } | |||||
| String token = gitService.checkoutToken(); | String token = gitService.checkoutToken(); | ||||
| gitService.deleteProject(token, owner, identifier); | gitService.deleteProject(token, owner, identifier); | ||||
| //删除模型依赖 | //删除模型依赖 | ||||
| @@ -1177,6 +1183,15 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| throw new Exception("该模型版本被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); | throw new Exception("该模型版本被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); | ||||
| } | } | ||||
| HashMap<String, String> queryMap = new HashMap<>(); | |||||
| queryMap.put("id", String.valueOf(repoId)); | |||||
| queryMap.put("version", version); | |||||
| List<Ray> rayList = rayDao.queryByModelId(JSON.toJSONString(queryMap)); | |||||
| if (rayList != null && !rayList.isEmpty()) { | |||||
| String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); | |||||
| throw new Exception("该数据集版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); | |||||
| } | |||||
| String token = gitService.checkoutToken(); | String token = gitService.checkoutToken(); | ||||
| String rootPath = Paths.get(localPath + "/" + relativePath).getParent().toString(); | String rootPath = Paths.get(localPath + "/" + relativePath).getParent().toString(); | ||||
| gitService.deleteBranch(token, owner, identifier, version, rootPath); | gitService.deleteBranch(token, owner, identifier, version, rootPath); | ||||
| @@ -4,12 +4,10 @@ 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.constant.Constant; | 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.*; | |||||
| import com.ruoyi.platform.mapper.AssetWorkflowDao; | import com.ruoyi.platform.mapper.AssetWorkflowDao; | ||||
| import com.ruoyi.platform.mapper.AutoMlDao; | import com.ruoyi.platform.mapper.AutoMlDao; | ||||
| import com.ruoyi.platform.mapper.RayDao; | |||||
| 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; | ||||
| @@ -56,6 +54,8 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| private AssetWorkflowDao assetWorkflowDao; | private AssetWorkflowDao assetWorkflowDao; | ||||
| @Resource | @Resource | ||||
| private AutoMlDao autoMlDao; | private AutoMlDao autoMlDao; | ||||
| @Resource | |||||
| private RayDao rayDao; | |||||
| @Value("${spring.redis.host}") | @Value("${spring.redis.host}") | ||||
| private String redisHost; | private String redisHost; | ||||
| @@ -421,6 +421,12 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| throw new Exception("该数据集被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习。"); | throw new Exception("该数据集被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习。"); | ||||
| } | } | ||||
| List<Ray> rayList = rayDao.queryByDatasetId(JSON.toJSONString(map)); | |||||
| if (rayList != null && !rayList.isEmpty()) { | |||||
| String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); | |||||
| throw new Exception("该数据集被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); | |||||
| } | |||||
| String token = gitService.checkoutToken(); | String token = gitService.checkoutToken(); | ||||
| gitService.deleteProject(token, owner, repo); | gitService.deleteProject(token, owner, repo); | ||||
| @@ -446,6 +452,12 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| throw new Exception("该数据集版本被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习。"); | throw new Exception("该数据集版本被自动机器学习:" + autoMls + "使用,不能删除,请先删除自动机器学习。"); | ||||
| } | } | ||||
| List<Ray> rayList = rayDao.queryByDatasetId(JSON.toJSONString(map)); | |||||
| if (rayList != null && !rayList.isEmpty()) { | |||||
| String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); | |||||
| throw new Exception("该数据集版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); | |||||
| } | |||||
| 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); | ||||
| @@ -109,6 +109,34 @@ | |||||
| where id = #{id} | where id = #{id} | ||||
| </select> | </select> | ||||
| <select id="queryByDatasetId" resultType="com.ruoyi.platform.domain.Ray"> | |||||
| select * | |||||
| from ray | |||||
| where JSON_CONTAINS(dataset, #{datasetId}) | |||||
| and state = 1 | |||||
| </select> | |||||
| <select id="queryByModelId" resultType="com.ruoyi.platform.domain.Ray"> | |||||
| select * | |||||
| from ray | |||||
| where JSON_CONTAINS(model, #{modelId}) | |||||
| and state = 1 | |||||
| </select> | |||||
| <select id="queryByImageId" resultType="com.ruoyi.platform.domain.Ray"> | |||||
| select * | |||||
| from ray | |||||
| where JSON_CONTAINS(image, #{imageId}) | |||||
| and state = 1 | |||||
| </select> | |||||
| <select id="queryByCodeConfig" resultType="com.ruoyi.platform.domain.Ray"> | |||||
| select * | |||||
| from ray | |||||
| where JSON_CONTAINS(code_config, #{codeConfig}) | |||||
| and state = 1 | |||||
| </select> | |||||
| <sql id="common_condition"> | <sql id="common_condition"> | ||||
| <where> | <where> | ||||
| state = 1 | state = 1 | ||||