diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java
index 6df28844..ad9a1ac7 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java
@@ -586,6 +586,7 @@ public class ModelsServiceImpl implements ModelsService {
}
//新建模型
+ // 拼接project
GitProjectVo gitProjectVo = new GitProjectVo();
gitProjectVo.setRepositoryName(repositoryName);
gitProjectVo.setName(Constant.Topic_model + "-" + modelsVo.getName());
@@ -601,6 +602,18 @@ public class ModelsServiceImpl implements ModelsService {
throw new RuntimeException("创建模型失败:" + project.get("message"));
}
+ String branchName = modelsVo.getVersion();
+ String owner = (String) userInfo.get("login");
+
+ String projectUrl = gitCloneEndpoint + "/" + owner + "/" + repositoryName + ".git";
+ String sourcePath = modelsVo.getModelVersionVos().get(0).getUrl();
+ String rootPath = localPath + ci4sUsername + "/model/" + gitlinIid + "/" + repositoryName + "/" + branchName;
+ String modelPath = rootPath + "/model";
+ String metaPath = rootPath + "/metadata";
+ String relatePath = ci4sUsername + "/model/" + gitlinIid + "/" + repositoryName + "/" + branchName + "/model";
+
+ // 创建分支
+ gitService.createBranch(token, (String) userInfo.get("login"), repositoryName, branchName, "master");
// 定义标签 标签1:model 标签2:ModelTag 标签3:ModelType
gitService.createTopic(token, gitlinIid, Constant.Topic_model);
if (StringUtils.isNotEmpty(modelsVo.getModelTag())) {
@@ -610,17 +623,11 @@ public class ModelsServiceImpl implements ModelsService {
gitService.createTopic(token, gitlinIid, "modeltype-" + modelsVo.getModelType());
}
- String owner = (String) userInfo.get("login");
- String projectUrl = gitCloneEndpoint + "/" + owner + "/" + repositoryName + ".git";
- String relationPath = ci4sUsername + "/model/" + gitlinIid + "/" + repositoryName + "/origin";
- String rootPath = localPath + relationPath;
- String modelPath = rootPath + "/model";
- String metaPath = rootPath + "/metadata";
- String relatePath = relationPath + "/model";
+ dvcUtils.gitClone(rootPath, projectUrl, branchName, gitLinkUsername, decryptGitLinkPassword);
- // 创建origin分支
- gitService.createBranch(token, owner, repositoryName, "origin", "master");
- dvcUtils.gitClone(rootPath, projectUrl, "origin", gitLinkUsername, decryptGitLinkPassword);
+ //干掉目标文件夹
+ dvcUtils.deleteDirectory(modelPath);
+ dvcUtils.moveFiles(sourcePath, modelPath);
//拼接生产的元数据后写入yaml文件
ModelMetaVo modelMetaVo = new ModelMetaVo();
@@ -629,13 +636,19 @@ public class ModelsServiceImpl implements ModelsService {
modelMetaVo.setCreateBy(String.valueOf(StringUtils.isNotEmpty((String) userInfo.get("nickname")) ? userInfo.get("nickname") : userInfo.get("login")));
modelMetaVo.setCreateTime(DateUtils.getTime());
modelMetaVo.setUpdateTime(DateUtils.getTime());
+ String projectUrlIp = gitCloneEndpointIp + "/" + owner + "/" + repositoryName + ".git";
+ modelMetaVo.setUsage("
" +
+ "# 克隆模型配置文件与存储参数到本地\n" +
+ "git clone -b " + branchName + " " + projectUrlIp + "\n" +
+ "# 远程拉取配置文件\n" +
+ "dvc pull\n" +
+ "
");
modelMetaVo.setIdentifier(repositoryName);
modelMetaVo.setOwner(owner);
modelMetaVo.setRelativePaths(relatePath);
File folder = new File(modelPath);
long folderSize = FileUtil.getFolderSize(folder);
modelMetaVo.setModelSize(FileUtil.formatFileSize(folderSize));
- BeanUtils.copyProperties(modelMetaVo, modelsVo);
Map metaMap = JSON.parseObject(JSON.toJSONString(modelMetaVo), Map.class);
YamlUtils.generateYamlFile(metaMap, metaPath, "metadata");
@@ -645,39 +658,35 @@ public class ModelsServiceImpl implements ModelsService {
modelDependency.setRepoId(gitlinIid);
modelDependency.setIdentifier(repositoryName);
modelDependency.setModelName(modelsVo.getName());
- modelDependency.setVersion("origin");
+ modelDependency.setVersion(modelsVo.getVersion());
modelDependency.setParentModel(modelsVo.getParentModel());
modelDependency.setOwner(gitLinkUsername);
modelDependency.setMeta(meta);
modelDependency.setState(Constant.State_valid);
modelDependency1Dao.insert(modelDependency);
- String s3Path = bucketName + "/mini-model-management-platform-files/" + relationPath;
-// CompletableFuture.supplyAsync(() -> {
-// try {
- dvcUtils.mkdir(modelPath);
- dvcUtils.dvcInit(rootPath);
- // 配置远程S3地址
- dvcUtils.dvcRemoteAdd(rootPath, s3Path);
- dvcUtils.dvcConfigS3Credentials(rootPath, endpoint);
- dvcUtils.dvcConfigS3Credentials2(rootPath, accessKeyId);
- dvcUtils.dvcConfigS3Credentials3(rootPath, secretAccessKey);
-
- // dvc 跟踪
- dvcUtils.dvcAdd(rootPath, "model");
- // git commit
- dvcUtils.gitCommit(rootPath, "commit from ci4s with " + loginUser.getUsername());
- dvcUtils.gitPush(rootPath, gitLinkUsername, decryptGitLinkPassword);
- dvcUtils.dvcPush(rootPath);
-
- // 创建分支
- newCreateVersion(modelsVo);
-// } catch (Exception e) {
-// logger.error(e.getMessage(), e);
-// throw new RuntimeException(e.getMessage());
-// }
-// return null;
-// });
+ String s3Path = bucketName + "/mini-model-management-platform-files/" + ci4sUsername + "/model/" + gitlinIid + "/" + repositoryName + "/" + branchName;
+ CompletableFuture.supplyAsync(() -> {
+ try {
+ dvcUtils.dvcInit(rootPath);
+ // 配置远程S3地址
+ dvcUtils.dvcRemoteAdd(rootPath, s3Path);
+ dvcUtils.dvcConfigS3Credentials(rootPath, endpoint);
+ dvcUtils.dvcConfigS3Credentials2(rootPath, accessKeyId);
+ dvcUtils.dvcConfigS3Credentials3(rootPath, secretAccessKey);
+
+ // dvc 跟踪
+ dvcUtils.dvcAdd(rootPath, "model");
+ // git commit
+ dvcUtils.gitCommit(rootPath, "commit from ci4s with " + loginUser.getUsername());
+ dvcUtils.gitPush(rootPath, gitLinkUsername, decryptGitLinkPassword);
+ dvcUtils.dvcPush(rootPath);
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RuntimeException(e.getMessage());
+ }
+ return null;
+ });
return "新增模型成功";
} catch (Exception e) {
@@ -718,8 +727,8 @@ public class ModelsServiceImpl implements ModelsService {
FileUtil.renameFile(rootPath, rootPath + "_deleted_" + System.currentTimeMillis());
//克隆
- dvcUtils.gitClone(rootPath, projectUrl, "origin", gitLinkUsername, gitLinkPassword);
- dvcUtils.refreshRemoteBranches(rootPath, gitLinkUsername, gitLinkPassword, "origin");
+ dvcUtils.gitClone(rootPath, projectUrl, oldModelDependencys.get(0).getVersion(), gitLinkUsername, gitLinkPassword);
+ dvcUtils.refreshRemoteBranches(rootPath, gitLinkUsername, gitLinkPassword, oldModelDependencys.get(0).getVersion());
//查询项目信息
String token = gitService.checkoutToken();
@@ -766,10 +775,9 @@ public class ModelsServiceImpl implements ModelsService {
modelMetaVo.setCreateBy(String.valueOf(StringUtils.isNotEmpty((String) userInfo.get("nickname")) ? userInfo.get("nickname") : userInfo.get("login")));
modelMetaVo.setCreateTime(DateUtils.getTime());
modelMetaVo.setUpdateTime(DateUtils.getTime());
- String projectUrlIp = gitCloneEndpointIp + "/" + owner + "/" + repositoryName + ".git";
modelMetaVo.setUsage("" +
"# 克隆模型配置文件与存储参数到本地\n" +
- "git clone -b " + branchName + " " + projectUrlIp + "\n" +
+ "git clone -b " + branchName + " " + projectUrl + "\n" +
"# 远程拉取配置文件\n" +
"dvc pull\n" +
"
");
@@ -976,7 +984,7 @@ public class ModelsServiceImpl implements ModelsService {
String token = gitService.checkoutToken();
List