하이퍼파라미터 , 모델관리 수정
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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 {}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user