[KC-108] ai api batch 작업중
This commit is contained in:
@@ -29,10 +29,8 @@ public class InferenceDetailDto {
|
||||
private String dataName;
|
||||
private Long mapSheepNum;
|
||||
private Long detectingCnt;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime analStrtDttm;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime analEndDttm;
|
||||
@JsonFormatDttm private ZonedDateTime analStrtDttm;
|
||||
@JsonFormatDttm private ZonedDateTime analEndDttm;
|
||||
private Long analSec;
|
||||
private String analState;
|
||||
|
||||
@@ -63,10 +61,8 @@ public class InferenceDetailDto {
|
||||
private Long id;
|
||||
private String analTitle;
|
||||
private Long detectingCnt;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime analStrtDttm;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime analEndDttm;
|
||||
@JsonFormatDttm private ZonedDateTime analStrtDttm;
|
||||
@JsonFormatDttm private ZonedDateTime analEndDttm;
|
||||
private Long analSec;
|
||||
private Long analPredSec;
|
||||
private String analState;
|
||||
@@ -106,10 +102,8 @@ public class InferenceDetailDto {
|
||||
private String modelInfo;
|
||||
private Integer targetYyyy;
|
||||
private Integer compareYyyy;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime analStrtDttm;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime analEndDttm;
|
||||
@JsonFormatDttm private ZonedDateTime analStrtDttm;
|
||||
@JsonFormatDttm private ZonedDateTime analEndDttm;
|
||||
private Long analSec;
|
||||
private Long analPredSec;
|
||||
private String resultUrl;
|
||||
@@ -189,8 +183,7 @@ public class InferenceDetailDto {
|
||||
private Clazzes target;
|
||||
private MapSheet mapSheet;
|
||||
private Coordinate center;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime updatedDttm;
|
||||
@JsonFormatDttm private ZonedDateTime updatedDttm;
|
||||
|
||||
public DetailListEntity(
|
||||
UUID uuid,
|
||||
@@ -240,8 +233,7 @@ public class InferenceDetailDto {
|
||||
|
||||
private String code;
|
||||
private String name;
|
||||
@JsonIgnore
|
||||
private Double score;
|
||||
@JsonIgnore private Double score;
|
||||
|
||||
public Clazz(String code, Double score) {
|
||||
this.code = code;
|
||||
@@ -308,10 +300,8 @@ public class InferenceDetailDto {
|
||||
String classAfterName;
|
||||
Double classAfterProb;
|
||||
Long mapSheetNum;
|
||||
@JsonIgnore
|
||||
String gemoStr;
|
||||
@JsonIgnore
|
||||
String geomCenterStr;
|
||||
@JsonIgnore String gemoStr;
|
||||
@JsonIgnore String geomCenterStr;
|
||||
JsonNode gemo;
|
||||
JsonNode geomCenter;
|
||||
|
||||
|
||||
@@ -23,9 +23,7 @@ import org.springframework.data.domain.Pageable;
|
||||
|
||||
public class InferenceResultDto {
|
||||
|
||||
/**
|
||||
* 목록조회 dto
|
||||
*/
|
||||
/** 목록조회 dto */
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@@ -37,15 +35,11 @@ public class InferenceResultDto {
|
||||
private String status;
|
||||
private String mapSheetCnt;
|
||||
private Long detectingCnt;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime startTime;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime endTime;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime elapsedTime;
|
||||
@JsonFormatDttm private ZonedDateTime startTime;
|
||||
@JsonFormatDttm private ZonedDateTime endTime;
|
||||
@JsonFormatDttm private ZonedDateTime elapsedTime;
|
||||
private Boolean applyYn;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime applyDttm;
|
||||
@JsonFormatDttm private ZonedDateTime applyDttm;
|
||||
|
||||
@JsonProperty("statusName")
|
||||
public String statusName() {
|
||||
@@ -53,9 +47,7 @@ public class InferenceResultDto {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록조회 검색 조건 dto
|
||||
*/
|
||||
/** 목록조회 검색 조건 dto */
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@@ -270,7 +262,6 @@ public class InferenceResultDto {
|
||||
this.model3Ver = model3Ver;
|
||||
|
||||
if (this.detectingEndCnt == null) this.detectingEndCnt = 0L;
|
||||
|
||||
}
|
||||
|
||||
private String usedServerName;
|
||||
@@ -336,7 +327,6 @@ public class InferenceResultDto {
|
||||
|
||||
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
@@ -346,12 +336,9 @@ public class InferenceResultDto {
|
||||
public static class InferenceServerStatusDto {
|
||||
|
||||
private String serverName;
|
||||
@JsonIgnore
|
||||
private float cpu_user;
|
||||
@JsonIgnore
|
||||
private float cpu_system;
|
||||
@JsonIgnore
|
||||
private float memused;
|
||||
@JsonIgnore private float cpu_user;
|
||||
@JsonIgnore private float cpu_system;
|
||||
@JsonIgnore private float memused;
|
||||
private Long kbmemused;
|
||||
private float gpuUtil;
|
||||
|
||||
|
||||
@@ -254,8 +254,7 @@ public class InferenceResultService {
|
||||
|
||||
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();
|
||||
|
||||
@@ -296,7 +296,6 @@ public class InferenceResultCoreService {
|
||||
}
|
||||
|
||||
entity.setUpdatedDttm(ZonedDateTime.now());
|
||||
|
||||
}
|
||||
|
||||
public List<InferenceServerStatusDto> getInferenceServerStatusList() {
|
||||
|
||||
@@ -126,14 +126,19 @@ public class MapSheetLearnEntity {
|
||||
|
||||
@Column(name = "m1_model_start_dttm")
|
||||
private ZonedDateTime m1ModelStartDttm;
|
||||
|
||||
@Column(name = "m2_model_start_dttm")
|
||||
private ZonedDateTime m2ModelStartDttm;
|
||||
|
||||
@Column(name = "m3_model_start_dttm")
|
||||
private ZonedDateTime m3ModelStartDttm;
|
||||
|
||||
@Column(name = "m1_model_end_dttm")
|
||||
private ZonedDateTime m1ModelEndDttm;
|
||||
|
||||
@Column(name = "m2_model_end_dttm")
|
||||
private ZonedDateTime m2ModelEndDttm;
|
||||
|
||||
@Column(name = "m3_model_end_dttm")
|
||||
private ZonedDateTime m3ModelEndDttm;
|
||||
|
||||
|
||||
@@ -172,7 +172,6 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
|
||||
mapSheetLearnEntity.inferEndDttm,
|
||||
mapSheetLearnEntity.detectingCnt,
|
||||
mapSheetLearnEntity.detectEndCnt,
|
||||
|
||||
m1Model.modelVer.as("model1Ver"),
|
||||
m2Model.modelVer.as("model2Ver"),
|
||||
m3Model.modelVer.as("model3Ver")))
|
||||
@@ -212,8 +211,7 @@ public class MapSheetLearnRepositoryImpl implements MapSheetLearnRepositoryCusto
|
||||
model.cdModelConfigFileName.as("cdModelConfigFileName"),
|
||||
model.clsModelPath,
|
||||
model.clsModelFileName,
|
||||
model.clsModelVersion
|
||||
))
|
||||
model.clsModelVersion))
|
||||
.from(mapSheetLearnEntity)
|
||||
.join(model)
|
||||
.on(model.uuid.eq(modelUuid))
|
||||
|
||||
@@ -48,14 +48,12 @@ 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());
|
||||
|
||||
@@ -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());
|
||||
@@ -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