Merge pull request '하이퍼파라미터 , 모델관리 수정' (#9) from feat/training_260202 into develop

Reviewed-on: #9
This commit was merged in pull request #9.
This commit is contained in:
2026-02-03 18:25:13 +09:00
18 changed files with 786 additions and 481 deletions

View File

@@ -0,0 +1,26 @@
package com.kamco.cd.training.common.enums;
import com.kamco.cd.training.common.utils.enums.CodeExpose;
import com.kamco.cd.training.common.utils.enums.EnumType;
import lombok.AllArgsConstructor;
import lombok.Getter;
@CodeExpose
@Getter
@AllArgsConstructor
public enum TrainType implements EnumType {
GENERAL("일반"),
TRANSFER("전이");
private final String desc;
@Override
public String getId() {
return name();
}
@Override
public String getText() {
return desc;
}
}

View File

@@ -138,7 +138,7 @@ public class HyperParamApiController {
})
@DeleteMapping("/{uuid}")
public ApiResponseDto<Void> deleteHyperParam(
@Parameter(description = "하이퍼파라미터 uuid", example = "7966dd64-004a-4596-89ef-001664bc4de2")
@Parameter(description = "하이퍼파라미터 uuid", example = "c3b5a285-8f68-42af-84f0-e6d09162deb5")
@PathVariable
UUID uuid) {
hyperParamService.deleteHyperParam(uuid);
@@ -160,7 +160,7 @@ public class HyperParamApiController {
})
@GetMapping("/{uuid}")
public ApiResponseDto<HyperParamDto.Basic> getHyperParam(
@Parameter(description = "하이퍼파라미터 uuid", example = "9c91a20c-71e7-4e5f-a860-9626d2b2059c")
@Parameter(description = "하이퍼파라미터 uuid", example = "c3b5a285-8f68-42af-84f0-e6d09162deb5")
@PathVariable
UUID uuid) {
return ApiResponseDto.ok(hyperParamService.getHyperParam(uuid));

View File

@@ -1,10 +1,13 @@
package com.kamco.cd.training.model.dto;
import com.kamco.cd.training.common.enums.TrainStatusType;
import com.kamco.cd.training.common.enums.TrainType;
import com.kamco.cd.training.common.utils.interfaces.JsonFormatDttm;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.time.Duration;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;
@@ -31,14 +34,72 @@ public class ModelMngDto {
private UUID uuid;
private String modelVer;
@JsonFormatDttm private ZonedDateTime startDttm;
@JsonFormatDttm private ZonedDateTime step1StrtDttm;
@JsonFormatDttm private ZonedDateTime step1EndDttm;
@JsonFormatDttm private ZonedDateTime step1Duration;
@JsonFormatDttm private ZonedDateTime step2StrtDttm;
@JsonFormatDttm private ZonedDateTime step2EndDttm;
@JsonFormatDttm private ZonedDateTime step2Duration;
private String step1Status;
private String step2Status;
private String transferStatus;
private String statusCd;
private String trainType;
public String getStatusName() {
if (this.statusCd == null || this.statusCd.isBlank()) return null;
try {
return TrainStatusType.valueOf(this.statusCd).getText(); // 또는 getName()
} catch (IllegalArgumentException e) {
return this.statusCd; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
}
}
public String getStep1StatusName() {
if (this.step1Status == null || this.step1Status.isBlank()) return null;
try {
return TrainStatusType.valueOf(this.step1Status).getText(); // 또는 getName()
} catch (IllegalArgumentException e) {
return this.step1Status; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
}
}
public String getStep2StatusNAme() {
if (this.step2Status == null || this.step2Status.isBlank()) return null;
try {
return TrainStatusType.valueOf(this.step2Status).getText(); // 또는 getName()
} catch (IllegalArgumentException e) {
return this.step2Status; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
}
}
public String getTrainTypeName() {
if (this.trainType == null || this.trainType.isBlank()) return null;
try {
return TrainType.valueOf(this.trainType).getText(); // 또는 getName()
} catch (IllegalArgumentException e) {
return this.trainType; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
}
}
private String formatDuration(ZonedDateTime start, ZonedDateTime end) {
if (start == null || end == null) {
return null;
}
long totalSeconds = Math.abs(Duration.between(start, end).getSeconds());
long hours = totalSeconds / 3600;
long minutes = (totalSeconds % 3600) / 60;
long seconds = totalSeconds % 60;
return String.format("%d시간 %d분 %d초", hours, minutes, seconds);
}
public String getStep1Duration() {
return formatDuration(this.step1StrtDttm, this.step1EndDttm);
}
public String getStep2Duration() {
return formatDuration(this.step2StrtDttm, this.step2EndDttm);
}
}
@Schema(name = "searchReq", description = "모델 관리 목록조회 파라미터")

View File

@@ -29,7 +29,14 @@ public class ModelMngService {
return modelMngCoreService.findByModelList(searchReq);
}
public void deleteModelTrain(UUID uuid) {}
/**
* 학습모델 삭제
*
* @param uuid
*/
public void deleteModelTrain(UUID uuid) {
modelMngCoreService.deleteModel(uuid);
}
/**
* 모델 상세 조회
@@ -40,14 +47,4 @@ public class ModelMngService {
public ModelMngDto.Detail getModelDetail(Long modelUid) {
return modelMngCoreService.getModelDetail(modelUid);
}
/**
* 모델 상세 조회 (UUID 기반)
*
* @param uuid 모델 UUID
* @return 모델 상세 정보
*/
public ModelMngDto.Detail getModelDetailByUuid(String uuid) {
return modelMngCoreService.getModelDetailByUuid(uuid);
}
}

View File

@@ -4,10 +4,9 @@ import com.kamco.cd.training.common.exception.BadRequestException;
import com.kamco.cd.training.common.exception.NotFoundException;
import com.kamco.cd.training.model.dto.ModelMngDto;
import com.kamco.cd.training.postgres.core.DatasetCoreService;
import com.kamco.cd.training.postgres.core.HyperParamCoreService;
import com.kamco.cd.training.postgres.core.ModelMngCoreService;
import com.kamco.cd.training.postgres.core.SystemMetricsCoreService;
import com.kamco.cd.training.postgres.entity.ModelTrainMasterEntity;
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -21,19 +20,9 @@ import org.springframework.transaction.annotation.Transactional;
public class ModelTrainService {
private final ModelMngCoreService modelMngCoreService;
private final HyperParamCoreService hyperParamCoreService;
private final DatasetCoreService datasetCoreService;
private final SystemMetricsCoreService systemMetricsCoreService;
/**
* 학습 모델 목록 조회
*
* @return 학습 모델 목록
*/
public List<ModelMngDto.TrainListRes> getTrainModelList() {
return modelMngCoreService.findAllTrainModels();
}
/**
* 학습 설정 통합 조회
*
@@ -99,7 +88,7 @@ public class ModelTrainService {
}
// 5. 학습 마스터 생성
ModelTrainMasterEntity entity = modelMngCoreService.createTrainMaster(trainReq);
ModelMasterEntity entity = modelMngCoreService.createTrainMaster(trainReq);
// 5. 데이터셋 매핑 생성
modelMngCoreService.createDatasetMappings(entity.getId(), trainReq.getDatasetIds());
@@ -178,39 +167,28 @@ public class ModelTrainService {
}
}
/**
* 학습 모델 삭제
*
* @param uuid 모델 UUID
*/
@Transactional
public void deleteTrainModel(String uuid) {
modelMngCoreService.deleteByUuid(uuid);
log.info("학습 모델 삭제 완료: uuid={}", uuid);
}
// ==================== Resume Training (학습 재시작) ====================
/**
* 학습 재시작 정보 조회
*
* @param uuid 모델 UUID
* @return 재시작 정보
*/
public ModelMngDto.ResumeInfo getResumeInfo(String uuid) {
ModelTrainMasterEntity entity = modelMngCoreService.findByUuid(uuid);
return ModelMngDto.ResumeInfo.builder()
.canResume(entity.getCanResume() != null && entity.getCanResume())
.lastEpoch(entity.getLastCheckpointEpoch())
.totalEpoch(entity.getEpochCnt())
.checkpointPath(entity.getCheckpointPath())
// .failedAt(
// entity.getStopDttm() != null
// ? entity.getStopDttm().atZone(java.time.ZoneId.systemDefault())
// : null)
.build();
}
//
// /**
// * 학습 재시작 정보 조회
// *
// * @param uuid 모델 UUID
// * @return 재시작 정보
// */
// public ModelMngDto.ResumeInfo getResumeInfo(String uuid) {
// ModelTrainMasterEntity entity = modelMngCoreService.findByUuid(uuid);
//
// return ModelMngDto.ResumeInfo.builder()
// .canResume(entity.getCanResume() != null && entity.getCanResume())
// .lastEpoch(entity.getLastCheckpointEpoch())
// .totalEpoch(entity.getEpochCnt())
// .checkpointPath(entity.getCheckpointPath())
// // .failedAt(
// // entity.getStopDttm() != null
// // ? entity.getStopDttm().atZone(java.time.ZoneId.systemDefault())
// // : null)
// .build();
// }
/**
* 학습 재시작
@@ -222,41 +200,42 @@ public class ModelTrainService {
@Transactional
public ModelMngDto.ResumeResponse resumeTraining(
String uuid, ModelMngDto.ResumeRequest resumeReq) {
ModelTrainMasterEntity entity = modelMngCoreService.findByUuid(uuid);
// ModelTrainMasterEntity entity = modelMngCoreService.findByUuid(uuid);
//
// // 재시작 가능 여부 검증
// if (entity.getCanResume() == null || !entity.getCanResume()) {
// throw new IllegalStateException("학습 재시작이 불가능한 모델입니다: " + uuid);
// }
//
// if (entity.getLastCheckpointEpoch() == null) {
// throw new IllegalStateException("Checkpoint가 존재하지 않습니다: " + uuid);
// }
//
// // 상태 업데이트
// entity.setStatusCd("RUNNING");
// entity.setProgressRate(0);
//
// // 총 Epoch 수 변경 (선택사항)
// if (resumeReq.getNewTotalEpoch() != null) {
// entity.setEpochCnt(resumeReq.getNewTotalEpoch());
// }
//
// log.info(
// "학습 재시작: uuid={}, resumeFromEpoch={}, totalEpoch={}",
// uuid,
// resumeReq.getResumeFromEpoch(),
// entity.getEpochCnt());
//
// // TODO: 비동기 GPU 학습 재시작 프로세스 트리거 로직 추가
// // - Checkpoint 파일 로드
// // - 지정된 Epoch부터 학습 재개
// 재시작 가능 여부 검증
if (entity.getCanResume() == null || !entity.getCanResume()) {
throw new IllegalStateException("학습 재시작이 불가능한 모델입니다: " + uuid);
}
if (entity.getLastCheckpointEpoch() == null) {
throw new IllegalStateException("Checkpoint가 존재하지 않습니다: " + uuid);
}
// 상태 업데이트
entity.setStatusCd("RUNNING");
entity.setProgressRate(0);
// 총 Epoch 수 변경 (선택사항)
if (resumeReq.getNewTotalEpoch() != null) {
entity.setEpochCnt(resumeReq.getNewTotalEpoch());
}
log.info(
"학습 재시작: uuid={}, resumeFromEpoch={}, totalEpoch={}",
uuid,
resumeReq.getResumeFromEpoch(),
entity.getEpochCnt());
// TODO: 비동기 GPU 학습 재시작 프로세스 트리거 로직 추가
// - Checkpoint 파일 로드
// - 지정된 Epoch부터 학습 재개
return ModelMngDto.ResumeResponse.builder()
.uuid(uuid)
.status(entity.getStatusCd())
.resumedFromEpoch(resumeReq.getResumeFromEpoch())
.build();
return null;
// ModelMngDto.ResumeResponse.builder()
// .uuid(uuid)
// .status(entity.getStatusCd())
// .resumedFromEpoch(resumeReq.getResumeFromEpoch())
// .build();
}
// ==================== Best Epoch Setting (Best Epoch 설정) ====================
@@ -271,47 +250,49 @@ public class ModelTrainService {
@Transactional
public ModelMngDto.BestEpochResponse setBestEpoch(
String uuid, ModelMngDto.BestEpochRequest bestEpochReq) {
ModelTrainMasterEntity entity = modelMngCoreService.findByUuid(uuid);
// 1차 학습 완료 상태 검증
if (!"STEP1_COMPLETED".equals(entity.getStatusCd())
&& !"STEP1".equals(entity.getProcessStep())) {
log.warn(
"Best Epoch 설정 시도: 현재 상태={}, processStep={}",
entity.getStatusCd(),
entity.getProcessStep());
}
Integer previousBestEpoch = entity.getConfirmedBestEpoch();
// 사용자가 확정한 Best Epoch 설정
entity.setConfirmedBestEpoch(bestEpochReq.getBestEpoch());
// 2차 학습(Test) 단계로 상태 전이
entity.setProcessStep("STEP2");
entity.setStatusCd("STEP2_RUNNING");
entity.setProgressRate(0);
entity.setUpdatedDttm(java.time.ZonedDateTime.now());
log.info(
"Best Epoch 설정 및 2차 학습 시작: uuid={}, newBestEpoch={}, previousBestEpoch={}, reason={}, newStatus={}",
uuid,
bestEpochReq.getBestEpoch(),
previousBestEpoch,
bestEpochReq.getReason(),
entity.getStatusCd());
// ModelTrainMasterEntity entity = modelMngCoreService.findByUuid(uuid);
//
// // 1차 학습 완료 상태 검증
// if (!"STEP1_COMPLETED".equals(entity.getStatusCd())
// && !"STEP1".equals(entity.getProcessStep())) {
// log.warn(
// "Best Epoch 설정 시도: 현재 상태={}, processStep={}",
// entity.getStatusCd(),
// entity.getProcessStep());
// }
//
// Integer previousBestEpoch = entity.getConfirmedBestEpoch();
//
// // 사용자가 확정한 Best Epoch 설정
// entity.setConfirmedBestEpoch(bestEpochReq.getBestEpoch());
//
// // 2차 학습(Test) 단계로 상태 전이
// entity.setProcessStep("STEP2");
// entity.setStatusCd("STEP2_RUNNING");
// entity.setProgressRate(0);
// entity.setUpdatedDttm(java.time.ZonedDateTime.now());
//
// log.info(
// "Best Epoch 설정 및 2차 학습 시작: uuid={}, newBestEpoch={}, previousBestEpoch={}, reason={},
// newStatus={}",
// uuid,
// bestEpochReq.getBestEpoch(),
// previousBestEpoch,
// bestEpochReq.getReason(),
// entity.getStatusCd());
// TODO: 비동기 GPU 2차 학습(Test) 프로세스 트리거 로직 추가
// - Best Epoch 모델 로드
// - Test 데이터셋으로 성능 평가 실행
// - 완료 시 STEP2_COMPLETED 상태로 전환
return ModelMngDto.BestEpochResponse.builder()
.uuid(uuid)
.bestEpoch(entity.getBestEpoch()) // 자동 선택된 값
.confirmedBestEpoch(entity.getConfirmedBestEpoch()) // 사용자 확정
.previousBestEpoch(previousBestEpoch)
.build();
return null;
// ModelMngDto.BestEpochResponse.builder()
// .uuid(uuid)
// .bestEpoch(entity.getBestEpoch()) // 자동 선택된
// .confirmedBestEpoch(entity.getConfirmedBestEpoch()) // 사용자 확정 값
// .previousBestEpoch(previousBestEpoch)
// .build();
}
/**
@@ -321,33 +302,33 @@ public class ModelTrainService {
* @return Epoch별 성능 지표 목록
*/
public List<ModelMngDto.EpochMetric> getEpochMetrics(String uuid) {
ModelTrainMasterEntity entity = modelMngCoreService.findByUuid(uuid);
// ModelTrainMasterEntity entity = modelMngCoreService.findByUuid(uuid);
//
// // TODO: 실제 학습 로그 파일이나 DB에서 Epoch별 성능 지표 조회
// // 현재는 샘플 데이터 반환
// List<ModelMngDto.EpochMetric> metrics = new java.util.ArrayList<>();
//
// if (entity.getEpochCnt() != null && entity.getBestEpoch() != null) {
// // 샘플 데이터 생성 (실제로는 학습 로그 파일 파싱 또는 별도 테이블 조회)
// for (int i = 1; i <= Math.min(entity.getEpochCnt(), 10); i++) {
// int epoch = entity.getBestEpoch() - 5 + i;
// if (epoch <= 0 || epoch > entity.getEpochCnt()) {
// continue;
// }
//
// metrics.add(
// ModelMngDto.EpochMetric.builder()
// .epoch(epoch)
// .mIoU(0.80 + (Math.random() * 0.15)) // 샘플 데이터
// .mFscore(0.85 + (Math.random() * 0.10)) // 샘플 데이터
// .loss(0.3 - (Math.random() * 0.15)) // 샘플 데이터
// .isBest(entity.getBestEpoch() != null && epoch == entity.getBestEpoch())
// .build());
// }
// }
//
// log.info("Epoch별 성능 지표 조회: uuid={}, metricsCount={}", uuid, metrics.size());
// TODO: 실제 학습 로그 파일이나 DB에서 Epoch별 성능 지표 조회
// 현재는 샘플 데이터 반환
List<ModelMngDto.EpochMetric> metrics = new java.util.ArrayList<>();
if (entity.getEpochCnt() != null && entity.getBestEpoch() != null) {
// 샘플 데이터 생성 (실제로는 학습 로그 파일 파싱 또는 별도 테이블 조회)
for (int i = 1; i <= Math.min(entity.getEpochCnt(), 10); i++) {
int epoch = entity.getBestEpoch() - 5 + i;
if (epoch <= 0 || epoch > entity.getEpochCnt()) {
continue;
}
metrics.add(
ModelMngDto.EpochMetric.builder()
.epoch(epoch)
.mIoU(0.80 + (Math.random() * 0.15)) // 샘플 데이터
.mFscore(0.85 + (Math.random() * 0.10)) // 샘플 데이터
.loss(0.3 - (Math.random() * 0.15)) // 샘플 데이터
.isBest(entity.getBestEpoch() != null && epoch == entity.getBestEpoch())
.build());
}
}
log.info("Epoch별 성능 지표 조회: uuid={}, metricsCount={}", uuid, metrics.size());
return metrics;
return null; // metrics;
}
}

View File

@@ -3,10 +3,11 @@ package com.kamco.cd.training.postgres.core;
import com.kamco.cd.training.common.exception.BadRequestException;
import com.kamco.cd.training.common.exception.CustomApiException;
import com.kamco.cd.training.common.exception.NotFoundException;
import com.kamco.cd.training.common.utils.UserUtil;
import com.kamco.cd.training.model.dto.ModelMngDto;
import com.kamco.cd.training.model.dto.ModelMngDto.Basic;
import com.kamco.cd.training.postgres.entity.ModelDatasetMappEntity;
import com.kamco.cd.training.postgres.entity.ModelTrainMasterEntity;
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
import com.kamco.cd.training.postgres.repository.model.ModelDatasetMappRepository;
import com.kamco.cd.training.postgres.repository.model.ModelMngRepository;
import java.time.ZonedDateTime;
@@ -22,6 +23,7 @@ import org.springframework.stereotype.Service;
public class ModelMngCoreService {
private final ModelMngRepository modelMngRepository;
private final ModelDatasetMappRepository modelDatasetMappRepository;
private final UserUtil userUtil;
/**
* 모델 목록 조회
@@ -30,16 +32,23 @@ public class ModelMngCoreService {
* @return 페이징 처리된 모델 목록
*/
public Page<Basic> findByModelList(ModelMngDto.SearchReq searchReq) {
Page<ModelTrainMasterEntity> entityPage = modelMngRepository.findByModels(searchReq);
return entityPage.map(ModelTrainMasterEntity::toDto);
Page<ModelMasterEntity> entityPage = modelMngRepository.findByModels(searchReq);
return entityPage.map(ModelMasterEntity::toDto);
}
/**
* 학습모델 삭제
*
* @param uuid
*/
public void deleteModel(UUID uuid) {
ModelTrainMasterEntity entity =
ModelMasterEntity entity =
modelMngRepository
.findByUuid(uuid)
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
// entity.setDelYn();
entity.setDelYn(true);
entity.setUpdatedDttm(ZonedDateTime.now());
entity.setUpdatedUid(userUtil.getId());
}
/**
@@ -49,7 +58,7 @@ public class ModelMngCoreService {
* @return 모델 상세 정보
*/
public ModelMngDto.Detail getModelDetail(Long modelUid) {
ModelTrainMasterEntity entity =
ModelMasterEntity entity =
modelMngRepository
.findById(modelUid)
.orElseThrow(() -> new NotFoundException("모델을 찾을 수 없습니다. ID: " + modelUid));
@@ -58,68 +67,27 @@ public class ModelMngCoreService {
throw new NotFoundException("삭제된 모델입니다. ID: " + modelUid);
}
return ModelMngDto.Detail.builder()
.uuid(entity.getUuid().toString())
.modelVer(entity.getModelVer())
.epochVer(entity.getEpochVer())
.processStep(entity.getProcessStep())
.trainStartDttm(entity.getTrainStartDttm())
.epochCnt(entity.getEpochCnt())
.datasetRatio(entity.getDatasetRatio())
.bestEpoch(entity.getBestEpoch())
.confirmedBestEpoch(entity.getConfirmedBestEpoch())
.step1EndDttm(entity.getStep1EndDttm())
.step1Duration(entity.getStep1Duration())
.step2EndDttm(entity.getStep2EndDttm())
.step2Duration(entity.getStep2Duration())
.progressRate(entity.getProgressRate())
.createdDttm(entity.getCreatedDttm())
.updatedDttm(entity.getUpdatedDttm())
.modelPath(entity.getModelPath())
.errorMsg(entity.getErrorMsg())
.build();
}
/**
* 모델 상세 조회 (UUID 기반)
*
* @param uuid 모델 UUID
* @return 모델 상세 정보
*/
public ModelMngDto.Detail getModelDetailByUuid(String uuid) {
ModelTrainMasterEntity entity = findByUuid(uuid);
return getModelDetail(entity.getId());
}
/**
* 학습 모델 전체 목록 조회 (삭제되지 않은 것만)
*
* @return 학습 모델 목록
*/
public List<ModelMngDto.TrainListRes> findAllTrainModels() {
List<ModelTrainMasterEntity> entities =
modelMngRepository.findByDelYnOrderByCreatedDttmDesc(false);
return entities.stream()
.map(
entity ->
ModelMngDto.TrainListRes.builder()
.uuid(entity.getUuid().toString())
.modelVer(entity.getModelVer())
.processStep(entity.getProcessStep())
.trainStartDttm(entity.getTrainStartDttm())
.progressRate(entity.getProgressRate())
.epochCnt(entity.getEpochCnt())
.step1EndDttm(entity.getStep1EndDttm())
.step1Duration(entity.getStep1Duration())
.step2EndDttm(entity.getStep2EndDttm())
.step2Duration(entity.getStep2Duration())
.createdDttm(entity.getCreatedDttm())
.errorMsg(entity.getErrorMsg())
.canResume(entity.getCanResume())
.lastCheckpointEpoch(entity.getLastCheckpointEpoch())
.build())
.toList();
return null;
// ModelMngDto.Detail.builder()
// .uuid(entity.getUuid().toString())
// .modelVer(entity.getModelVer())
// .epochVer(entity.getEpochVer())
// .processStep(entity.getProcessStep())
// .trainStartDttm(entity.getTrainStartDttm())
// .epochCnt(entity.getEpochCnt())
// .datasetRatio(entity.getDatasetRatio())
// .bestEpoch(entity.getBestEpoch())
// .confirmedBestEpoch(entity.getConfirmedBestEpoch())
// .step1EndDttm(entity.getStep1EndDttm())
// .step1Duration(entity.getStep1Duration())
// .step2EndDttm(entity.getStep2EndDttm())
// .step2Duration(entity.getStep2Duration())
// .progressRate(entity.getProgressRate())
// .createdDttm(entity.getCreatedDttm())
// .updatedDttm(entity.getUpdatedDttm())
// .modelPath(entity.getModelPath())
// .errorMsg(entity.getErrorMsg())
// .build();
}
/**
@@ -140,19 +108,19 @@ public class ModelMngCoreService {
* @param trainReq 학습 시작 요청
* @return 생성된 모델 Entity
*/
public ModelTrainMasterEntity createTrainMaster(ModelMngDto.TrainStartReq trainReq) {
ModelTrainMasterEntity entity = new ModelTrainMasterEntity();
entity.setModelVer(trainReq.getHyperVer());
entity.setEpochVer(String.valueOf(trainReq.getEpoch()));
entity.setProcessStep("STEP1");
entity.setTrainStartDttm(ZonedDateTime.now());
entity.setEpochCnt(trainReq.getEpoch());
entity.setDatasetRatio(trainReq.getDatasetRatio());
entity.setDelYn(false);
entity.setCreatedDttm(ZonedDateTime.now());
entity.setProgressRate(0);
public ModelMasterEntity createTrainMaster(ModelMngDto.TrainStartReq trainReq) {
// ModelMasterEntity entity = new ModelMasterEntity();
// entity.setModelVer(trainReq.getHyperVer());
// entity.setEpochVer(String.valueOf(trainReq.getEpoch()));
// entity.setProcessStep("STEP1");
// entity.setTrainStartDttm(ZonedDateTime.now());
// entity.setEpochCnt(trainReq.getEpoch());
// entity.setDatasetRatio(trainReq.getDatasetRatio());
// entity.setDelYn(false);
// entity.setCreatedDttm(ZonedDateTime.now());
// entity.setProgressRate(0);
return modelMngRepository.save(entity);
return null; // modelMngRepository.save(entity);
}
/**
@@ -177,7 +145,7 @@ public class ModelMngCoreService {
* @param uuid UUID
* @return 모델 Entity
*/
public ModelTrainMasterEntity findByUuid(String uuid) {
public ModelMasterEntity findByUuid(String uuid) {
try {
java.util.UUID uuidObj = java.util.UUID.fromString(uuid);
return modelMngRepository
@@ -187,22 +155,4 @@ public class ModelMngCoreService {
throw new BadRequestException("잘못된 UUID 형식입니다: " + uuid);
}
}
/**
* 모델 삭제 (논리 삭제)
*
* @param uuid UUID
*/
public void deleteByUuid(String uuid) {
ModelTrainMasterEntity entity = findByUuid(uuid);
// 진행 중인 모델은 삭제 불가
// if ("RUNNING".equals(entity.getStatusCd())) {
// throw new BadRequestException("진행 중인 모델은 삭제할 수 없습니다.");
// }
entity.setDelYn(true);
entity.setUpdatedDttm(ZonedDateTime.now());
modelMngRepository.save(entity);
}
}

View File

@@ -0,0 +1,52 @@
package com.kamco.cd.training.postgres.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import java.time.OffsetDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@Entity
@Table(name = "tb_model_config")
public class ModelConfigEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "config_id", nullable = false)
private Integer id;
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "model_id", nullable = false)
private ModelMasterEntity model;
@Column(name = "epoch_count")
private Integer epochCount;
@Column(name = "train_percent")
private Float trainPercent;
@Column(name = "validation_percent")
private Float validationPercent;
@Column(name = "test_percent")
private Float testPercent;
@ColumnDefault("now()")
@Column(name = "created_dttm")
private OffsetDateTime createdDttm;
@Column(name = "created_uid")
private Long createdUid;
}

View File

@@ -0,0 +1,47 @@
package com.kamco.cd.training.postgres.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import java.time.OffsetDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@Entity
@Table(name = "tb_model_dataset")
public class ModelDatasetEntity {
@Id
@Column(name = "id", nullable = false)
private Long id;
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "model_id", nullable = false)
private ModelMasterEntity model;
@NotNull
@Column(name = "data_id", nullable = false)
private Long dataId;
@Column(name = "building_cnt")
private Long buildingCnt;
@Column(name = "container_cnt")
private Long containerCnt;
@ColumnDefault("now()")
@Column(name = "created_dttm")
private OffsetDateTime createdDttm;
@Column(name = "created_uid")
private Long createdUid;
}

View File

@@ -0,0 +1,74 @@
package com.kamco.cd.training.postgres.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.OffsetDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@Entity
@Table(name = "tb_model_history")
public class ModelHistoryEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "hst_id", nullable = false)
private Integer id;
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "model_id", nullable = false)
private ModelMasterEntity model;
@Column(name = "model_no")
private Short modelNo;
@Size(max = 50)
@Column(name = "model_ver", length = 50)
private String modelVer;
@Column(name = "model_step")
private Short modelStep;
@Column(name = "step1_strt_dttm")
private OffsetDateTime step1StrtDttm;
@Column(name = "step1_end_dttm")
private OffsetDateTime step1EndDttm;
@Size(max = 20)
@Column(name = "step1_state", length = 20)
private String step1State;
@Column(name = "step2_strt_dttm")
private OffsetDateTime step2StrtDttm;
@Column(name = "step2_end_dttm")
private OffsetDateTime step2EndDttm;
@Size(max = 20)
@Column(name = "step2_state", length = 20)
private String step2State;
@Column(name = "error_msg", length = Integer.MAX_VALUE)
private String errorMsg;
@ColumnDefault("now()")
@Column(name = "created_dttm")
private OffsetDateTime createdDttm;
@Column(name = "created_uid")
private Long createdUid;
}

View File

@@ -5,8 +5,6 @@ import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
@@ -313,9 +311,6 @@ public class ModelHyperParamEntity {
@Column(name = "m3_use_cnt")
private Long m3UseCnt = 0L;
@OneToMany(mappedBy = "hyperParams", fetch = FetchType.LAZY)
private Set<ModelTrainMasterEntity> trainMasters = new LinkedHashSet<>();
public HyperParamDto.Basic toDto() {
return new HyperParamDto.Basic(
this.uuid,

View File

@@ -0,0 +1,108 @@
package com.kamco.cd.training.postgres.entity;
import com.kamco.cd.training.model.dto.ModelMngDto;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@Entity
@Table(name = "tb_model_master")
public class ModelMasterEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "model_id", nullable = false)
private Long id;
@NotNull
@Column(name = "hyper_param_id", nullable = false)
private Long hyperParamId;
@Size(max = 10)
@Column(name = "model_no", length = 10)
private String modelNo;
@Size(max = 50)
@Column(name = "model_ver", length = 50)
private String modelVer;
@Column(name = "model_step")
private Short modelStep;
@Size(max = 20)
@Column(name = "status_cd", length = 20)
private String statusCd;
@Column(name = "strt_dttm")
private ZonedDateTime strtDttm;
@Column(name = "step1_strt_dttm")
private ZonedDateTime step1StrtDttm;
@Column(name = "step1_end_dttm")
private ZonedDateTime step1EndDttm;
@Size(max = 20)
@Column(name = "step1_state", length = 20)
private String step1State;
@Column(name = "step2_strt_dttm")
private ZonedDateTime step2StrtDttm;
@Column(name = "step2_end_dttm")
private ZonedDateTime step2EndDttm;
@Size(max = 20)
@Column(name = "step2_state", length = 20)
private String step2State;
@Column(name = "del_yn")
private Boolean delYn;
@ColumnDefault("now()")
@Column(name = "created_dttm")
private ZonedDateTime createdDttm = ZonedDateTime.now();
@Column(name = "created_uid")
private Long createdUid;
@Column(name = "updated_dttm")
private ZonedDateTime updatedDttm;
@Column(name = "updated_uid")
private Long updatedUid;
@Column(name = "uuid")
private UUID uuid = UUID.randomUUID();
@Column(name = "train_type")
private String trainType;
public ModelMngDto.Basic toDto() {
return new ModelMngDto.Basic(
this.id,
this.uuid,
this.modelVer,
this.strtDttm,
this.step1StrtDttm,
this.step1EndDttm,
this.step2StrtDttm,
this.step2EndDttm,
this.step1State,
this.step2State,
this.statusCd,
this.trainType);
}
}

View File

@@ -0,0 +1,75 @@
package com.kamco.cd.training.postgres.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.OffsetDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@Entity
@Table(name = "tb_model_matrics_test")
public class ModelMatricsTestEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "mtrc_id", nullable = false)
private Long id;
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "model_id", nullable = false)
private ModelMasterEntity model;
@Size(max = 50)
@Column(name = "model", length = 50)
private String model1;
@Column(name = "tp")
private Long tp;
@Column(name = "fp")
private Long fp;
@Column(name = "fn")
private Long fn;
@Column(name = "tn")
private Long tn;
@Column(name = "precisions")
private Float precisions;
@Column(name = "recall")
private Float recall;
@Column(name = "f1_score")
private Float f1Score;
@Column(name = "accuracy")
private Float accuracy;
@Column(name = "iou")
private Float iou;
@Column(name = "processed_images")
private Long processedImages;
@ColumnDefault("now()")
@Column(name = "created_dttm")
private OffsetDateTime createdDttm;
@Column(name = "created_uid")
private Long createdUid;
}

View File

@@ -0,0 +1,55 @@
package com.kamco.cd.training.postgres.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import java.time.OffsetDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@Entity
@Table(name = "tb_model_matrics_train")
public class ModelMatricsTrainEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "mtrc_id", nullable = false)
private Long id;
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "model_id", nullable = false)
private ModelMasterEntity model;
@Column(name = "epoch")
private Integer epoch;
@Column(name = "iteration")
private Long iteration;
@Column(name = "loss")
private Double loss;
@Column(name = "lr")
private Double lr;
@Column(name = "duration_time")
private Float durationTime;
@ColumnDefault("now()")
@Column(name = "created_dttm")
private OffsetDateTime createdDttm;
@Column(name = "created_uid")
private Long createdUid;
}

View File

@@ -0,0 +1,79 @@
package com.kamco.cd.training.postgres.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import java.time.OffsetDateTime;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@Entity
@Table(name = "tb_model_matrics_validation")
public class ModelMatricsValidationEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "mtrc_id", nullable = false)
private Long id;
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "model_id", nullable = false)
private ModelMasterEntity model;
@Column(name = "epoch")
private Integer epoch;
@Column(name = "a_acc")
private Float aAcc;
@Column(name = "m_fscore")
private Float mFscore;
@Column(name = "m_precision")
private Float mPrecision;
@Column(name = "m_recall")
private Float mRecall;
@Column(name = "m_iou")
private Float mIou;
@Column(name = "m_acc")
private Float mAcc;
@Column(name = "changed_fscore")
private Float changedFscore;
@Column(name = "changed_precision")
private Float changedPrecision;
@Column(name = "changed_recall")
private Float changedRecall;
@Column(name = "unchanged_fscore")
private Float unchangedFscore;
@Column(name = "unchanged_precision")
private Float unchangedPrecision;
@Column(name = "unchanged_recall")
private Float unchangedRecall;
@ColumnDefault("now()")
@Column(name = "created_dttm")
private OffsetDateTime createdDttm;
@Column(name = "created_uid")
private Long createdUid;
}

View File

@@ -1,192 +0,0 @@
package com.kamco.cd.training.postgres.entity;
import com.kamco.cd.training.model.dto.ModelMngDto;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.annotations.UuidGenerator;
@Getter
@Setter
@Entity
@Table(name = "tb_model_train_master")
public class ModelTrainMasterEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "model_uid", nullable = false)
private Long id;
@Size(max = 50)
@NotNull
@Column(name = "model_ver", nullable = false, length = 50)
private String modelVer;
@Size(max = 50)
@Column(name = "hyper_ver", length = 50)
private String hyperVer;
/** tb_model_train_master.hyper_param_id -> tb_model_hyper_params.hyper_param_id */
@NotNull
@Column(name = "hyper_param_id", nullable = false)
private Long hyperParamId;
/** - hyperParamId 컬럼으로 저장/수정하고 - 객체로 조회할 때만 hyperParams 사용 */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(
name = "hyper_param_id",
referencedColumnName = "hyper_param_id",
insertable = false,
updatable = false)
private ModelHyperParamEntity hyperParams;
@Size(max = 50)
@Column(name = "epoch_ver", length = 50)
private String epochVer;
@Size(max = 50)
@Column(name = "process_step", length = 50)
private String processStep;
@Column(name = "train_start_dttm")
private ZonedDateTime trainStartDttm;
@Column(name = "epoch_cnt")
private Integer epochCnt;
@Size(max = 50)
@Column(name = "dataset_ratio", length = 50)
private String datasetRatio;
@Column(name = "best_epoch")
private Integer bestEpoch;
@Column(name = "step1_end_dttm")
private ZonedDateTime step1EndDttm;
@Column(name = "step1_duration")
private ZonedDateTime step1Duration;
@Column(name = "step2_end_dttm")
private ZonedDateTime step2EndDttm;
@Column(name = "step2_duration")
private ZonedDateTime step2Duration;
@NotNull
@ColumnDefault("false")
@Column(name = "del_yn", nullable = false)
private Boolean delYn = false;
@Column(name = "created_uid")
private Long createdUid;
@Column(name = "updated_uid")
private Long updatedUid;
@ColumnDefault("now()")
@Column(name = "created_dttm")
private ZonedDateTime createdDttm;
@Column(name = "updated_dttm")
private ZonedDateTime updatedDttm;
@ColumnDefault("0")
@Column(name = "progress_rate")
private Integer progressRate;
@Column(name = "stop_dttm")
private ZonedDateTime stopDttm;
@Column(name = "confirmed_best_epoch")
private Integer confirmedBestEpoch;
@Size(max = 255)
@Column(name = "model_path")
private String modelPath;
@Column(name = "error_msg")
private String errorMsg;
@Column(name = "step2_start_dttm")
private ZonedDateTime step2StartDttm;
@Size(max = 1000)
@Column(name = "train_log_path", length = 1000)
private String trainLogPath;
@Column(name = "memo")
private String memo;
/** 기존 자기참조(base_model_uid)는 유지 */
@ManyToOne(fetch = FetchType.LAZY)
@OnDelete(action = OnDeleteAction.SET_NULL)
@JoinColumn(name = "base_model_uid")
private ModelTrainMasterEntity baseModel;
@Size(max = 1000)
@Column(name = "pretrained_model_path", length = 1000)
private String pretrainedModelPath;
@Column(name = "last_checkpoint_epoch")
private Integer lastCheckpointEpoch;
@Size(max = 500)
@Column(name = "checkpoint_path", length = 500)
private String checkpointPath;
@Column(name = "can_resume")
private Boolean canResume;
@NotNull
@UuidGenerator
@Column(name = "uuid", nullable = false, updatable = false)
private UUID uuid = UUID.randomUUID();
@Size(max = 10)
@Column(name = "step1_status", length = 10)
private String step1Status;
@Size(max = 10)
@Column(name = "step2_status", length = 10)
private String step2Status;
@Size(max = 10)
@Column(name = "transfer_status", length = 10)
private String transferStatus;
@Size(max = 10)
@Column(name = "status_cd", length = 10)
private String statusCd;
public ModelMngDto.Basic toDto() {
return new ModelMngDto.Basic(
this.id,
this.uuid,
this.modelVer,
this.trainStartDttm,
this.step1EndDttm,
this.step1Duration,
this.step2EndDttm,
this.step2Duration,
this.step1Status,
this.step2Status,
this.transferStatus,
this.statusCd);
}
}

View File

@@ -1,17 +1,7 @@
package com.kamco.cd.training.postgres.repository.model;
import com.kamco.cd.training.postgres.entity.ModelTrainMasterEntity;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ModelMngRepository
extends JpaRepository<ModelTrainMasterEntity, Long>, ModelMngRepositoryCustom {
List<ModelTrainMasterEntity> findByDelYnOrderByCreatedDttmDesc(Boolean delYn);
Optional<ModelTrainMasterEntity> findFirstByStatusCdAndDelYn(String statusCd, Boolean delYn);
Optional<ModelTrainMasterEntity> findByUuid(UUID uuid);
}
extends JpaRepository<ModelMasterEntity, Long>, ModelMngRepositoryCustom {}

View File

@@ -1,7 +1,7 @@
package com.kamco.cd.training.postgres.repository.model;
import com.kamco.cd.training.model.dto.ModelMngDto;
import com.kamco.cd.training.postgres.entity.ModelTrainMasterEntity;
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
import java.util.Optional;
import java.util.UUID;
import org.springframework.data.domain.Page;
@@ -14,7 +14,9 @@ public interface ModelMngRepositoryCustom {
* @param searchReq
* @return
*/
Page<ModelTrainMasterEntity> findByModels(ModelMngDto.SearchReq searchReq);
Page<ModelMasterEntity> findByModels(ModelMngDto.SearchReq searchReq);
Optional<ModelTrainMasterEntity> findByUuid(UUID uuid);
Optional<ModelMasterEntity> findByUuid(UUID uuid);
Optional<ModelMasterEntity> findFirstByStatusCdAndDelYn(String statusCd, Boolean delYn);
}

View File

@@ -1,9 +1,9 @@
package com.kamco.cd.training.postgres.repository.model;
import static com.kamco.cd.training.postgres.entity.QModelTrainMasterEntity.modelTrainMasterEntity;
import static com.kamco.cd.training.postgres.entity.QModelMasterEntity.modelMasterEntity;
import com.kamco.cd.training.model.dto.ModelMngDto;
import com.kamco.cd.training.postgres.entity.ModelTrainMasterEntity;
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.jpa.impl.JPAQueryFactory;
import java.util.List;
@@ -28,28 +28,28 @@ public class ModelMngRepositoryImpl implements ModelMngRepositoryCustom {
* @return
*/
@Override
public Page<ModelTrainMasterEntity> findByModels(ModelMngDto.SearchReq req) {
public Page<ModelMasterEntity> findByModels(ModelMngDto.SearchReq req) {
Pageable pageable = req.toPageable();
BooleanBuilder builder = new BooleanBuilder();
if (req.getStatus() != null && !req.getStatus().isEmpty()) {
builder.and(modelTrainMasterEntity.statusCd.eq(req.getStatus()));
builder.and(modelMasterEntity.statusCd.eq(req.getStatus()));
}
List<ModelTrainMasterEntity> content =
List<ModelMasterEntity> content =
queryFactory
.selectFrom(modelTrainMasterEntity)
.selectFrom(modelMasterEntity)
.where(builder)
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.orderBy(modelTrainMasterEntity.createdDttm.desc())
.orderBy(modelMasterEntity.createdDttm.desc())
.fetch();
// Count 쿼리 별도 실행 (null safe handling)
Long total =
queryFactory
.select(modelTrainMasterEntity.count())
.from(modelTrainMasterEntity)
.select(modelMasterEntity.count())
.from(modelMasterEntity)
.where(builder)
.fetchOne();
@@ -65,12 +65,17 @@ public class ModelMngRepositoryImpl implements ModelMngRepositoryCustom {
* @return
*/
@Override
public Optional<ModelTrainMasterEntity> findByUuid(UUID uuid) {
public Optional<ModelMasterEntity> findByUuid(UUID uuid) {
return Optional.ofNullable(
queryFactory
.select(modelTrainMasterEntity)
.from(modelTrainMasterEntity)
.where(modelTrainMasterEntity.uuid.eq(uuid))
.select(modelMasterEntity)
.from(modelMasterEntity)
.where(modelMasterEntity.uuid.eq(uuid))
.fetchOne());
}
@Override
public Optional<ModelMasterEntity> findFirstByStatusCdAndDelYn(String statusCd, Boolean delYn) {
return Optional.empty();
}
}