|
|
|
@ -20,6 +20,8 @@ import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.net.URLDecoder;
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
@ -36,12 +38,6 @@ public class PipelineUploadController {
|
|
|
|
|
|
|
|
|
|
|
|
private final MinioAttachmentService minioAttachmentService;
|
|
|
|
private final MinioAttachmentService minioAttachmentService;
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "파이프라인 생성 및 MinIO업로드", description = "Kubeflow에 파이프라인 파일(Multipart)을 업로드하고 MinIO에 저장")
|
|
|
|
|
|
|
|
@ApiResponses({
|
|
|
|
|
|
|
|
@ApiResponse(responseCode = "200", description = "파이프라인 업로드 및 MinIO 저장 성공"),
|
|
|
|
|
|
|
|
@ApiResponse(responseCode = "400", description = "잘못된 요청"),
|
|
|
|
|
|
|
|
@ApiResponse(responseCode = "500", description = "서버 내부 오류")
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
|
public ResponseEntity<Map<String, Object>> uploadPipeline(
|
|
|
|
public ResponseEntity<Map<String, Object>> uploadPipeline(
|
|
|
|
@RequestParam("uploadfile") MultipartFile file,
|
|
|
|
@RequestParam("uploadfile") MultipartFile file,
|
|
|
|
@ -53,14 +49,20 @@ public class PipelineUploadController {
|
|
|
|
@RequestParam("projectId") Long projectId
|
|
|
|
@RequestParam("projectId") Long projectId
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 1. Kubeflow 파이프라인 업로드
|
|
|
|
// description 한글 디코딩
|
|
|
|
Map<String, Object> result = pipelineUploadService.uploadPipeline(file, name, displayName, description, namespace);
|
|
|
|
String decodedDescription = description != null
|
|
|
|
|
|
|
|
? URLDecoder.decode(description, StandardCharsets.UTF_8)
|
|
|
|
|
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1. Kubeflow 업로드
|
|
|
|
|
|
|
|
Map<String, Object> result = pipelineUploadService.uploadPipeline(
|
|
|
|
|
|
|
|
file, name, displayName, decodedDescription, namespace);
|
|
|
|
|
|
|
|
|
|
|
|
WorkflowEntity workflow = WorkflowEntity.builder()
|
|
|
|
WorkflowEntity workflow = WorkflowEntity.builder()
|
|
|
|
.pipelineId((String) result.get("pipeline_id"))
|
|
|
|
.pipelineId((String) result.get("pipeline_id"))
|
|
|
|
.displayName((String) result.get("display_name"))
|
|
|
|
.displayName((String) result.get("display_name"))
|
|
|
|
.name((String) result.get("name"))
|
|
|
|
.name((String) result.get("name"))
|
|
|
|
.description((String) result.get("description"))
|
|
|
|
.description(decodedDescription) // 여기 디코딩 적용
|
|
|
|
.namespace((String) result.get("namespace"))
|
|
|
|
.namespace((String) result.get("namespace"))
|
|
|
|
.regUserId(regUserId)
|
|
|
|
.regUserId(regUserId)
|
|
|
|
.projectId(projectId)
|
|
|
|
.projectId(projectId)
|
|
|
|
@ -73,19 +75,19 @@ public class PipelineUploadController {
|
|
|
|
// 2. MinIO 업로드
|
|
|
|
// 2. MinIO 업로드
|
|
|
|
MinioAttachmentEntity attachment = minioAttachmentService.uploadFile(
|
|
|
|
MinioAttachmentEntity attachment = minioAttachmentService.uploadFile(
|
|
|
|
file,
|
|
|
|
file,
|
|
|
|
"workflows/" + projectId, // 저장 경로 예시
|
|
|
|
"workflows/" + projectId,
|
|
|
|
workflow.getId(), // refId : 방금 저장한 워크플로우 PK
|
|
|
|
workflow.getId(),
|
|
|
|
"workflows", // refType
|
|
|
|
"workflows",
|
|
|
|
displayName, // title
|
|
|
|
displayName,
|
|
|
|
description, // description
|
|
|
|
decodedDescription, // 디코딩 적용
|
|
|
|
1, // version
|
|
|
|
1,
|
|
|
|
regUserId,
|
|
|
|
regUserId,
|
|
|
|
projectId
|
|
|
|
projectId
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
String minioUrl = minioAttachmentService.getFileUrl(attachment.getStoragePath());
|
|
|
|
String minioUrl = minioAttachmentService.getFileUrl(attachment.getStoragePath());
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 최종 응답 구성
|
|
|
|
// 3. 최종 응답
|
|
|
|
Map<String, Object> response = new HashMap<>();
|
|
|
|
Map<String, Object> response = new HashMap<>();
|
|
|
|
response.put("pipeline", result);
|
|
|
|
response.put("pipeline", result);
|
|
|
|
response.put("workflow", workflow);
|
|
|
|
response.put("workflow", workflow);
|
|
|
|
@ -106,6 +108,7 @@ public class PipelineUploadController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/runs")
|
|
|
|
@PostMapping("/runs")
|
|
|
|
@Operation(
|
|
|
|
@Operation(
|
|
|
|
summary = "Kubeflow Run 생성",
|
|
|
|
summary = "Kubeflow Run 생성",
|
|
|
|
|