Merge pull request 'shp파일 생성 수정, 미사용 소스 제거' (#327) from feat/infer_dev_260107 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/327
This commit is contained in:
@@ -18,13 +18,14 @@ public class ExternalJarRunner {
|
||||
/**
|
||||
* shp 파일 생성
|
||||
*
|
||||
* @param jarPath jar 경로
|
||||
* @param batchIds 배치 아이디
|
||||
* @param jarPath jar 경로
|
||||
* @param batchIds 배치 아이디
|
||||
* @param inferenceId uid
|
||||
* @param mapIds 추론 실행한 도엽 ids
|
||||
* @param mode <p>MERGED - batch-ids 에 해당하는 **모든 데이터를 하나의 Shapefile로 병합 생성,
|
||||
* <p>MAP_IDS - 명시적으로 전달한 map-ids만 대상으로 Shapefile 생성,
|
||||
* <p>RESOLVE - batch-ids 기준으로 **JAR 내부에서 map_ids를 조회**한 뒤 Shapefile 생성
|
||||
* @param mapIds 추론 실행한 도엽 ids
|
||||
* @param mode
|
||||
* <p>MERGED - batch-ids 에 해당하는 **모든 데이터를 하나의 Shapefile로 병합 생성,
|
||||
* <p>MAP_IDS - 명시적으로 전달한 map-ids만 대상으로 Shapefile 생성,
|
||||
* <p>RESOLVE - batch-ids 기준으로 **JAR 내부에서 map_ids를 조회**한 뒤 Shapefile 생성
|
||||
*/
|
||||
public void run(String jarPath, String batchIds, String inferenceId, String mapIds, String mode) {
|
||||
List<String> args = new ArrayList<>();
|
||||
@@ -43,13 +44,12 @@ public class ExternalJarRunner {
|
||||
execJar(jarPath, args);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* geoserver 등록
|
||||
*
|
||||
* @param jarPath jar 파일경로
|
||||
* @param jarPath jar 파일경로
|
||||
* @param register shp 경로
|
||||
* @param layer geoserver에 등록될 레이어 이름
|
||||
* @param layer geoserver에 등록될 레이어 이름
|
||||
*/
|
||||
public void run(String jarPath, String register, String layer) {
|
||||
List<String> args = new ArrayList<>();
|
||||
@@ -76,7 +76,7 @@ public class ExternalJarRunner {
|
||||
Process p = pb.start();
|
||||
|
||||
try (BufferedReader br =
|
||||
new BufferedReader(new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8))) {
|
||||
new BufferedReader(new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
out.append(line).append('\n');
|
||||
|
||||
@@ -30,9 +30,7 @@ public class InferenceResultShpService {
|
||||
@Value("${file.dataset-dir}")
|
||||
private String datasetDir;
|
||||
|
||||
/**
|
||||
* inference_results 테이블을 기준으로 분석 결과 테이블과 도형 테이블을 최신 상태로 반영한다.
|
||||
*/
|
||||
/** inference_results 테이블을 기준으로 분석 결과 테이블과 도형 테이블을 최신 상태로 반영한다. */
|
||||
@Transactional
|
||||
public InferenceResultShpDto.InferenceCntDto saveInferenceResultData(Long id) {
|
||||
return coreService.buildInferenceData(id);
|
||||
|
||||
@@ -58,9 +58,7 @@ 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()) {
|
||||
@@ -145,7 +143,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) {
|
||||
@@ -170,7 +168,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) {
|
||||
@@ -328,28 +326,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());
|
||||
@@ -417,7 +415,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());
|
||||
@@ -427,8 +425,7 @@ 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");
|
||||
@@ -456,11 +453,9 @@ 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);
|
||||
@@ -494,16 +489,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);
|
||||
|
||||
@@ -528,16 +523,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);
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@ public class ShpPipelineService {
|
||||
private final ShpKeyLock shpKeyLock;
|
||||
|
||||
@Async("shpExecutor")
|
||||
public void runPipeline(
|
||||
String jarPath, String datasetDir, String batchId, String inferenceId) {
|
||||
public void runPipeline(String jarPath, String datasetDir, String batchId, String inferenceId) {
|
||||
|
||||
// inferenceId 기준 동시 실행 제한
|
||||
if (!shpKeyLock.tryLock(inferenceId)) {
|
||||
|
||||
Reference in New Issue
Block a user