[KC-108] ai api batch 작업중
This commit is contained in:
@@ -29,10 +29,8 @@ public class InferenceDetailDto {
|
|||||||
private String dataName;
|
private String dataName;
|
||||||
private Long mapSheepNum;
|
private Long mapSheepNum;
|
||||||
private Long detectingCnt;
|
private Long detectingCnt;
|
||||||
@JsonFormatDttm
|
@JsonFormatDttm private ZonedDateTime analStrtDttm;
|
||||||
private ZonedDateTime analStrtDttm;
|
@JsonFormatDttm private ZonedDateTime analEndDttm;
|
||||||
@JsonFormatDttm
|
|
||||||
private ZonedDateTime analEndDttm;
|
|
||||||
private Long analSec;
|
private Long analSec;
|
||||||
private String analState;
|
private String analState;
|
||||||
|
|
||||||
@@ -63,10 +61,8 @@ public class InferenceDetailDto {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private String analTitle;
|
private String analTitle;
|
||||||
private Long detectingCnt;
|
private Long detectingCnt;
|
||||||
@JsonFormatDttm
|
@JsonFormatDttm private ZonedDateTime analStrtDttm;
|
||||||
private ZonedDateTime analStrtDttm;
|
@JsonFormatDttm private ZonedDateTime analEndDttm;
|
||||||
@JsonFormatDttm
|
|
||||||
private ZonedDateTime analEndDttm;
|
|
||||||
private Long analSec;
|
private Long analSec;
|
||||||
private Long analPredSec;
|
private Long analPredSec;
|
||||||
private String analState;
|
private String analState;
|
||||||
@@ -106,10 +102,8 @@ public class InferenceDetailDto {
|
|||||||
private String modelInfo;
|
private String modelInfo;
|
||||||
private Integer targetYyyy;
|
private Integer targetYyyy;
|
||||||
private Integer compareYyyy;
|
private Integer compareYyyy;
|
||||||
@JsonFormatDttm
|
@JsonFormatDttm private ZonedDateTime analStrtDttm;
|
||||||
private ZonedDateTime analStrtDttm;
|
@JsonFormatDttm private ZonedDateTime analEndDttm;
|
||||||
@JsonFormatDttm
|
|
||||||
private ZonedDateTime analEndDttm;
|
|
||||||
private Long analSec;
|
private Long analSec;
|
||||||
private Long analPredSec;
|
private Long analPredSec;
|
||||||
private String resultUrl;
|
private String resultUrl;
|
||||||
@@ -189,8 +183,7 @@ public class InferenceDetailDto {
|
|||||||
private Clazzes target;
|
private Clazzes target;
|
||||||
private MapSheet mapSheet;
|
private MapSheet mapSheet;
|
||||||
private Coordinate center;
|
private Coordinate center;
|
||||||
@JsonFormatDttm
|
@JsonFormatDttm private ZonedDateTime updatedDttm;
|
||||||
private ZonedDateTime updatedDttm;
|
|
||||||
|
|
||||||
public DetailListEntity(
|
public DetailListEntity(
|
||||||
UUID uuid,
|
UUID uuid,
|
||||||
@@ -240,8 +233,7 @@ public class InferenceDetailDto {
|
|||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
private String name;
|
private String name;
|
||||||
@JsonIgnore
|
@JsonIgnore private Double score;
|
||||||
private Double score;
|
|
||||||
|
|
||||||
public Clazz(String code, Double score) {
|
public Clazz(String code, Double score) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
@@ -308,10 +300,8 @@ public class InferenceDetailDto {
|
|||||||
String classAfterName;
|
String classAfterName;
|
||||||
Double classAfterProb;
|
Double classAfterProb;
|
||||||
Long mapSheetNum;
|
Long mapSheetNum;
|
||||||
@JsonIgnore
|
@JsonIgnore String gemoStr;
|
||||||
String gemoStr;
|
@JsonIgnore String geomCenterStr;
|
||||||
@JsonIgnore
|
|
||||||
String geomCenterStr;
|
|
||||||
JsonNode gemo;
|
JsonNode gemo;
|
||||||
JsonNode geomCenter;
|
JsonNode geomCenter;
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ import org.springframework.data.domain.Pageable;
|
|||||||
|
|
||||||
public class InferenceResultDto {
|
public class InferenceResultDto {
|
||||||
|
|
||||||
/**
|
/** 목록조회 dto */
|
||||||
* 목록조회 dto
|
|
||||||
*/
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@@ -37,15 +35,11 @@ public class InferenceResultDto {
|
|||||||
private String status;
|
private String status;
|
||||||
private String mapSheetCnt;
|
private String mapSheetCnt;
|
||||||
private Long detectingCnt;
|
private Long detectingCnt;
|
||||||
@JsonFormatDttm
|
@JsonFormatDttm private ZonedDateTime startTime;
|
||||||
private ZonedDateTime startTime;
|
@JsonFormatDttm private ZonedDateTime endTime;
|
||||||
@JsonFormatDttm
|
@JsonFormatDttm private ZonedDateTime elapsedTime;
|
||||||
private ZonedDateTime endTime;
|
|
||||||
@JsonFormatDttm
|
|
||||||
private ZonedDateTime elapsedTime;
|
|
||||||
private Boolean applyYn;
|
private Boolean applyYn;
|
||||||
@JsonFormatDttm
|
@JsonFormatDttm private ZonedDateTime applyDttm;
|
||||||
private ZonedDateTime applyDttm;
|
|
||||||
|
|
||||||
@JsonProperty("statusName")
|
@JsonProperty("statusName")
|
||||||
public String statusName() {
|
public String statusName() {
|
||||||
@@ -53,9 +47,7 @@ public class InferenceResultDto {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 목록조회 검색 조건 dto */
|
||||||
* 목록조회 검색 조건 dto
|
|
||||||
*/
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@@ -270,7 +262,6 @@ public class InferenceResultDto {
|
|||||||
this.model3Ver = model3Ver;
|
this.model3Ver = model3Ver;
|
||||||
|
|
||||||
if (this.detectingEndCnt == null) this.detectingEndCnt = 0L;
|
if (this.detectingEndCnt == null) this.detectingEndCnt = 0L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String usedServerName;
|
private String usedServerName;
|
||||||
@@ -336,7 +327,6 @@ public class InferenceResultDto {
|
|||||||
|
|
||||||
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
|
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -346,12 +336,9 @@ public class InferenceResultDto {
|
|||||||
public static class InferenceServerStatusDto {
|
public static class InferenceServerStatusDto {
|
||||||
|
|
||||||
private String serverName;
|
private String serverName;
|
||||||
@JsonIgnore
|
@JsonIgnore private float cpu_user;
|
||||||
private float cpu_user;
|
@JsonIgnore private float cpu_system;
|
||||||
@JsonIgnore
|
@JsonIgnore private float memused;
|
||||||
private float cpu_system;
|
|
||||||
@JsonIgnore
|
|
||||||
private float memused;
|
|
||||||
private Long kbmemused;
|
private Long kbmemused;
|
||||||
private float gpuUtil;
|
private float gpuUtil;
|
||||||
|
|
||||||
|
|||||||
@@ -254,8 +254,7 @@ public class InferenceResultService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
List<Map<String, Object>> list =
|
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");
|
Integer batchIdInt = (Integer) list.get(0).get("batch_id");
|
||||||
batchId = batchIdInt.longValue();
|
batchId = batchIdInt.longValue();
|
||||||
|
|||||||
@@ -296,7 +296,6 @@ public class InferenceResultCoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entity.setUpdatedDttm(ZonedDateTime.now());
|
entity.setUpdatedDttm(ZonedDateTime.now());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InferenceServerStatusDto> getInferenceServerStatusList() {
|
public List<InferenceServerStatusDto> getInferenceServerStatusList() {
|
||||||
|
|||||||
@@ -126,14 +126,19 @@ public class MapSheetLearnEntity {
|
|||||||
|
|
||||||
@Column(name = "m1_model_start_dttm")
|
@Column(name = "m1_model_start_dttm")
|
||||||
private ZonedDateTime m1ModelStartDttm;
|
private ZonedDateTime m1ModelStartDttm;
|
||||||
|
|
||||||
@Column(name = "m2_model_start_dttm")
|
@Column(name = "m2_model_start_dttm")
|
||||||
private ZonedDateTime m2ModelStartDttm;
|
private ZonedDateTime m2ModelStartDttm;
|
||||||
|
|
||||||
@Column(name = "m3_model_start_dttm")
|
@Column(name = "m3_model_start_dttm")
|
||||||
private ZonedDateTime m3ModelStartDttm;
|
private ZonedDateTime m3ModelStartDttm;
|
||||||
|
|
||||||
@Column(name = "m1_model_end_dttm")
|
@Column(name = "m1_model_end_dttm")
|
||||||
private ZonedDateTime m1ModelEndDttm;
|
private ZonedDateTime m1ModelEndDttm;
|
||||||
|
|
||||||
@Column(name = "m2_model_end_dttm")
|
@Column(name = "m2_model_end_dttm")
|
||||||
private ZonedDateTime m2ModelEndDttm;
|
private ZonedDateTime m2ModelEndDttm;
|
||||||
|
|
||||||
@Column(name = "m3_model_end_dttm")
|
@Column(name = "m3_model_end_dttm")
|
||||||
private ZonedDateTime m3ModelEndDttm;
|
private ZonedDateTime m3ModelEndDttm;
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,6 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
|
|||||||
mapSheetLearnEntity.inferEndDttm,
|
mapSheetLearnEntity.inferEndDttm,
|
||||||
mapSheetLearnEntity.detectingCnt,
|
mapSheetLearnEntity.detectingCnt,
|
||||||
mapSheetLearnEntity.detectEndCnt,
|
mapSheetLearnEntity.detectEndCnt,
|
||||||
|
|
||||||
m1Model.modelVer.as("model1Ver"),
|
m1Model.modelVer.as("model1Ver"),
|
||||||
m2Model.modelVer.as("model2Ver"),
|
m2Model.modelVer.as("model2Ver"),
|
||||||
m3Model.modelVer.as("model3Ver")))
|
m3Model.modelVer.as("model3Ver")))
|
||||||
@@ -212,8 +211,7 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
|
|||||||
model.cdModelConfigFileName.as("cdModelConfigFileName"),
|
model.cdModelConfigFileName.as("cdModelConfigFileName"),
|
||||||
model.clsModelPath,
|
model.clsModelPath,
|
||||||
model.clsModelFileName,
|
model.clsModelFileName,
|
||||||
model.clsModelVersion
|
model.clsModelVersion))
|
||||||
))
|
|
||||||
.from(mapSheetLearnEntity)
|
.from(mapSheetLearnEntity)
|
||||||
.join(model)
|
.join(model)
|
||||||
.on(model.uuid.eq(modelUuid))
|
.on(model.uuid.eq(modelUuid))
|
||||||
|
|||||||
@@ -48,14 +48,12 @@ public class MapSheetInferenceJobService {
|
|||||||
@Value("${inference.url}")
|
@Value("${inference.url}")
|
||||||
private String inferenceUrl;
|
private String inferenceUrl;
|
||||||
|
|
||||||
|
/** 추론 진행 배치 1분 */
|
||||||
@Scheduled(fixedDelay = 60_000)
|
@Scheduled(fixedDelay = 60_000)
|
||||||
@Transactional
|
@Transactional
|
||||||
public void runBatch() {
|
public void runBatch() {
|
||||||
log.info("1분 배치 시작");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO: 배치 로직 작성
|
|
||||||
|
|
||||||
InferenceBatchSheet batchSheet =
|
InferenceBatchSheet batchSheet =
|
||||||
inferenceResultCoreService.getInferenceResultByStatus(Status.IN_PROGRESS.getId());
|
inferenceResultCoreService.getInferenceResultByStatus(Status.IN_PROGRESS.getId());
|
||||||
|
|
||||||
@@ -99,12 +97,14 @@ public class MapSheetInferenceJobService {
|
|||||||
|
|
||||||
if (type.equals("M1")) {
|
if (type.equals("M1")) {
|
||||||
// M1 완료되었으면 M2 실행
|
// 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");
|
this.updateProcessingEndTimeByModel(batchSheet.getUuid(), ZonedDateTime.now(), "M1");
|
||||||
} else if (type.equals("M2")) {
|
} else if (type.equals("M2")) {
|
||||||
// M1 완료되었으면 M3 실행
|
// 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");
|
this.updateProcessingEndTimeByModel(batchSheet.getUuid(), ZonedDateTime.now(), "M2");
|
||||||
} else if (type.equals("M3")) {
|
} else if (type.equals("M3")) {
|
||||||
@@ -129,25 +129,28 @@ public class MapSheetInferenceJobService {
|
|||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
log.error("배치 중 인터럽트 발생", e);
|
log.error("배치 중 인터럽트 발생", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("1분 배치 종료");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startInference(Long id, UUID uuid, String type, UUID modelUuid) {
|
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();
|
pred_requests_areas predRequestsAreas = new pred_requests_areas();
|
||||||
predRequestsAreas.setInput1_year(progressDto.getPred_requests_areas().getInput1_year());
|
predRequestsAreas.setInput1_year(progressDto.getPred_requests_areas().getInput1_year());
|
||||||
predRequestsAreas.setInput2_year(progressDto.getPred_requests_areas().getInput2_year());
|
predRequestsAreas.setInput2_year(progressDto.getPred_requests_areas().getInput2_year());
|
||||||
predRequestsAreas.setInput1_scene_path(progressDto.getPred_requests_areas().getInput1_scene_path());
|
predRequestsAreas.setInput1_scene_path(
|
||||||
predRequestsAreas.setInput2_scene_path(progressDto.getPred_requests_areas().getInput2_scene_path());
|
progressDto.getPred_requests_areas().getInput1_scene_path());
|
||||||
|
predRequestsAreas.setInput2_scene_path(
|
||||||
|
progressDto.getPred_requests_areas().getInput2_scene_path());
|
||||||
|
|
||||||
InferenceSendDto m = new InferenceSendDto();
|
InferenceSendDto m = new InferenceSendDto();
|
||||||
m.setModel_version(progressDto.getModelVersion());
|
m.setModel_version(progressDto.getModelVersion());
|
||||||
m.setCd_model_path(progressDto.getCdModelPath() + "/" + progressDto.getCdModelFileName());
|
m.setCd_model_path(progressDto.getCdModelPath() + "/" + progressDto.getCdModelFileName());
|
||||||
m.setCd_model_config(progressDto.getCdModelConfigPath() + "/" + progressDto.getCdModelConfigFileName());
|
m.setCd_model_config(
|
||||||
m.setCls_model_path(progressDto.getCdModelClsPath() + "/" + progressDto.getCdModelClsFileName());
|
progressDto.getCdModelConfigPath() + "/" + progressDto.getCdModelConfigFileName());
|
||||||
|
m.setCls_model_path(
|
||||||
|
progressDto.getCdModelClsPath() + "/" + progressDto.getCdModelClsFileName());
|
||||||
m.setCls_model_version(progressDto.getClsModelVersion());
|
m.setCls_model_version(progressDto.getClsModelVersion());
|
||||||
m.setCd_model_type(type);
|
m.setCd_model_type(type);
|
||||||
m.setPriority(progressDto.getPriority());
|
m.setPriority(progressDto.getPriority());
|
||||||
@@ -197,8 +200,7 @@ public class MapSheetInferenceJobService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
List<Map<String, Object>> list =
|
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");
|
Integer batchIdInt = (Integer) list.get(0).get("batch_id");
|
||||||
batchId = batchIdInt.longValue();
|
batchId = batchIdInt.longValue();
|
||||||
|
|||||||
Reference in New Issue
Block a user