shp파일 생성 수정, 미사용 소스 제거
This commit is contained in:
@@ -10,7 +10,6 @@ import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto.InferenceBatchShe
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceProgressDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.SaveInferenceAiDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Status;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultsTestingDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceSendDto;
|
||||
import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
|
||||
import com.kamco.cd.kamcoback.scheduler.dto.BatchStatusDto;
|
||||
@@ -59,7 +58,9 @@ public class MapSheetInferenceJobService {
|
||||
@Value("${file.dataset-dir}")
|
||||
private String datasetDir;
|
||||
|
||||
/** 추론 진행 배치 1분 60_000 */
|
||||
/**
|
||||
* 추론 진행 배치 1분 60_000
|
||||
*/
|
||||
@Scheduled(fixedDelay = 60_000)
|
||||
public void runBatch() {
|
||||
if (isLocalProfile()) {
|
||||
@@ -144,7 +145,7 @@ public class MapSheetInferenceJobService {
|
||||
String url = batchUrl + "/" + batchId;
|
||||
|
||||
ExternalCallResult<String> result =
|
||||
externalHttpClient.call(url, HttpMethod.GET, null, jsonHeaders(), String.class);
|
||||
externalHttpClient.call(url, HttpMethod.GET, null, jsonHeaders(), String.class);
|
||||
|
||||
int status = result.statusCode();
|
||||
if (status == 404) {
|
||||
@@ -169,7 +170,7 @@ public class MapSheetInferenceJobService {
|
||||
String url = inferenceUrl + "/" + jobId;
|
||||
|
||||
ExternalCallResult<String> result =
|
||||
externalHttpClient.call(url, HttpMethod.GET, null, jsonHeaders(), String.class);
|
||||
externalHttpClient.call(url, HttpMethod.GET, null, jsonHeaders(), String.class);
|
||||
|
||||
int status = result.statusCode();
|
||||
if (status == 404) {
|
||||
@@ -250,26 +251,10 @@ public class MapSheetInferenceJobService {
|
||||
batchIds.add(sheet.getM2BatchId());
|
||||
batchIds.add(sheet.getM3BatchId());
|
||||
|
||||
List<InferenceResultsTestingDto.ShpDto> resultList =
|
||||
inferenceResultCoreService.getInferenceResults(batchIds);
|
||||
String inferenceId = "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (InferenceResultsTestingDto.ShpDto dto : resultList) {
|
||||
if (dto.getMapId() == null) {
|
||||
continue;
|
||||
}
|
||||
if (!sb.isEmpty()) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append("\"").append(dto.getMapId()).append("\"");
|
||||
}
|
||||
inferenceId = sheet.getUid();
|
||||
String mapIds = sb.toString();
|
||||
String batchId = sheet.getM1BatchId() + "," + sheet.getM2BatchId() + "," + sheet.getM3BatchId();
|
||||
|
||||
// shp 파일 비동기 생성
|
||||
shpPipelineService.runPipeline(jarPath, datasetDir, batchId, inferenceId, mapIds);
|
||||
shpPipelineService.runPipeline(jarPath, datasetDir, batchId, sheet.getUid());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,28 +328,28 @@ public class MapSheetInferenceJobService {
|
||||
|
||||
// 추론 실행 api 파라미터 조회
|
||||
InferenceProgressDto progressDto =
|
||||
inferenceResultCoreService.getInferenceAiResultById(id, modelUuid);
|
||||
inferenceResultCoreService.getInferenceAiResultById(id, modelUuid);
|
||||
|
||||
// ai 에 맞는 모델 명으로 변경
|
||||
String inferenceType = modelToInferenceType(type);
|
||||
|
||||
InferenceSendDto.pred_requests_areas predRequestsAreas =
|
||||
new InferenceSendDto.pred_requests_areas();
|
||||
new InferenceSendDto.pred_requests_areas();
|
||||
predRequestsAreas.setInput1_year(progressDto.getPred_requests_areas().getInput1_year());
|
||||
predRequestsAreas.setInput2_year(progressDto.getPred_requests_areas().getInput2_year());
|
||||
predRequestsAreas.setInput1_scene_path(
|
||||
progressDto.getPred_requests_areas().getInput1_scene_path());
|
||||
progressDto.getPred_requests_areas().getInput1_scene_path());
|
||||
predRequestsAreas.setInput2_scene_path(
|
||||
progressDto.getPred_requests_areas().getInput2_scene_path());
|
||||
progressDto.getPred_requests_areas().getInput2_scene_path());
|
||||
|
||||
InferenceSendDto m = new InferenceSendDto();
|
||||
m.setPred_requests_areas(predRequestsAreas);
|
||||
m.setModel_version(progressDto.getModelVersion());
|
||||
m.setCd_model_path(progressDto.getCdModelPath() + "/" + progressDto.getCdModelFileName());
|
||||
m.setCd_model_config(
|
||||
progressDto.getCdModelConfigPath() + "/" + progressDto.getCdModelConfigFileName());
|
||||
progressDto.getCdModelConfigPath() + "/" + progressDto.getCdModelConfigFileName());
|
||||
m.setCls_model_path(
|
||||
progressDto.getCdModelClsPath() + "/" + progressDto.getCdModelClsFileName());
|
||||
progressDto.getCdModelClsPath() + "/" + progressDto.getCdModelClsFileName());
|
||||
m.setCls_model_version(progressDto.getClsModelVersion());
|
||||
m.setCd_model_type(inferenceType);
|
||||
m.setPriority(progressDto.getPriority());
|
||||
@@ -432,7 +417,7 @@ public class MapSheetInferenceJobService {
|
||||
headers.setAccept(List.of(MediaType.APPLICATION_JSON));
|
||||
|
||||
ExternalCallResult<String> result =
|
||||
externalHttpClient.call(inferenceUrl, HttpMethod.POST, dto, headers, String.class);
|
||||
externalHttpClient.call(inferenceUrl, HttpMethod.POST, dto, headers, String.class);
|
||||
|
||||
if (result.statusCode() < 200 || result.statusCode() >= 300) {
|
||||
log.error("Inference API failed. status={}, body={}", result.statusCode(), result.body());
|
||||
@@ -442,7 +427,8 @@ public class MapSheetInferenceJobService {
|
||||
// 4) 응답 파싱
|
||||
try {
|
||||
List<Map<String, Object>> list =
|
||||
objectMapper.readValue(result.body(), new TypeReference<>() {});
|
||||
objectMapper.readValue(result.body(), new TypeReference<>() {
|
||||
});
|
||||
|
||||
if (list.isEmpty()) {
|
||||
throw new IllegalStateException("Inference response is empty");
|
||||
@@ -470,9 +456,11 @@ public class MapSheetInferenceJobService {
|
||||
return "local".equalsIgnoreCase(profile);
|
||||
}
|
||||
|
||||
/** 모델별 추론 종료 update */
|
||||
/**
|
||||
* 모델별 추론 종료 update
|
||||
*/
|
||||
private void updateProcessingEndTimeByModel(
|
||||
BatchStatusDto dto, UUID uuid, ZonedDateTime dateTime, String type) {
|
||||
BatchStatusDto dto, UUID uuid, ZonedDateTime dateTime, String type) {
|
||||
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
||||
saveInferenceAiDto.setUuid(uuid);
|
||||
saveInferenceAiDto.setUpdateUid(0L);
|
||||
@@ -506,16 +494,16 @@ public class MapSheetInferenceJobService {
|
||||
/**
|
||||
* 도엽별 실패여부 업데이트
|
||||
*
|
||||
* @param dto batch 정보
|
||||
* @param dto batch 정보
|
||||
* @param uuid uuid
|
||||
* @param type 모델 타입
|
||||
*/
|
||||
private void saveFail5k(BatchStatusDto dto, UUID uuid, String type) {
|
||||
|
||||
List<Long> failedIds =
|
||||
Optional.ofNullable(dto.getFailedIds()).orElse(List.of()).stream()
|
||||
.map(Long::valueOf)
|
||||
.toList();
|
||||
Optional.ofNullable(dto.getFailedIds()).orElse(List.of()).stream()
|
||||
.map(Long::valueOf)
|
||||
.toList();
|
||||
|
||||
List<Long> jobIds = inferenceResultCoreService.findFail5kList(uuid, failedIds, type);
|
||||
|
||||
@@ -540,16 +528,16 @@ public class MapSheetInferenceJobService {
|
||||
/**
|
||||
* 도엽별 job id 저장
|
||||
*
|
||||
* @param dto batch 정보
|
||||
* @param dto batch 정보
|
||||
* @param uuid uuid
|
||||
* @param type 모델 타입
|
||||
*/
|
||||
private void saveCompleted5k(BatchStatusDto dto, UUID uuid, String type) {
|
||||
|
||||
List<Long> completedIds =
|
||||
Optional.ofNullable(dto.getCompletedIds()).orElse(List.of()).stream()
|
||||
.map(Long::valueOf)
|
||||
.toList();
|
||||
Optional.ofNullable(dto.getCompletedIds()).orElse(List.of()).stream()
|
||||
.map(Long::valueOf)
|
||||
.toList();
|
||||
|
||||
List<Long> jobIds = inferenceResultCoreService.findCompleted5kList(uuid, completedIds, type);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ShpPipelineService {
|
||||
|
||||
@Async("shpExecutor")
|
||||
public void runPipeline(
|
||||
String jarPath, String datasetDir, String batchId, String inferenceId, String mapIds) {
|
||||
String jarPath, String datasetDir, String batchId, String inferenceId) {
|
||||
|
||||
// inferenceId 기준 동시 실행 제한
|
||||
if (!shpKeyLock.tryLock(inferenceId)) {
|
||||
@@ -27,15 +27,14 @@ public class ShpPipelineService {
|
||||
|
||||
try {
|
||||
// uid 기준 merge shp, geojson 파일 생성
|
||||
externalJarRunner.run(jarPath, batchId, inferenceId, "");
|
||||
externalJarRunner.run(jarPath, batchId, inferenceId, "", "MERGED");
|
||||
|
||||
// uid 기준 shp 파일 geoserver 등록
|
||||
String register = datasetDir + "/" + inferenceId + "/merge/" + inferenceId + ".shp";
|
||||
externalJarRunner.run(jarPath, register, inferenceId);
|
||||
|
||||
// uid 기준 도엽별 shp, geojson 파일 생성
|
||||
// TODO 도엽별은 속도 확인 후 다시 체크
|
||||
externalJarRunner.run(jarPath, batchId, inferenceId, mapIds);
|
||||
externalJarRunner.run(jarPath, batchId, inferenceId, "", "RESOLVE");
|
||||
|
||||
log.info("SHP pipeline finished. inferenceId={}", inferenceId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user