|
@@ -223,88 +223,67 @@ public class DataAugmentationServiceImpl extends BaseServiceImpl<DataAugmentatio
|
|
|
|
|
|
@Override
|
|
|
public CommonResult start(Long id) {
|
|
|
- DataAugmentation dataAugmentation = getById(id);
|
|
|
-
|
|
|
- SysOssVo inputOssEntity = ossService.getById(dataAugmentation.getInputOssId());
|
|
|
-
|
|
|
- String filePath = inputOssEntity.getFileName();
|
|
|
- String localPath = TaaisConfig.getProfile();
|
|
|
- String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
-
|
|
|
- String fileName = StringUtils.substringAfterLast(filePath, "/");
|
|
|
- String fileName_without_suffix = removeFileExtension(fileName);
|
|
|
- Path path = null;
|
|
|
- Path inputPath = null;
|
|
|
- Path outputPath = null;
|
|
|
- Path logPath = null;
|
|
|
-// Path path = Paths.get();
|
|
|
- //String osName = System.getProperty("os.name");
|
|
|
- //判断是否是Windows环境
|
|
|
-// if (osName.toLowerCase().contains("windows")) {
|
|
|
-// path = Paths.get("D:", resourcePath);
|
|
|
-// } else {
|
|
|
-// path = Paths.get(resourcePath);
|
|
|
-//
|
|
|
-// }
|
|
|
- path = Paths.get(resourcePath);
|
|
|
- inputPath = path.resolveSibling(fileName_without_suffix + "_input");
|
|
|
- outputPath = path.resolveSibling(fileName_without_suffix + "_output");
|
|
|
- logPath = path.resolveSibling(fileName_without_suffix + "_log");
|
|
|
- makeDir(inputPath.toString());
|
|
|
- makeDir(outputPath.toString());
|
|
|
- makeDir(logPath.toString());
|
|
|
-
|
|
|
- System.out.println("inputPath:" + inputPath.toString());
|
|
|
- ZipUtils.unzip(resourcePath, inputPath.toString());
|
|
|
- //获取inputPath的下一级目录
|
|
|
-// if (Files.exists(inputPath) && Files.isDirectory(inputPath)) {
|
|
|
-// try (DirectoryStream<Path> stream = Files.newDirectoryStream(inputPath)) {
|
|
|
-// // 遍历目录流以找到第一个子目录
|
|
|
-// for (Path entry : stream) {
|
|
|
-// if (Files.isDirectory(entry)) {
|
|
|
-// // 打印第一个子目录的名称,并跳出循环
|
|
|
-// dataAugmentation.setInputPath(entry.toString());
|
|
|
-// break; // 只处理第一个子目录后退出
|
|
|
-// }
|
|
|
-// }
|
|
|
-// } catch (IOException e) {
|
|
|
-// return CommonResult.fail(e.toString());
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// return CommonResult.fail("The provided path is not a valid directory.");
|
|
|
-// }
|
|
|
- dataAugmentation.setInputPath(inputPath.toString());
|
|
|
- dataAugmentation.setAlgorithmPath(logPath.toString());
|
|
|
- dataAugmentation.setOutputPath(outputPath.toString());
|
|
|
- dataAugmentation.setStartTime(new Date());
|
|
|
- dataAugmentation.setStatus(BizConstant.VideoStatus.RUNNING);
|
|
|
- updateById(dataAugmentation);
|
|
|
- SysDictDataBo sysDictDataBo = new SysDictDataBo();
|
|
|
- sysDictDataBo.setDictLabel(dataAugmentation.getTaskType() + "开始url");
|
|
|
- sysDictDataBo.setDictType("biz_data_augmentation");
|
|
|
- List<SysDictDataVo> sysDictDataVos = iSysDictDataService.selectDictDataList(sysDictDataBo);
|
|
|
- if (sysDictDataVos.size() == 0) {
|
|
|
- return CommonResult.fail("未设置数据增强算法推理的url!请在数据字典中设置该算法的推理url!");
|
|
|
- }
|
|
|
- String data_augmentation_start_url = sysDictDataVos.get(0).getDictValue();
|
|
|
- //设置传输对象
|
|
|
- TransmissionObject transmissionObject = new TransmissionObject();
|
|
|
- transmissionObject.setBizId(dataAugmentation.getId());
|
|
|
- transmissionObject.setBizType(dataAugmentation.getTaskType());
|
|
|
- transmissionObject.setLogPath(dataAugmentation.getAlgorithmPath());
|
|
|
- transmissionObject.setSourcePath(dataAugmentation.getInputPath());
|
|
|
- transmissionObject.setResultPath(dataAugmentation.getOutputPath());
|
|
|
- transmissionObject.setOtherParams(dataAugmentation.getHyperparameterConfiguration());
|
|
|
- HttpResponseEntity responseEntity = sendPostMsg(data_augmentation_start_url, transmissionObject);
|
|
|
-
|
|
|
- if (responseEntity.getStatus() == 200) {
|
|
|
- dataAugmentation.setStatus(BizConstant.VideoStatus.FAILED);
|
|
|
+ try {
|
|
|
+ DataAugmentation dataAugmentation = getById(id);
|
|
|
+ SysOssVo inputOssEntity = ossService.getById(dataAugmentation.getInputOssId());
|
|
|
+ String filePath = inputOssEntity.getFileName();
|
|
|
+ String localPath = TaaisConfig.getProfile();
|
|
|
+ String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
+
|
|
|
+ String fileName = StringUtils.substringAfterLast(filePath, "/");
|
|
|
+ String fileName_without_suffix = removeFileExtension(fileName);
|
|
|
+ Path path = null;
|
|
|
+ Path inputPath = null;
|
|
|
+ Path outputPath = null;
|
|
|
+ Path logPath = null;
|
|
|
+ path = Paths.get(resourcePath);
|
|
|
+ inputPath = path.resolveSibling(fileName_without_suffix + "_input");
|
|
|
+ outputPath = path.resolveSibling(fileName_without_suffix + "_output");
|
|
|
+ logPath = path.resolveSibling(fileName_without_suffix + "_log");
|
|
|
+ makeDir(inputPath.toString());
|
|
|
+ makeDir(outputPath.toString());
|
|
|
+ makeDir(logPath.toString());
|
|
|
+ logPath = Paths.get(logPath.toString(), "log.log");
|
|
|
+ Files.createFile(logPath);
|
|
|
+ System.out.println("inputPath:" + inputPath.toString());
|
|
|
+ ZipUtils.unzip(resourcePath, inputPath.toString());
|
|
|
+ dataAugmentation.setInputPath(inputPath.toString());
|
|
|
+ dataAugmentation.setAlgorithmPath(logPath.toString());
|
|
|
+ dataAugmentation.setOutputPath(outputPath.toString());
|
|
|
+ dataAugmentation.setStartTime(new Date());
|
|
|
+ dataAugmentation.setStatus(BizConstant.VideoStatus.RUNNING);
|
|
|
updateById(dataAugmentation);
|
|
|
- return CommonResult.success("任务开始成功,请等待完成");
|
|
|
- }
|
|
|
- else {
|
|
|
- return CommonResult.fail("任务开始失败,请检查!");
|
|
|
+ SysDictDataBo sysDictDataBo = new SysDictDataBo();
|
|
|
+ sysDictDataBo.setDictLabel(dataAugmentation.getTaskType() + "开始url");
|
|
|
+ sysDictDataBo.setDictType("biz_data_augmentation");
|
|
|
+ List<SysDictDataVo> sysDictDataVos = iSysDictDataService.selectDictDataList(sysDictDataBo);
|
|
|
+ if (sysDictDataVos.size() == 0) {
|
|
|
+ return CommonResult.fail("未设置" + dataAugmentation.getTaskType() + "算法推理的url!请在数据字典中设置该算法的推理url!");
|
|
|
+ }
|
|
|
+ String data_augmentation_start_url = sysDictDataVos.get(0).getDictValue();
|
|
|
+ //设置传输对象
|
|
|
+ TransmissionObject transmissionObject = new TransmissionObject();
|
|
|
+ transmissionObject.setBizId(dataAugmentation.getId());
|
|
|
+ transmissionObject.setBizType(dataAugmentation.getTaskType());
|
|
|
+ transmissionObject.setLogPath(dataAugmentation.getAlgorithmPath());
|
|
|
+ transmissionObject.setSourcePath(dataAugmentation.getInputPath());
|
|
|
+ transmissionObject.setResultPath(dataAugmentation.getOutputPath());
|
|
|
+ transmissionObject.setOtherParams(dataAugmentation.getHyperparameterConfiguration());
|
|
|
+ HttpResponseEntity responseEntity = sendPostMsg(data_augmentation_start_url, transmissionObject);
|
|
|
+
|
|
|
+ if (responseEntity.getStatus() == 200) {
|
|
|
+ dataAugmentation.setStatus(BizConstant.VideoStatus.FAILED);
|
|
|
+ updateById(dataAugmentation);
|
|
|
+ return CommonResult.success("任务开始成功,请等待完成");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return CommonResult.fail("任务开始失败,请检查算法服务!");
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return CommonResult.fail("出现异常:" + e.toString());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public HttpResponseEntity sendPostMsg(String url, Object obj) {
|