update dataset version

This commit is contained in:
fanshuai 2024-09-06 16:39:52 +08:00
commit 53046a939a
13 changed files with 287 additions and 97 deletions

View File

@ -0,0 +1,27 @@
package com.ruoyi.platform.domain;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;
import java.io.Serializable;
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
@Data
public class ModelDependency1 implements Serializable {
private Long id;
private String parentModel;
private String modelName;
private String version;
private Integer repoId;
private String identifier;
private String owner;
private Integer state;
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.platform.mapper;
import com.ruoyi.platform.domain.ModelDependency1;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ModelDependency1Dao {
int insert(ModelDependency1 modelDependency1);
List<ModelDependency1> queryByModelName(@Param("modelName") String modelName);
ModelDependency1 queryByModelNameAndVersion(@Param("repoId") Integer repoId, @Param("modelName") String modelName, @Param("version") String version);
List<ModelDependency1> queryByParentModel(@Param("parentModel") String parentModel);
int deleteModel(@Param("repoId") Integer repoId, @Param("identifier")String identifier, @Param("owner") String owner, @Param("version") String version);
int deleteModelDependency(@Param("repoId") Integer repoId, @Param("identifier")String identifier, @Param("owner") String owner, @Param("version") String version);
}

View File

@ -11,17 +11,17 @@ public interface GitService {
String login(String username, String password);
//输入token项目名tag创建新项目,返回项目地址
Map createProject(String token, GitProjectVo gitProjectVo) throws Exception;
Map createProject(GitProjectVo gitProjectVo) throws Exception;
void createBranch(String token,String owner, String projectName, String branchName, String oldBranchName) throws Exception;
void createBranch(String owner, String projectName, String branchName, String oldBranchName) throws Exception;
void createTopic(String token, Integer id, String topicName) throws Exception;
void createTopic(Integer id, String topicName) throws Exception;
List<Map<String, Object>> getBrancheList(String token, String owner, String projectName) throws Exception;
List<Map<String, Object>> getBrancheList(String owner, String projectName) throws Exception;
void deleteProject(String token, String owner, String projectName) throws Exception;
void deleteProject(String owner, String projectName) throws Exception;
void deleteBranch(String token, String owner,String projectName ,String branchName) throws Exception;
void deleteBranch(String owner,String projectName ,String branchName) throws Exception;
Map getUserInfo(String token) throws Exception;
Map getUserInfo() throws Exception;
}

View File

@ -67,7 +67,7 @@ public class DatasetServiceImpl implements DatasetService {
private String bucketName;
@Resource
private MinioUtil minioUtil;
private MinioUtil minioUtil;
/**
* 通过ID查询单条数据
@ -105,8 +105,8 @@ public class DatasetServiceImpl implements DatasetService {
/**
* 分页查询
*
* @param dataset 筛选条件
* @param pageRequest 分页对象
* @param dataset 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
@Override
@ -146,7 +146,7 @@ public class DatasetServiceImpl implements DatasetService {
@Override
public Dataset update(Dataset dataset) {
int currentState = dataset.getState();
if (currentState == 0){
if (currentState == 0) {
throw new RuntimeException("数据集已被删除,无法更新。");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
@ -170,7 +170,7 @@ public class DatasetServiceImpl implements DatasetService {
@Override
public String removeById(Integer id) throws Exception {
Dataset dataset = this.datasetDao.queryById(id);
if (dataset == null){
if (dataset == null) {
throw new Exception("数据集不存在");
}
@ -178,7 +178,7 @@ public class DatasetServiceImpl implements DatasetService {
LoginUser loginUser = SecurityUtils.getLoginUser();
String username = loginUser.getUsername();
String createdBy = dataset.getCreateBy();
if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){
if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createdBy))) {
throw new Exception("无权限删除该数据集");
}
if (datasetVersionService.queryByDatasetId(id).size()>0){
@ -432,4 +432,5 @@ public class DatasetServiceImpl implements DatasetService {
}
return results;
}
}

View File

@ -39,7 +39,7 @@ public class GitServiceImpl implements GitService {
params.put("client_secret", "L3wBKTNnRo-wPen7bxR3F1myCvtVDgpWa6MnpfyWeJE");
try {
// 发送POST请求
String req = HttpUtils.sendPostRequest("https://www.gitlink.org.cn/oauth/token",null, JsonUtils.mapToJson(params));
String req = HttpUtils.sendPostRequest("https://www.gitlink.org.cn/oauth/token", null, JsonUtils.mapToJson(params));
// 解析响应JSON
if (StringUtils.isEmpty(req)) {
throw new RuntimeException("终止响应内容为空。");
@ -51,7 +51,7 @@ public class GitServiceImpl implements GitService {
String accessToken = (String) runResMap.get("access_token");
//通过access_token获取用户信息
String userReq = HttpUtils.sendGetWithToken("https://www.gitlink.org.cn/api/users/get_user_info.json",null, accessToken);
String userReq = HttpUtils.sendGetWithToken("https://www.gitlink.org.cn/api/users/get_user_info.json", null, accessToken);
if (StringUtils.isEmpty(userReq)) {
throw new RuntimeException("终止响应内容为空。");
}
@ -59,8 +59,8 @@ public class GitServiceImpl implements GitService {
String ci4sUsername = loginUser.getUsername();
// 将access_token存入Redis
Jedis jedis = new Jedis(redisHost);
jedis.set(ci4sUsername+"_gitToken", accessToken);
jedis.set(ci4sUsername+"_gitUserInfo", userReq);
jedis.set(ci4sUsername + "_gitToken", accessToken);
jedis.set(ci4sUsername + "_gitUserInfo", userReq);
return accessToken;
} catch (Exception e) {
log.error("登录GitLink失败。", e);
@ -68,38 +68,68 @@ public class GitServiceImpl implements GitService {
}
}
public String checkoutToken() {
Jedis jedis = new Jedis(redisHost);
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
String token = jedis.get(ci4sUsername + "_gitToken");
String gitLinkUsername = loginUser.getSysUser().getGitLinkUsername();
String gitLinkPassword = loginUser.getSysUser().getGitLinkPassword();
if (StringUtils.isEmpty(token)) {
login(gitLinkUsername, gitLinkPassword);
token = jedis.get(ci4sUsername + "_gitToken");
} else {
try {
Map userInfo = getUserInfo();
if (userInfo == null || (userInfo.get("status") != null && 401 == (Integer) userInfo.get("status"))) {
login(gitLinkUsername, gitLinkPassword);
token = jedis.get(ci4sUsername + "_gitToken");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return token;
}
@Override
public Map createProject(String token, GitProjectVo gitProjectVo) throws Exception {
String userReq = HttpUtils.sendPostWithToken("https://www.gitlink.org.cn/api/projects.json",JsonUtils.objectToJson(gitProjectVo),token);
public Map createProject(GitProjectVo gitProjectVo) throws Exception {
String token = this.checkoutToken();
String userReq = HttpUtils.sendPostWithToken("https://www.gitlink.org.cn/api/projects.json", JsonUtils.objectToJson(gitProjectVo), token);
return JsonUtils.jsonToMap(userReq);
}
@Override
public void createBranch(String token,String owner, String projectName, String branchName, String oldBranchName) throws Exception {
public void createBranch(String owner, String projectName, String branchName, String oldBranchName) throws Exception {
//https://www.gitlink.org.cn/api/v1/fanshuai/testdssa8755/branches.json
// {
// "new_branch_name": "SsS",
// "old_branch_name": "master"
// }
String createBranchUrl = "https://www.gitlink.org.cn/api/v1/"+ owner + "/" + projectName + "/branches.json";
String token = this.checkoutToken();
String createBranchUrl = "https://www.gitlink.org.cn/api/v1/" + owner + "/" + projectName + "/branches.json";
Map<String, Object> resMap = new HashMap<>();
resMap.put("new_branch_name", branchName);
resMap.put("old_branch_name", oldBranchName);
String req = HttpUtils.sendPostWithToken(createBranchUrl,JsonUtils.objectToJson(resMap),token);
String req = HttpUtils.sendPostWithToken(createBranchUrl, JsonUtils.objectToJson(resMap), token);
}
@Override
public void createTopic(String token, Integer id, String topicName) throws Exception {
public void createTopic(Integer id, String topicName) throws Exception {
// https://www.gitlink.org.cn/api/v1/project_topics.json
String token = this.checkoutToken();
Map<String, Object> resMap = new HashMap<>();
resMap.put("project_id", id);
resMap.put("name", topicName);
String req = HttpUtils.sendPostWithToken("https://www.gitlink.org.cn/api/v1/project_topics.json",JsonUtils.objectToJson(resMap),token);
String req = HttpUtils.sendPostWithToken("https://www.gitlink.org.cn/api/v1/project_topics.json", JsonUtils.objectToJson(resMap), token);
}
@Override
public List<Map<String, Object>> getBrancheList(String token, String owner, String projectName) throws Exception {
String req = HttpUtils.sendGetWithToken("https://www.gitlink.org.cn/api/v1/"+owner+"/"+projectName+"/branches/all.json",null, token);
public List<Map<String, Object>> getBrancheList(String owner, String projectName) throws Exception {
String token = checkoutToken();
String req = HttpUtils.sendGetWithToken("https://www.gitlink.org.cn/api/v1/" + owner + "/" + projectName + "/branches/all.json", null, token);
// 解析响应JSON
if (StringUtils.isEmpty(req)) {
throw new RuntimeException("终止响应内容为空。");
@ -110,22 +140,25 @@ public class GitServiceImpl implements GitService {
}
@Override
public void deleteProject(String token, String owner, String projectName) throws Exception {
HttpUtils.sendDeleteRequest("https://www.gitlink.org.cn/api/"+owner+"/"+projectName+".json", token);
public void deleteProject(String owner, String projectName) throws Exception {
String token = this.checkoutToken();
HttpUtils.sendDeleteRequest("https://www.gitlink.org.cn/api/" + owner + "/" + projectName + ".json", token);
}
@Override
public void deleteBranch(String token, String owner, String projectName, String branchName) throws Exception {
HttpUtils.sendDeleteRequest("https://www.gitlink.org.cn/api/v1/"+owner+"/"+projectName+"/branches/"+branchName+".json", token);
public void deleteBranch(String owner, String projectName, String branchName) throws Exception {
String token = this.checkoutToken();
HttpUtils.sendDeleteRequest("https://www.gitlink.org.cn/api/v1/" + owner + "/" + projectName + "/branches/" + branchName + ".json", token);
}
@Override
public Map getUserInfo(String token) throws Exception {
public Map getUserInfo() throws Exception {
String token = this.checkoutToken();
String userReq = HttpUtils.sendGetWithToken("https://www.gitlink.org.cn/api/users/get_user_info.json",null, token);
if (StringUtils.isEmpty(userReq)){
return null;
}
Map<String, Object> runResMap = JsonUtils.jsonToMap(userReq);
return runResMap;
return runResMap;
}
}

View File

@ -514,7 +514,6 @@ public class ModelsServiceImpl implements ModelsService {
public CompletableFuture<String> newCreateModel(ModelsVo modelsVo) throws Exception {
return CompletableFuture.supplyAsync(() -> {
try {
String token = gitService.login(modelsVo.getGitLinkUsername(), modelsVo.getGitLinkPassword());
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
Jedis jedis = new Jedis(redisHost);
@ -532,15 +531,15 @@ public class ModelsServiceImpl implements ModelsService {
gitProjectVo.setUserId(userId);
// 创建项目
Map project = gitService.createProject(token, gitProjectVo);
Map project = gitService.createProject(gitProjectVo);
// 创建分支
String branchName = modelsVo.getVersion();
gitService.createBranch(token, (String) userInfo.get("login"), repositoryName, branchName, "master");
gitService.createBranch((String) userInfo.get("login"), repositoryName, branchName, "master");
// 定义标签 标签1ci4s_model 标签2ModelTag 标签3ModelType
gitService.createTopic(token, (Integer) project.get("id"), "ci4s_model");
gitService.createTopic(token, (Integer) project.get("id"), "ModelTag_" + modelsVo.getModelTag());
gitService.createTopic(token, (Integer) project.get("id"), "ModelType_" + modelsVo.getModelType());
gitService.createTopic((Integer) project.get("id"), "ci4s_model");
gitService.createTopic((Integer) project.get("id"), "ModelTag_" + modelsVo.getModelTag());
gitService.createTopic((Integer) project.get("id"), "ModelType_" + modelsVo.getModelType());
// 得到项目地址
String projectUrl = gitendpoint + "/" + (String) userInfo.get("login") + "/" + repositoryName + ".git";
// 得到用户操作的路径
@ -592,7 +591,7 @@ public class ModelsServiceImpl implements ModelsService {
// 创建分支
String branchName = modelsVo.getVersion();
String repositoryName = modelsVo.getRepositoryName();
gitService.createBranch(token, (String) userInfo.get("login"), repositoryName, branchName, "master");
gitService.createBranch((String) userInfo.get("login"), repositoryName, branchName, "master");
// 得到项目地址
String projectUrl = gitendpoint + "/" + (String) userInfo.get("login") + "/" + repositoryName + ".git";
// 得到用户操作的路径
@ -684,7 +683,7 @@ public class ModelsServiceImpl implements ModelsService {
@Override
public Page<ModelsVo> newPubilcQueryByPage(ModelsVo modelsVo, PageRequest pageRequest) throws Exception {
LoginUser loginUser = SecurityUtils.getLoginUser();
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
String token = gitService.login(modelsVo.getGitLinkUsername(), modelsVo.getGitLinkPassword());
Jedis jedis = new Jedis(redisHost);

View File

@ -62,11 +62,9 @@ public class NewDatasetServiceImpl implements NewDatasetService {
@Override
public String newCreateDataset(NewDatasetVo datasetVo) throws Exception {
checkoutToken();
Jedis jedis = new Jedis(redisHost);
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
String token = jedis.get(ci4sUsername + "_gitToken");
String gitLinkUsername = loginUser.getSysUser().getGitLinkUsername();
String gitLinkPassword = loginUser.getSysUser().getGitLinkPassword();
String userReq = jedis.get(ci4sUsername + "_gitUserInfo");
@ -81,15 +79,15 @@ public class NewDatasetServiceImpl implements NewDatasetService {
gitProjectVo.setPrivate(!datasetVo.getIsPublic());
gitProjectVo.setUserId(userId);
// 创建项目
Map project = gitService.createProject(token, gitProjectVo);
Map project = gitService.createProject(gitProjectVo);
Integer gitlinIid = (Integer) project.get("id");
// 创建分支
String branchName = datasetVo.getVersion();
gitService.createBranch(token, (String) userInfo.get("login"), repositoryName, branchName, "master");
gitService.createBranch((String) userInfo.get("login"), repositoryName, branchName, "master");
// 定义标签 标签1ci4s_dataset 标签2DataTag 标签3DataType
gitService.createTopic(token, gitlinIid, "ci4s_dataset");
gitService.createTopic(token, gitlinIid, "DataTag_" + datasetVo.getDataTag());
gitService.createTopic(token, gitlinIid, "DataType_" + datasetVo.getDataType());
gitService.createTopic(gitlinIid, "ci4s_dataset");
gitService.createTopic(gitlinIid, "DataTag_" + datasetVo.getDataTag());
gitService.createTopic( gitlinIid, "DataType_" + datasetVo.getDataType());
// 得到项目地址
String projectUrl = gitendpoint + "/" + (String) userInfo.get("login") + "/"+ repositoryName + ".git";
@ -139,7 +137,6 @@ public class NewDatasetServiceImpl implements NewDatasetService {
public CompletableFuture<String> newCreateVersion(NewDatasetVo datasetVo) {
return CompletableFuture.supplyAsync(() -> {
try {
checkoutToken();
Jedis jedis = new Jedis(redisHost);
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
@ -152,7 +149,7 @@ public class NewDatasetServiceImpl implements NewDatasetService {
String branchName = StringUtils.isEmpty(datasetVo.getVersion()) ? "master" : datasetVo.getVersion();
String repositoryName = datasetVo.getIdentifier();
if (StringUtils.equals(branchName, "master")) {
gitService.createBranch(token, (String) userInfo.get("login"), repositoryName, branchName, "master");
gitService.createBranch((String) userInfo.get("login"), repositoryName, branchName, "master");
}
// 得到项目地址
String projectUrl = gitendpoint + "/" + (String) userInfo.get("login") + "/" + repositoryName + ".git";
@ -211,7 +208,6 @@ public class NewDatasetServiceImpl implements NewDatasetService {
@Override
public Page<NewDatasetVo> newPersonalQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception {
checkoutToken();
Jedis jedis = new Jedis(redisHost);
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
@ -234,7 +230,6 @@ public class NewDatasetServiceImpl implements NewDatasetService {
@Override
public Page<NewDatasetVo> newPubilcQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception {
checkoutToken();
Jedis jedis = new Jedis(redisHost);
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
@ -274,7 +269,7 @@ public class NewDatasetServiceImpl implements NewDatasetService {
version = (String) versionList.get(0).get("name");
}
List<Map<String, Object>> fileDetailsAfterGitPull = DVCUtils.getFileDetailsAfterGitPull("E:\\test\\" +id, repositoryName, version, gitLinkUsername, gitLinkPassword);
List<Map<String, Object>> fileDetailsAfterGitPull = DVCUtils.getFileDetailsAfterGitPull("E:\\test\\" +id, repositoryName, version, "data",gitLinkUsername, gitLinkPassword);
// 在localPathlocal+id+"/"+repositoryName目录下的dataset.yaml中取到元数据
Map<String, Object> stringObjectMap = YamlUtils.loadYamlFile("E:\\test\\" + id + "\\" + repositoryName + "\\" + "dataset.yaml");
NewDatasetVo newDatasetVo = ConvertUtil.convertMapToObject(stringObjectMap, NewDatasetVo.class);
@ -295,12 +290,11 @@ public class NewDatasetServiceImpl implements NewDatasetService {
@Override
public List<Map<String, Object>> getVersionList(String repo, String owner) throws Exception {
checkoutToken();
Jedis jedis = new Jedis(redisHost);
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
String token = jedis.get(ci4sUsername+"_gitToken");
List<Map<String, Object>> brancheList = gitService.getBrancheList(token, owner, repo);
List<Map<String, Object>> brancheList = gitService.getBrancheList(owner, repo);
return brancheList.stream()
.filter(branch -> !"master".equals(branch.get("name")))
.collect(Collectors.toList());
@ -308,22 +302,20 @@ public class NewDatasetServiceImpl implements NewDatasetService {
@Override
public void deleteDatasetNew(String repo, String owner) throws Exception {
checkoutToken();
Jedis jedis = new Jedis(redisHost);
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
String token = jedis.get(ci4sUsername+"_gitToken");
gitService.deleteProject(token, owner, repo);
gitService.deleteProject(owner, repo);
}
@Override
public void deleteDatasetVersionNew(String repo, String owner, String version) throws Exception {
checkoutToken();
Jedis jedis = new Jedis(redisHost);
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
String token = jedis.get(ci4sUsername+"_gitToken");
gitService.deleteBranch(token, owner, repo, version);
gitService.deleteBranch(owner, repo, version);
}
@Override
@ -378,7 +370,6 @@ public class NewDatasetServiceImpl implements NewDatasetService {
@Override
public ResponseEntity<InputStreamResource> downloadAllDatasetFilesNew(String repositoryName, String version) throws Exception {
// 命令行操作 git clone 项目地址
checkoutToken();
LoginUser loginUser = SecurityUtils.getLoginUser();
String gitLinkUsername = loginUser.getSysUser().getGitLinkUsername();
String gitLinkPassword = loginUser.getSysUser().getGitLinkPassword();
@ -471,31 +462,5 @@ public class NewDatasetServiceImpl implements NewDatasetService {
return new ArrayList<>();
}
private String checkoutToken(){
Jedis jedis = new Jedis(redisHost);
LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
String token = jedis.get(ci4sUsername+"_gitToken");
String gitLinkUsername = loginUser.getSysUser().getGitLinkUsername();
String gitLinkPassword = loginUser.getSysUser().getGitLinkPassword();
if(StringUtils.isEmpty(token)){
gitService.login(gitLinkUsername, gitLinkPassword);
token = jedis.get(ci4sUsername+"_gitToken");
}else {
try {
Map userInfo = gitService.getUserInfo(token);
if (userInfo == null ||(userInfo.get("status")!=null&&401==(Integer) userInfo.get("status"))){
gitService.login(gitLinkUsername, gitLinkPassword);
token = jedis.get(ci4sUsername+"_gitToken");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return token;
}
}

View File

@ -1,10 +1,11 @@
package com.ruoyi.platform.utils;
import org.apache.commons.beanutils.PropertyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.apache.commons.beanutils.PropertyUtils;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@ -23,7 +24,7 @@ public class ConvertUtil {
public static final Logger logger = LoggerFactory.getLogger(ConvertUtil.class);
/**
/**
* 将实体对象转换为VO对象
* @param source 源实体对象
* @param target 目标VO对象的类
@ -90,7 +91,8 @@ public class ConvertUtil {
}
}
return targetObject;
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
} catch (InstantiationException | IllegalAccessException | InvocationTargetException |
NoSuchMethodException e) {
e.printStackTrace();
}
return null;
@ -98,8 +100,13 @@ public class ConvertUtil {
private static boolean hasProperty(Class<?> clazz, String propertyName) {
try {
Field field = clazz.getDeclaredField(propertyName);
return field != null;
Class<?> superClazz = clazz.getSuperclass();
if(superClazz != Object.class){
return hasProperty(superClazz, propertyName);
} else {
Field field = clazz.getDeclaredField(propertyName);
return field != null;
}
} catch (NoSuchFieldException e) {
return false;
}

View File

@ -193,12 +193,12 @@ public class DVCUtils {
* @param branch 分支名称
* @return 包含文件路径名称和大小的List<Map<String, Object>>
*/
public static List<Map<String, Object>> getFileDetailsAfterGitPull(String localPath, String repoFolder, String branch,String username, String password) {
public static List<Map<String, Object>> getFileDetailsAfterGitPull(String localPath, String repoFolder, String branch, String filePath , String username, String password) {
List<Map<String, Object>> fileInfoList = new ArrayList<>();
try {
// 切换到指定目录
Path repoPath = Paths.get(localPath, repoFolder);
Path repoPath = Paths.get(localPath, repoFolder, branch);
//刷新
// gitFetch(localPath, username, password);
@ -207,19 +207,19 @@ public class DVCUtils {
// // 执行git pull
// gitPull(localPath, username, password);
// 读取data文件夹中的文件列表
Path dataPath = Paths.get(repoPath.toString(), "data");
Path dataPath = Paths.get(repoPath.toString(), filePath);
File[] files = dataPath.toFile().listFiles();
if (files != null) {
for (File file : files) {
if (file.isFile()) {
long size = Files.size(file.toPath());
String filePath = file.getAbsolutePath();
String absoluteFilePath = file.getAbsolutePath();
String fileName = file.getName();
Map<String, Object> fileDetails = new HashMap<>();
fileDetails.put("size", size);
fileDetails.put("filePath", filePath);
fileDetails.put("filePath", absoluteFilePath);
fileDetails.put("fileName", fileName);
fileInfoList.add(fileDetails);

View File

@ -0,0 +1,18 @@
package com.ruoyi.platform.vo;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.ruoyi.platform.domain.ModelDependency1;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class ModelDependency1TreeVo extends ModelDependency1 implements Serializable {
List<ModelDependency1> patrentModelList;
List<ModelDependency1TreeVo> childModelList;
}

View File

@ -0,0 +1,67 @@
package com.ruoyi.platform.vo;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Data
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class ModelMetaVo implements Serializable {
@ApiModelProperty(name = "模型名称")
private String name;
@ApiModelProperty(name = "版本")
private String version;
@ApiModelProperty(name = "版本描述")
private String versionDescription;
@ApiModelProperty(value = "创建人")
private String createBy;
@ApiModelProperty(value = "更新时间")
private Date updateTime;
@ApiModelProperty(value = "训练镜像")
private String image;
@ApiModelProperty(value = "训练代码")
private String code;
@ApiModelProperty(value = "模型来源")
private String modelSource;
@ApiModelProperty(value = "训练数据集")
private List<String> trainDatasets;
@ApiModelProperty(value = "测试数据集")
private List<String> testDatasets;
@ApiModelProperty(value = "参数")
private HashMap<String, String> params;
@ApiModelProperty(value = "指标")
private HashMap<String, String> metrics;
@ApiModelProperty(value = "训练任务")
private String trainTask;
@ApiModelProperty(value = "模型标签(模型能力)")
private String modelTag;
@ApiModelProperty(value = "模型类型(模型框架)")
private String modelType;
@ApiModelProperty(value = "模型描述")
private String description;
@ApiModelProperty(value = "示例用法")
private String examples;
}

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.platform.mapper.ModelDependency1Dao">
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into model_dependency1(parent_model, model_name, version, repo_id, identifier, owner)
values (#{parentModel}, #{modelName}, #{version}, #{repoId}, #{identifier}, #{owner})
</insert>
<select id="queryByModelName" resultType="com.ruoyi.platform.domain.ModelDependency1">
select *
from model_dependency1
where model_name = #{modelName}
and state = 1
</select>
<select id="queryByModelNameAndVersion" resultType="com.ruoyi.platform.domain.ModelDependency1">
select *
from model_dependency1
where repo_id = #{repoId}
and model_name = #{modelName}
and version = #{version}
and state = 1
</select>
<select id="queryByParentModel" resultType="com.ruoyi.platform.domain.ModelDependency1">
select *
from model_dependency1
where parent_model = #{parentModel}
and state = 1
</select>
<update id="deleteModel">
update model_dependency1
set state = 0
where repo_id = #{repoId} and identifier = #{identifier} and owner = #{owner}
<if test="version != null and version != ''">
and version = #{version}
</if>
</update>
<update id="deleteModelDependency">
update model_dependency1
set parent_model = null
where parent_model like concat(#{repoId}, ':', #{identifier},
<if test="version != null and version != ''">
':', #{version},
</if>
'%')
</update>
</mapper>

View File

@ -19,7 +19,7 @@
<!--查询单个-->
<select id="queryById" resultMap="ModelsMap">
select
id, name, description,available_range, model_type,model_tag, create_by, create_time, update_by, update_time, state
id, name, description,available_range, model_type,model_tag, create_by, create_time, update_by, update_time, state
from models
where id = #{id} and state = 1
</select>
@ -27,7 +27,7 @@
<!--查询单个-->
<select id="findByName" resultMap="ModelsMap">
select
id, name, description,available_range, model_type,model_tag, create_by, create_time, update_by, update_time, state
id, name, description,available_range, model_type,model_tag, create_by, create_time, update_by, update_time, state
from models
where name = #{name} and state = 1 limit 1