|
@@ -52,8 +52,6 @@ public class ProjectService {
|
|
String algorithmPlatformTokenUri;
|
|
String algorithmPlatformTokenUri;
|
|
@Value("${algorithm-platform.algorithm-addr-uri}")
|
|
@Value("${algorithm-platform.algorithm-addr-uri}")
|
|
String algorithmPlatformAlgorithmAddrUri;
|
|
String algorithmPlatformAlgorithmAddrUri;
|
|
-
|
|
|
|
-
|
|
|
|
@Value("${scheduler.minio-path.project-result}")
|
|
@Value("${scheduler.minio-path.project-result}")
|
|
String projectResultPathOfMinio;
|
|
String projectResultPathOfMinio;
|
|
@Value("${scheduler.linux-path.temp}")
|
|
@Value("${scheduler.linux-path.temp}")
|
|
@@ -339,29 +337,39 @@ public class ProjectService {
|
|
//4-1 根据算法 id 获取算法文件地址、是否已导入成镜像。
|
|
//4-1 根据算法 id 获取算法文件地址、是否已导入成镜像。
|
|
AlgorithmPO algorithmPO = algorithmMapper.selectById(algorithmId);
|
|
AlgorithmPO algorithmPO = algorithmMapper.selectById(algorithmId);
|
|
String dockerImage = dockerConfiguration.getRegistry() + "/";
|
|
String dockerImage = dockerConfiguration.getRegistry() + "/";
|
|
- String algorithmTarLinuxTempPath;
|
|
|
|
|
|
+ String algorithmDirectoryLinuxTempPath;
|
|
|
|
+ String algorithmTarLinuxTempPath = null;
|
|
if (algorithmPO != null) { // 使用仿真平台自己的算法
|
|
if (algorithmPO != null) { // 使用仿真平台自己的算法
|
|
String algorithmCode = algorithmPO.getAlgorithmCode();
|
|
String algorithmCode = algorithmPO.getAlgorithmCode();
|
|
String dockerImport = algorithmPO.getDockerImport();
|
|
String dockerImport = algorithmPO.getDockerImport();
|
|
- dockerImage += "algorithm_" + algorithmCode + ":latest";
|
|
|
|
- algorithmTarLinuxTempPath = linuxTempPath + "algorithm/" + algorithmCode + ".tar";
|
|
|
|
|
|
+ dockerImage += dockerConfiguration.getRegistry() + "/algorithm_" + algorithmCode + ":latest";
|
|
if ("1".equals(dockerImport) && StringUtil.isNotEmpty(dockerImport)) { // 已经导入同时存在镜像名称
|
|
if ("1".equals(dockerImport) && StringUtil.isNotEmpty(dockerImport)) { // 已经导入同时存在镜像名称
|
|
dockerImage = algorithmPO.getDockerImage();
|
|
dockerImage = algorithmPO.getDockerImage();
|
|
return dockerImage;
|
|
return dockerImage;
|
|
} else if (dockerImport == null || "0".equals(dockerImport)) { // 未导入
|
|
} else if (dockerImport == null || "0".equals(dockerImport)) { // 未导入
|
|
String uploadMode = algorithmPO.getUploadMode();
|
|
String uploadMode = algorithmPO.getUploadMode();
|
|
if (DictConstants.ALGORITHM_UPLOAD_MODE_FILE.equals(uploadMode)) {
|
|
if (DictConstants.ALGORITHM_UPLOAD_MODE_FILE.equals(uploadMode)) {
|
|
|
|
+ algorithmTarLinuxTempPath = linuxTempPath + "algorithm-file/" + algorithmCode + "/" + algorithmCode + ".tar";
|
|
String minioPath = algorithmPO.getMinioPath();
|
|
String minioPath = algorithmPO.getMinioPath();
|
|
MinioUtil.downloadToFile(minioClient, bucketName, minioPath, algorithmTarLinuxTempPath); // 下载算法文件到本地
|
|
MinioUtil.downloadToFile(minioClient, bucketName, minioPath, algorithmTarLinuxTempPath); // 下载算法文件到本地
|
|
} else if (DictConstants.ALGORITHM_UPLOAD_MODE_GIT.equals(uploadMode)) {
|
|
} else if (DictConstants.ALGORITHM_UPLOAD_MODE_GIT.equals(uploadMode)) {
|
|
|
|
+ algorithmDirectoryLinuxTempPath = linuxTempPath + "algorithm-git/" + algorithmCode + "/";
|
|
String gitUrl = algorithmPO.getGitUrl();
|
|
String gitUrl = algorithmPO.getGitUrl();
|
|
String gitUserName = algorithmPO.getGitUserName();
|
|
String gitUserName = algorithmPO.getGitUserName();
|
|
String gitPassword = algorithmPO.getGitPassword();
|
|
String gitPassword = algorithmPO.getGitPassword();
|
|
- GitUtil.clone(gitUrl, gitUserName, gitPassword, algorithmTarLinuxTempPath); // 下载算法文件到本地
|
|
|
|
|
|
+ GitUtil.clone(gitUrl, gitUserName, gitPassword, algorithmDirectoryLinuxTempPath); // 下载算法文件到目录
|
|
|
|
+ for (String filename : Objects.requireNonNull(new File(algorithmDirectoryLinuxTempPath).list())) {
|
|
|
|
+ if (filename.endsWith(".tar")) {
|
|
|
|
+ algorithmTarLinuxTempPath = algorithmDirectoryLinuxTempPath + filename;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
throw new RuntimeException("算法 " + algorithmId + " 的 upload_mode 字段数据有误!");
|
|
throw new RuntimeException("算法 " + algorithmId + " 的 upload_mode 字段数据有误!");
|
|
}
|
|
}
|
|
algorithmMapper.updateDockerImportAndDockerImageById("1", dockerImage, algorithmId);
|
|
algorithmMapper.updateDockerImportAndDockerImageById("1", dockerImage, algorithmId);
|
|
|
|
+ if (algorithmTarLinuxTempPath == null) {
|
|
|
|
+ throw new RuntimeException("ProjectService--handleAlgorithm 算法" + algorithmId + "下载失败。");
|
|
|
|
+ }
|
|
LinuxUtil.execute("docker import " + algorithmTarLinuxTempPath + " " + dockerImage);
|
|
LinuxUtil.execute("docker import " + algorithmTarLinuxTempPath + " " + dockerImage);
|
|
LinuxUtil.execute("docker push " + dockerImage);
|
|
LinuxUtil.execute("docker push " + dockerImage);
|
|
FileUtil.rm(algorithmTarLinuxTempPath);
|
|
FileUtil.rm(algorithmTarLinuxTempPath);
|