84 lines
3.4 KiB
Java
84 lines
3.4 KiB
Java
package com.kamco.cd.kamcoback.test;
|
|
|
|
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
|
import com.kamco.cd.kamcoback.scheduler.service.ShpPipelineService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.media.Content;
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.web.ErrorResponse;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
@Tag(name = "test shape api", description = "test shape api")
|
|
@RestController
|
|
@RequiredArgsConstructor
|
|
@RequestMapping("/api/test")
|
|
public class TestShapeApiController {
|
|
|
|
private final ShpPipelineService shpPipelineService;
|
|
|
|
@Value("${inference.jar-path}")
|
|
private String jarPath;
|
|
|
|
@Value("${file.dataset-dir}")
|
|
private String datasetDir;
|
|
|
|
@Operation(
|
|
summary = "shapefile 생성 테스트",
|
|
description = "지정된 inference ID와 batch ID 목록으로 shapefile을 생성합니다.")
|
|
@ApiResponses({
|
|
@ApiResponse(
|
|
responseCode = "200",
|
|
description = "shapefile 생성 요청 성공",
|
|
content = @Content(schema = @Schema(implementation = String.class))),
|
|
@ApiResponse(
|
|
responseCode = "400",
|
|
description = "잘못된 요청 데이터",
|
|
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
|
|
@ApiResponse(
|
|
responseCode = "500",
|
|
description = "서버 오류",
|
|
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
|
|
})
|
|
@GetMapping("/make-shapefile")
|
|
public ApiResponseDto<String> makeShapeFile(
|
|
@RequestParam String inferenceId, @RequestParam List<Long> batchIds) {
|
|
shpPipelineService.makeShapeFile(inferenceId, batchIds);
|
|
return ApiResponseDto.ok("Shapefile 생성이 시작되었습니다. inferenceId: " + inferenceId);
|
|
}
|
|
|
|
@Operation(
|
|
summary = "기존 run pipeline 테스트",
|
|
description = "지정된 inference ID와 batch ID 목록으로 shapefile을 생성합니다.")
|
|
@ApiResponses({
|
|
@ApiResponse(
|
|
responseCode = "200",
|
|
description = "shapefile 생성 요청 성공",
|
|
content = @Content(schema = @Schema(implementation = String.class))),
|
|
@ApiResponse(
|
|
responseCode = "400",
|
|
description = "잘못된 요청 데이터",
|
|
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
|
|
@ApiResponse(
|
|
responseCode = "500",
|
|
description = "서버 오류",
|
|
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
|
|
})
|
|
@GetMapping("/run-pipeline")
|
|
public ApiResponseDto<String> runPipeline(
|
|
@RequestParam String inferenceId, @RequestParam List<Long> batchIds) {
|
|
String batchIdStr = batchIds.stream().map(String::valueOf).collect(Collectors.joining(","));
|
|
shpPipelineService.runPipeline(jarPath, datasetDir, batchIdStr, inferenceId);
|
|
return ApiResponseDto.ok("runPipeline 생성이 시작되었습니다. inferenceId: " + inferenceId);
|
|
}
|
|
}
|