트랜젝션처리 임시폴더 uid업데이트 #91
@@ -13,6 +13,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
|||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -204,13 +206,12 @@ public class TrainApiController {
|
|||||||
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
|
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
|
||||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||||
})
|
})
|
||||||
@PostMapping("/counts/{uuid}")
|
@GetMapping(path = "/counts/{uuid}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public ApiResponseDto<Void> getCount(
|
public ApiResponseDto<String> getCount(
|
||||||
@Parameter(description = "uuid", example = "e22181eb-2ac4-4100-9941-d06efce25c49")
|
@Parameter(description = "uuid", example = "e22181eb-2ac4-4100-9941-d06efce25c49")
|
||||||
@PathVariable
|
@PathVariable
|
||||||
UUID uuid) {
|
UUID uuid) {
|
||||||
Long modelId = trainJobService.getModelIdByUuid(uuid);
|
Long modelId = trainJobService.getModelIdByUuid(uuid);
|
||||||
dataSetCountersService.getCount(modelId);
|
return ApiResponseDto.ok(dataSetCountersService.getCount(modelId));
|
||||||
return ApiResponseDto.ok(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,26 +25,32 @@ public class DataSetCountersService {
|
|||||||
@Value("${train.docker.basePath}")
|
@Value("${train.docker.basePath}")
|
||||||
private String trainBaseDir;
|
private String trainBaseDir;
|
||||||
|
|
||||||
public void getCount(Long modelId) {
|
public String getCount(Long modelId) {
|
||||||
ModelTrainMngDto.Basic basic = modelTrainMngCoreService.findModelById(modelId);
|
ModelTrainMngDto.Basic basic = modelTrainMngCoreService.findModelById(modelId);
|
||||||
List<Long> datasetIds = modelTrainMngCoreService.findModelDatasetMapp(modelId);
|
List<Long> datasetIds = modelTrainMngCoreService.findModelDatasetMapp(modelId);
|
||||||
List<String> uids = modelTrainMngCoreService.findDatasetUid(datasetIds);
|
List<String> uids = modelTrainMngCoreService.findDatasetUid(datasetIds);
|
||||||
|
|
||||||
|
StringBuilder allLogs = new StringBuilder();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// request 폴더
|
// request 폴더
|
||||||
for (String uid : uids) {
|
for (String uid : uids) {
|
||||||
Path path = Path.of(requestDir, uid);
|
Path path = Path.of(requestDir, uid);
|
||||||
DatasetCounters counters = countTmpAfterBuild(path);
|
DatasetCounters counters = countTmpAfterBuild(path);
|
||||||
counters.prints(uid, "REQUEST");
|
allLogs.append(counters.prints(uid, "REQUEST")).append(System.lineSeparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
// tmp
|
// tmp
|
||||||
Path tmpPath = Path.of(trainBaseDir, "tmp", basic.getRequestPath());
|
Path tmpPath = Path.of(trainBaseDir, "tmp", basic.getRequestPath());
|
||||||
DatasetCounters counters2 = countTmpAfterBuild(tmpPath);
|
DatasetCounters counters2 = countTmpAfterBuild(tmpPath);
|
||||||
counters2.prints(basic.getRequestPath(), "TMP");
|
allLogs
|
||||||
|
.append(counters2.prints(basic.getRequestPath(), "TMP"))
|
||||||
|
.append(System.lineSeparator());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return allLogs.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int countTif(Path dir) throws IOException {
|
private int countTif(Path dir) throws IOException {
|
||||||
@@ -114,7 +120,7 @@ public class DataSetCountersService {
|
|||||||
this.input2 = input2;
|
this.input2 = input2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prints(String uuid, String type) {
|
public String prints(String uuid, String type) {
|
||||||
int train = 0, test = 0, val = 0;
|
int train = 0, test = 0, val = 0;
|
||||||
int train2 = 0, test2 = 0, val2 = 0;
|
int train2 = 0, test2 = 0, val2 = 0;
|
||||||
|
|
||||||
@@ -138,6 +144,23 @@ public class DataSetCountersService {
|
|||||||
train + train2,
|
train + train2,
|
||||||
val + val2,
|
val + val2,
|
||||||
test + test2);
|
test + test2);
|
||||||
|
|
||||||
|
return String.format(
|
||||||
|
"======== UUID FOLDER COUNT %s : %s%n"
|
||||||
|
+ "input 1 = train : %s | val : %s | test : %s%n"
|
||||||
|
+ "input 2 = train : %s | val : %s | test : %s%n"
|
||||||
|
+ "*total* = train : %s | val : %s | test : %s",
|
||||||
|
type,
|
||||||
|
uuid,
|
||||||
|
train,
|
||||||
|
val,
|
||||||
|
test,
|
||||||
|
train2,
|
||||||
|
val2,
|
||||||
|
test2,
|
||||||
|
train + train2,
|
||||||
|
val + val2,
|
||||||
|
test + test2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,9 +223,9 @@ public class TrainJobService {
|
|||||||
UUID tmpUuid = UUID.randomUUID();
|
UUID tmpUuid = UUID.randomUUID();
|
||||||
String raw = tmpUuid.toString().toUpperCase().replace("-", "");
|
String raw = tmpUuid.toString().toUpperCase().replace("-", "");
|
||||||
|
|
||||||
|
// MODELID 가져오기
|
||||||
Long modelId = modelTrainMngCoreService.findModelIdByUuid(modelUuid);
|
Long modelId = modelTrainMngCoreService.findModelIdByUuid(modelUuid);
|
||||||
List<Long> datasetIds = modelTrainMngCoreService.findModelDatasetMapp(modelId);
|
List<Long> datasetIds = modelTrainMngCoreService.findModelDatasetMapp(modelId);
|
||||||
|
|
||||||
List<String> uids = modelTrainMngCoreService.findDatasetUid(datasetIds);
|
List<String> uids = modelTrainMngCoreService.findDatasetUid(datasetIds);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -233,6 +233,7 @@ public class TrainJobService {
|
|||||||
String pathUid = tmpDatasetService.buildTmpDatasetSymlink(raw, uids);
|
String pathUid = tmpDatasetService.buildTmpDatasetSymlink(raw, uids);
|
||||||
ModelTrainMngDto.UpdateReq updateReq = new ModelTrainMngDto.UpdateReq();
|
ModelTrainMngDto.UpdateReq updateReq = new ModelTrainMngDto.UpdateReq();
|
||||||
updateReq.setRequestPath(pathUid);
|
updateReq.setRequestPath(pathUid);
|
||||||
|
// 학습모델을 수정한다.
|
||||||
modelTrainMngCoreService.updateModelMaster(modelId, updateReq);
|
modelTrainMngCoreService.updateModelMaster(modelId, updateReq);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user