[KC-108] ai api batch 작업중
This commit is contained in:
@@ -48,16 +48,14 @@ public class MapSheetInferenceJobService {
|
||||
@Value("${inference.url}")
|
||||
private String inferenceUrl;
|
||||
|
||||
/** 추론 진행 배치 1분 */
|
||||
@Scheduled(fixedDelay = 60_000)
|
||||
@Transactional
|
||||
public void runBatch() {
|
||||
log.info("1분 배치 시작");
|
||||
|
||||
try {
|
||||
// TODO: 배치 로직 작성
|
||||
|
||||
InferenceBatchSheet batchSheet =
|
||||
inferenceResultCoreService.getInferenceResultByStatus(Status.IN_PROGRESS.getId());
|
||||
inferenceResultCoreService.getInferenceResultByStatus(Status.IN_PROGRESS.getId());
|
||||
|
||||
if (batchSheet == null) {
|
||||
return;
|
||||
@@ -84,7 +82,7 @@ public class MapSheetInferenceJobService {
|
||||
String url = batchUrl + "/" + batchId;
|
||||
|
||||
ExternalCallResult<String> result =
|
||||
externalHttpClient.call(url, HttpMethod.GET, null, headers, String.class);
|
||||
externalHttpClient.call(url, HttpMethod.GET, null, headers, String.class);
|
||||
|
||||
int status = result.statusCode();
|
||||
if (status < 200 || status >= 300) {
|
||||
@@ -99,12 +97,14 @@ public class MapSheetInferenceJobService {
|
||||
|
||||
if (type.equals("M1")) {
|
||||
// M1 완료되었으면 M2 실행
|
||||
this.startInference(batchSheet.getId(), batchSheet.getUuid(), "M2", batchSheet.getM2ModelUuid());
|
||||
this.startInference(
|
||||
batchSheet.getId(), batchSheet.getUuid(), "M2", batchSheet.getM2ModelUuid());
|
||||
// 종료시간
|
||||
this.updateProcessingEndTimeByModel(batchSheet.getUuid(), ZonedDateTime.now(), "M1");
|
||||
} else if (type.equals("M2")) {
|
||||
// M1 완료되었으면 M3 실행
|
||||
this.startInference(batchSheet.getId(), batchSheet.getUuid(), "M3", batchSheet.getM3ModelUuid());
|
||||
this.startInference(
|
||||
batchSheet.getId(), batchSheet.getUuid(), "M3", batchSheet.getM3ModelUuid());
|
||||
// 종료시간
|
||||
this.updateProcessingEndTimeByModel(batchSheet.getUuid(), ZonedDateTime.now(), "M2");
|
||||
} else if (type.equals("M3")) {
|
||||
@@ -129,25 +129,28 @@ public class MapSheetInferenceJobService {
|
||||
Thread.currentThread().interrupt();
|
||||
log.error("배치 중 인터럽트 발생", e);
|
||||
}
|
||||
|
||||
log.info("1분 배치 종료");
|
||||
}
|
||||
|
||||
private void startInference(Long id, UUID uuid, String type, UUID modelUuid) {
|
||||
|
||||
InferenceProgressDto progressDto = inferenceResultCoreService.getInferenceAiResultById(id, type, modelUuid);
|
||||
InferenceProgressDto progressDto =
|
||||
inferenceResultCoreService.getInferenceAiResultById(id, type, modelUuid);
|
||||
|
||||
pred_requests_areas predRequestsAreas = new 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());
|
||||
predRequestsAreas.setInput2_scene_path(progressDto.getPred_requests_areas().getInput2_scene_path());
|
||||
predRequestsAreas.setInput1_scene_path(
|
||||
progressDto.getPred_requests_areas().getInput1_scene_path());
|
||||
predRequestsAreas.setInput2_scene_path(
|
||||
progressDto.getPred_requests_areas().getInput2_scene_path());
|
||||
|
||||
InferenceSendDto m = new InferenceSendDto();
|
||||
m.setModel_version(progressDto.getModelVersion());
|
||||
m.setCd_model_path(progressDto.getCdModelPath() + "/" + progressDto.getCdModelFileName());
|
||||
m.setCd_model_config(progressDto.getCdModelConfigPath() + "/" + progressDto.getCdModelConfigFileName());
|
||||
m.setCls_model_path(progressDto.getCdModelClsPath() + "/" + progressDto.getCdModelClsFileName());
|
||||
m.setCd_model_config(
|
||||
progressDto.getCdModelConfigPath() + "/" + progressDto.getCdModelConfigFileName());
|
||||
m.setCls_model_path(
|
||||
progressDto.getCdModelClsPath() + "/" + progressDto.getCdModelClsFileName());
|
||||
m.setCls_model_version(progressDto.getClsModelVersion());
|
||||
m.setCd_model_type(type);
|
||||
m.setPriority(progressDto.getPriority());
|
||||
@@ -184,7 +187,7 @@ public class MapSheetInferenceJobService {
|
||||
}
|
||||
|
||||
ExternalCallResult<String> result =
|
||||
externalHttpClient.call(inferenceUrl, HttpMethod.POST, dto, headers, String.class);
|
||||
externalHttpClient.call(inferenceUrl, HttpMethod.POST, dto, headers, String.class);
|
||||
|
||||
int status = result.statusCode();
|
||||
String body = result.body();
|
||||
@@ -197,8 +200,7 @@ public class MapSheetInferenceJobService {
|
||||
|
||||
try {
|
||||
List<Map<String, Object>> list =
|
||||
om.readValue(body, new TypeReference<List<Map<String, Object>>>() {
|
||||
});
|
||||
om.readValue(body, new TypeReference<List<Map<String, Object>>>() {});
|
||||
|
||||
Integer batchIdInt = (Integer) list.get(0).get("batch_id");
|
||||
batchId = batchIdInt.longValue();
|
||||
|
||||
Reference in New Issue
Block a user