Selaa lähdekoodia

修改打分命令

root 2 vuotta sitten
vanhempi
commit
73de0713cc

+ 3 - 49
api-common/src/main/java/api/common/util/CollectionUtil.java

@@ -4,7 +4,6 @@ import java.util.*;
 
 
 public class CollectionUtil {
 public class CollectionUtil {
 
 
-    //* -------------------------------- before jdk9 --------------------------------
 
 
     public static <T> List<T> arrayToList(T[] array) {
     public static <T> List<T> arrayToList(T[] array) {
         return Arrays.asList(array);
         return Arrays.asList(array);
@@ -49,54 +48,9 @@ public class CollectionUtil {
         return !isEmpty(map);
         return !isEmpty(map);
     }
     }
 
 
-//    //* -------------------------------- jdk9  --------------------------------
-//
-//    /**
-//     * 根据数组或参数序列创建只读的 list
-//     *
-//     * @param elements 数组或参数序列
-//     * @param <T>      元素类型
-//     * @return 只读 list
-//     */
-//    @SafeVarargs
-//    public static <T> List<T> createUnmodifiableList(T... elements) {
-//        return List.of(elements);
-//    }
-//
-//    /**
-//     * 根据 list 创建只读的 list
-//     *
-//     * @param list list
-//     * @param <E>  元素类型
-//     * @return 只读 list
-//     */
-//    public static <E> List<E> createUnmodifiableList(List<E> list) {
-//        return Collections.unmodifiableList(list);
-//    }
-//
-//    /**
-//     * 根据 set 创建只读的 set
-//     *
-//     * @param set set
-//     * @param <E> 元素类型
-//     * @return 只读 list
-//     */
-//    public static <E> Set<E> createUnmodifiableList(Set<E> set) {
-//        return Collections.unmodifiableSet(set);
-//    }
-//
-//
-//    /**
-//     * 根据 map 创建只读的 map
-//     *
-//     * @param map map
-//     * @param <K> 键类型
-//     * @param <V> 值类型
-//     * @return 只读 map
-//     */
-//    public static <K, V> Map<K, V> createUnmodifiableList(Map<K, V> map) {
-//        return Collections.unmodifiableMap(map);
-//    }
+    public static void addValueToMap(Map<String, Integer> map, int value, String key) {
+        map.merge(key, value, Integer::sum);
+    }
 
 
 
 
 }
 }

+ 14 - 7
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/manager/TaskManager.java

@@ -234,14 +234,20 @@ public class TaskManager {
                     if (DictConstants.TASK_ANALYSIS.equals(runState)) {
                     if (DictConstants.TASK_ANALYSIS.equals(runState)) {
                         taskMapper.updateSuccessStateWithStopTime(task2Id, DictConstants.TASK_ANALYSING, TimeUtil.getNowForMysql());
                         taskMapper.updateSuccessStateWithStopTime(task2Id, DictConstants.TASK_ANALYSING, TimeUtil.getNowForMysql());
                         // 计算每个任务的得分
                         // 计算每个任务的得分
-                        String runResultMinio = taskOfLeaf.getRunResultFilePath() + "/Ego.csv";
-                        String runResultLinux = linuxTempPath + runResultMinio;
-                        String scoreCommand = "python3 " + pyPath + "main.py " + runResultLinux + " " + taskOfLeaf.getSceneType() + " " + ruleName; // 指定打分脚本
+                        String result1OfMinio = taskOfLeaf.getRunResultFilePath() + "/Ego.csv";
+                        String result1OfLinux = linuxTempPath + result1OfMinio;
+                        String result2OfMinio = taskOfLeaf.getRunResultFilePath() + "/combined_ogt.csv";
+                        String result2OfLinux = linuxTempPath + result2OfMinio;
+                        String scoreCommand = "python3 " + pyPath + "main.py "
+                                + result1OfLinux + " "
+                                + result2OfLinux + " "
+                                + taskOfLeaf.getSceneType() + " " + ruleName; // 指定打分脚本
                         String scoreResult;
                         String scoreResult;
                         ScoreTO score;
                         ScoreTO score;
                         try {
                         try {
-                            log.info("TaskService--state 下载 minio 上的结果文件 " + runResultMinio + " 到本地:" + runResultLinux);
-                            MinioUtil.downloadToFile(minioClient, bucketName, runResultMinio, runResultLinux);  // 也可改成下载到指定ip的服务器上,需要保证和打分脚本在一台机器上。
+                            log.info("TaskService--state 下载 minio 上的结果文件 " + result1OfMinio + " 和 " + result2OfMinio + " 到临时目录:" + linuxTempPath);
+                            MinioUtil.downloadToFile(minioClient, bucketName, result1OfMinio, result1OfLinux);  // 也可改成下载到指定ip的服务器上,需要保证和打分脚本在一台机器上。
+                            MinioUtil.downloadToFile(minioClient, bucketName, result2OfMinio, result2OfLinux);  // 也可改成下载到指定ip的服务器上,需要保证和打分脚本在一台机器上。
                         } catch (Exception e) {
                         } catch (Exception e) {
                             throw new RuntimeException("------- TaskService--state 下载 minio 上的结果文件出错:" + e.getMessage());
                             throw new RuntimeException("------- TaskService--state 下载 minio 上的结果文件出错:" + e.getMessage());
                         }
                         }
@@ -251,8 +257,9 @@ public class TaskManager {
                             log.info("TaskService--state 项目" + projectId + " 的任务 " + task2Id + " 打分结束,结果为:" + scoreResult);
                             log.info("TaskService--state 项目" + projectId + " 的任务 " + task2Id + " 打分结束,结果为:" + scoreResult);
                             String replace = StringUtil.replace(scoreResult, "'", "\"");
                             String replace = StringUtil.replace(scoreResult, "'", "\"");
                             score = JsonUtil.jsonToBean(replace, ScoreTO.class);
                             score = JsonUtil.jsonToBean(replace, ScoreTO.class);
-                            FileUtil.rm(runResultLinux);
-                            log.info("TaskService--state 已删除运行结果文件 Ego.csv:" + runResultLinux);
+                            FileUtil.rm(result1OfLinux);
+                            FileUtil.rm(result2OfLinux);
+                            log.info("TaskService--state 已删除运行结果文件 Ego.csv 和 combined_ogt.csv。");
                         } catch (IOException e) {
                         } catch (IOException e) {
                             throw new RuntimeException("------- TaskService--state 项目" + projectId + "的任务" + task2Id + " 打分出错,命令为:" + scoreCommand + " 修改状态为:" + DictConstants.TASK_ABORTED + "\n" + e.getMessage());
                             throw new RuntimeException("------- TaskService--state 项目" + projectId + "的任务" + task2Id + " 打分出错,命令为:" + scoreCommand + " 修改状态为:" + DictConstants.TASK_ABORTED + "\n" + e.getMessage());
                         }
                         }

+ 5 - 3
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/service/ProjectService.java

@@ -379,10 +379,10 @@ public class ProjectService {
                 throw new RuntimeException("算法 " + algorithmId + " 的 mysql 数据有误!");
                 throw new RuntimeException("算法 " + algorithmId + " 的 mysql 数据有误!");
             }
             }
         } else { // 从索为算法平台下载算法
         } else { // 从索为算法平台下载算法
-            log.info("ProjectService--handleAlgorithm 项目" + projectId + "需要从索为平台下载算法 " + algorithmId);
+            log.info("ProjectService--handleAlgorithm 项目" + projectId + "需要使用索为平台算法 " + algorithmId);
             algorithmTarLinuxTempPath = linuxTempPath + "algorithm/" + algorithmId + ".tar";
             algorithmTarLinuxTempPath = linuxTempPath + "algorithm/" + algorithmId + ".tar";
-            String dockerImageWithoutVersion = "algorithm_" + algorithmId;
-            dockerImage = dockerConfiguration.getRegistry() + "/" + dockerImageWithoutVersion + ":latest";
+            String dockerImageWithoutVersion = dockerConfiguration.getRegistry() + "/algorithm_" + algorithmId;
+            dockerImage = dockerImageWithoutVersion + ":latest";
             //0 查看算法是否已经导入
             //0 查看算法是否已经导入
             if (!projectUtil.isImported(dockerImageWithoutVersion)) {
             if (!projectUtil.isImported(dockerImageWithoutVersion)) {
                 //1 获取 token
                 //1 获取 token
@@ -401,6 +401,8 @@ public class ProjectService {
                 LinuxUtil.execute("docker push " + dockerImage);
                 LinuxUtil.execute("docker push " + dockerImage);
                 FileUtil.rm(algorithmTarLinuxTempPath);
                 FileUtil.rm(algorithmTarLinuxTempPath);
                 log.info("ProjectService--handleAlgorithm 已删除算法临时文件:" + algorithmTarLinuxTempPath);
                 log.info("ProjectService--handleAlgorithm 已删除算法临时文件:" + algorithmTarLinuxTempPath);
+            } else {
+                log.info("ProjectService--handleAlgorithm 算法镜像" + dockerImageWithoutVersion + "已导入。");
             }
             }
         }
         }
 
 

+ 1 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/util/ProjectUtil.java

@@ -230,7 +230,7 @@ public class ProjectUtil {
                     int tempParallelism = tempNode.getMaxParallelism();
                     int tempParallelism = tempNode.getMaxParallelism();
                     if (tempParallelism > 0) {
                     if (tempParallelism > 0) {
                         tempNode.setMaxParallelism(tempParallelism - 1);
                         tempNode.setMaxParallelism(tempParallelism - 1);
-                        resultNodeMap.merge(tempNodeName, 1, Integer::sum);
+                        CollectionUtil.addValueToMap(resultNodeMap, 1, tempNodeName);
                     }
                     }
                 }
                 }
             }
             }