미사용 소스 정리
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.kamco.cd.training.postgres.core;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kamco.cd.training.common.enums.LearnDataRegister;
|
||||
import com.kamco.cd.training.common.enums.LearnDataType;
|
||||
@@ -10,15 +9,12 @@ import com.kamco.cd.training.dataset.dto.DatasetDto;
|
||||
import com.kamco.cd.training.dataset.dto.DatasetDto.SelectDataSet;
|
||||
import com.kamco.cd.training.dataset.dto.DatasetObjDto.Basic;
|
||||
import com.kamco.cd.training.dataset.dto.DatasetObjDto.SearchReq;
|
||||
import com.kamco.cd.training.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.training.postgres.entity.DatasetEntity;
|
||||
import com.kamco.cd.training.postgres.entity.DatasetObjEntity;
|
||||
import com.kamco.cd.training.postgres.repository.dataset.DatasetObjRepository;
|
||||
import com.kamco.cd.training.postgres.repository.dataset.DatasetRepository;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -187,101 +183,6 @@ public class DatasetCoreService
|
||||
summaryReq.getDatasetIds().size(), totalMapSheets, totalFileSize, averageMapSheets);
|
||||
}
|
||||
|
||||
/**
|
||||
* 활성 데이터셋 전체 조회 (학습 관리용)
|
||||
*
|
||||
* @return 데이터셋 정보 목록
|
||||
*/
|
||||
public List<ModelMngDto.DatasetInfo> findAllActiveDatasetsForTraining() {
|
||||
List<DatasetEntity> entities = datasetRepository.findByDeletedOrderByCreatedDttmDesc(false);
|
||||
|
||||
return entities.stream()
|
||||
.map(
|
||||
entity -> {
|
||||
// totalSize를 읽기 쉬운 형식으로 변환
|
||||
String totalSizeStr = formatFileSize(entity.getTotalSize());
|
||||
|
||||
// classCounts JSON 파싱
|
||||
Map<String, Integer> classCounts = entity.getClassCounts();
|
||||
|
||||
return ModelMngDto.DatasetInfo.builder()
|
||||
.id(entity.getId())
|
||||
.title(entity.getTitle())
|
||||
.totalItems(entity.getTotalItems())
|
||||
.totalSize(totalSizeStr)
|
||||
.classCounts(classCounts)
|
||||
.memo(entity.getMemo())
|
||||
.createdDttm(entity.getCreatedDttm())
|
||||
.build();
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON 문자열을 Map으로 파싱
|
||||
*
|
||||
* @param jsonStr JSON 문자열
|
||||
* @return 클래스별 카운트 맵
|
||||
*/
|
||||
private Map<String, Integer> parseClassCounts(String jsonStr) {
|
||||
if (jsonStr == null || jsonStr.trim().isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
try {
|
||||
return objectMapper.readValue(jsonStr, new TypeReference<Map<String, Integer>>() {});
|
||||
} catch (Exception e) {
|
||||
log.warn("클래스 통계 JSON 파싱 실패: {}", jsonStr, e);
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 데이터셋의 클래스 통계 계산 및 저장
|
||||
*
|
||||
* @param datasetId 데이터셋 ID
|
||||
* @param classCounts 클래스별 카운트
|
||||
*/
|
||||
public void updateClassCounts(Long datasetId, Map<String, Integer> classCounts) {
|
||||
DatasetEntity entity =
|
||||
datasetRepository
|
||||
.findById(datasetId)
|
||||
.orElseThrow(() -> new NotFoundException("데이터셋을 찾을 수 없습니다. ID: " + datasetId));
|
||||
|
||||
try {
|
||||
entity.setClassCounts(classCounts);
|
||||
datasetRepository.save(entity);
|
||||
log.info("데이터셋 클래스 통계 업데이트 완료: datasetId={}, classes={}", datasetId, classCounts.keySet());
|
||||
} catch (Exception e) {
|
||||
log.error("클래스 통계 JSON 변환 실패: datasetId={}", datasetId, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 크기를 읽기 쉬운 형식으로 변환
|
||||
*
|
||||
* @param size 바이트 단위 크기
|
||||
* @return 형식화된 문자열 (예: "1.5GB")
|
||||
*/
|
||||
private String formatFileSize(Long size) {
|
||||
if (size == null || size == 0) {
|
||||
return "0 GB";
|
||||
}
|
||||
|
||||
double gb = size / (1024.0 * 1024.0 * 1024.0);
|
||||
if (gb >= 1.0) {
|
||||
return String.format("%.2f GB", gb);
|
||||
}
|
||||
|
||||
double mb = size / (1024.0 * 1024.0);
|
||||
if (mb >= 1.0) {
|
||||
return String.format("%.2f MB", mb);
|
||||
}
|
||||
|
||||
double kb = size / 1024.0;
|
||||
return String.format("%.2f KB", kb);
|
||||
}
|
||||
|
||||
public Page<Basic> searchDatasetObjectList(SearchReq searchReq) {
|
||||
Page<DatasetObjEntity> entityPage = datasetObjRepository.searchDatasetObjectList(searchReq);
|
||||
return entityPage.map(DatasetObjEntity::toDto);
|
||||
|
||||
@@ -6,7 +6,6 @@ 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.ModelTrainMngDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto.Basic;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto.TrainingDataset;
|
||||
@@ -161,78 +160,6 @@ public class ModelTrainMngCoreService {
|
||||
return modelConfigRepository.save(entity).getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 모델 상세 조회
|
||||
*
|
||||
* @param modelUid 모델 UID
|
||||
* @return 모델 상세 정보
|
||||
*/
|
||||
public ModelMngDto.Detail getModelDetail(Long modelUid) {
|
||||
ModelMasterEntity entity =
|
||||
modelMngRepository
|
||||
.findById(modelUid)
|
||||
.orElseThrow(() -> new NotFoundException("모델을 찾을 수 없습니다. ID: " + modelUid));
|
||||
|
||||
if (Boolean.TRUE.equals(entity.getDelYn())) {
|
||||
throw new NotFoundException("삭제된 모델입니다. ID: " + modelUid);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 실행 중인 모델 확인
|
||||
*
|
||||
* @return 실행 중인 모델 UUID (없으면 null)
|
||||
*/
|
||||
public String findRunningModelUuid() {
|
||||
return modelMngRepository
|
||||
.findFirstByStatusCdAndDelYn("RUNNING", false)
|
||||
.map(entity -> entity.getUuid().toString())
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 학습 마스터 생성
|
||||
*
|
||||
* @param trainReq 학습 시작 요청
|
||||
* @return 생성된 모델 Entity
|
||||
*/
|
||||
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 null; // modelMngRepository.save(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 데이터셋 매핑 생성
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user