|
@@ -31,10 +31,10 @@ import javax.annotation.Resource;
|
|
|
import java.io.*;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.nio.file.Files;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
+import java.nio.file.attribute.PosixFilePermission;
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -239,31 +239,43 @@ public class SceneEvaluationRuleService {
|
|
|
if (!new File(evaluationDirectoryOfUser).exists()) {
|
|
|
// 1 将场景评价规则脚本保存到 script 目录
|
|
|
FileUtil.createDirectory(scriptsPath);
|
|
|
- final ArrayList<String> scriptFilePath = CollectionUtil.createArrayList(
|
|
|
- "/data_preprocessing.py",
|
|
|
- "/elevation.py",
|
|
|
- "/scenario_evaluation_utils52.py"
|
|
|
- );
|
|
|
- for (String pyFilePath : scriptFilePath) {
|
|
|
- try {
|
|
|
- downloadDependFile(sceneEvaluationScript + pyFilePath, scriptsPath + pyFilePath);
|
|
|
- } catch (IOException e) {
|
|
|
- log.error("下载 py 依赖文件失败: " + sceneEvaluationScript + pyFilePath, e);
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
+// final ArrayList<String> scriptFilePath = CollectionUtil.createArrayList(
|
|
|
+// "/data_preprocessing.py",
|
|
|
+// "/elevation.py",
|
|
|
+// "/scenario_evaluation_utils52.py"
|
|
|
+// );
|
|
|
+// for (String pyFilePath : scriptFilePath) {
|
|
|
+// try {
|
|
|
+// downloadDependFile(sceneEvaluationScript + pyFilePath, scriptsPath + pyFilePath);
|
|
|
+// } catch (IOException e) {
|
|
|
+// log.error("下载 py 依赖文件失败: " + sceneEvaluationScript + pyFilePath, e);
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
// 下载场景评价脚本到脚本目录
|
|
|
if (sceneEvaluationRulePO.getScriptPath() == null) {
|
|
|
return false;
|
|
|
}
|
|
|
- String pyMainPath = scriptsPath + "/" + sceneEvaluationRulePO.getRuleId() + ".py";
|
|
|
+ String pyMainPath = scriptsPath + "/" + sceneEvaluationRulePO.getRuleId();
|
|
|
if (!new File(pyMainPath).exists()) {
|
|
|
try {
|
|
|
downloadDependFile(sceneEvaluationRulePO.getScriptPath(), pyMainPath);
|
|
|
+ Path path = Paths.get(pyMainPath);
|
|
|
+ Set<PosixFilePermission> permissions = new HashSet<>();
|
|
|
+ permissions.add(PosixFilePermission.OWNER_READ);
|
|
|
+ permissions.add(PosixFilePermission.OWNER_WRITE);
|
|
|
+ permissions.add(PosixFilePermission.OWNER_EXECUTE);
|
|
|
+ permissions.add(PosixFilePermission.GROUP_READ);
|
|
|
+ permissions.add(PosixFilePermission.GROUP_WRITE);
|
|
|
+ permissions.add(PosixFilePermission.GROUP_EXECUTE);
|
|
|
+ permissions.add(PosixFilePermission.OTHERS_READ);
|
|
|
+ permissions.add(PosixFilePermission.OTHERS_WRITE);
|
|
|
+ permissions.add(PosixFilePermission.OTHERS_EXECUTE);
|
|
|
+ Files.setPosixFilePermissions(path, permissions);
|
|
|
} catch (IOException e) {
|
|
|
- log.error("下载 py 执行文件失败: " + sceneEvaluationRulePO.getScriptPath(), e);
|
|
|
+ log.error("下载执行文件失败: " + sceneEvaluationRulePO.getScriptPath(), e);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -291,8 +303,8 @@ public class SceneEvaluationRuleService {
|
|
|
downloadDependFile(sceneEvaluationComputeParam.getSceneXODRPath(), scenePath + "/" + xodrName);
|
|
|
} else if (StringUtils.equals(sceneEvaluationComputeParam.getComputeType(), DictConstants.RISK)) {
|
|
|
// 计算危险度 从 minio path 下载 csv (ego 和 sensors)
|
|
|
- downloadDependFile(sceneEvaluationComputeParam.getEvaluationPath() + "/ego.csv", scenePath + "/ego.csv");
|
|
|
- downloadDependFile(sceneEvaluationComputeParam.getEvaluationPath() + "/sensor.csv", scenePath + "/sensor.csv");
|
|
|
+ downloadDependFile(sceneEvaluationComputeParam.getEvaluationPath() + "/Ego.csv", scenePath + "/Ego.csv");
|
|
|
+ downloadDependFile(sceneEvaluationComputeParam.getEvaluationPath() + "/evaluation.csv", scenePath + "/evaluation.csv");
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
@@ -301,12 +313,11 @@ public class SceneEvaluationRuleService {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
-// String sceneEvaluationCommand = "python3 " + pyMainPath + " " + (scenePath);
|
|
|
String sceneEvaluationCommand;
|
|
|
if (StringUtils.equals(sceneEvaluationComputeParams.get(0).getComputeType(), DictConstants.COMPLEXITY)) {
|
|
|
- sceneEvaluationCommand = "python " + pyMainPath + " complexity";
|
|
|
+ sceneEvaluationCommand = pyMainPath + " " + scenePathFather + " complexity";
|
|
|
} else {
|
|
|
- sceneEvaluationCommand = "python " + pyMainPath + " criticality";
|
|
|
+ sceneEvaluationCommand = pyMainPath + " " + scenePathFather + " criticality";
|
|
|
}
|
|
|
String sceneEvaluationResult;
|
|
|
log.info("开始执行场景评价命令:" + sceneEvaluationCommand);
|