|
|
|
@ -1,7 +1,9 @@
|
|
|
|
package kr.re.etri.autoflow.controllers;
|
|
|
|
package kr.re.etri.autoflow.controllers;
|
|
|
|
|
|
|
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
|
|
|
import kr.re.etri.autoflow.entity.WorkflowEntity;
|
|
|
|
import kr.re.etri.autoflow.service.PipelineUploadService;
|
|
|
|
import kr.re.etri.autoflow.service.PipelineUploadService;
|
|
|
|
|
|
|
|
import kr.re.etri.autoflow.service.WorkFlowService;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
@ -11,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.client.HttpClientErrorException;
|
|
|
|
import org.springframework.web.client.HttpClientErrorException;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
@ -23,6 +26,7 @@ import java.util.Map;
|
|
|
|
public class PipelineUploadController {
|
|
|
|
public class PipelineUploadController {
|
|
|
|
|
|
|
|
|
|
|
|
private final PipelineUploadService pipelineUploadService;
|
|
|
|
private final PipelineUploadService pipelineUploadService;
|
|
|
|
|
|
|
|
private final WorkFlowService workFlowService;
|
|
|
|
|
|
|
|
|
|
|
|
@io.swagger.v3.oas.annotations.Operation(
|
|
|
|
@io.swagger.v3.oas.annotations.Operation(
|
|
|
|
summary = "파이프라인 업로드",
|
|
|
|
summary = "파이프라인 업로드",
|
|
|
|
@ -42,44 +46,47 @@ public class PipelineUploadController {
|
|
|
|
description = "서버 내부 오류"
|
|
|
|
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(
|
|
|
|
@io.swagger.v3.oas.annotations.Parameter(description = "업로드할 파이프라인 파일", required = true)
|
|
|
|
|
|
|
|
@RequestParam("uploadfile") MultipartFile file,
|
|
|
|
@RequestParam("uploadfile") MultipartFile file,
|
|
|
|
|
|
|
|
@RequestParam(value = "name", required = true) String name,
|
|
|
|
@io.swagger.v3.oas.annotations.Parameter(description = "파이프라인 이름", required = true)
|
|
|
|
@RequestParam(value = "display_name", required = true) String displayName,
|
|
|
|
@RequestParam(value = "name", required = false) String name,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@io.swagger.v3.oas.annotations.Parameter(description = "표시 이름", required = true)
|
|
|
|
|
|
|
|
@RequestParam(value = "display_name", required = false) String displayName,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@io.swagger.v3.oas.annotations.Parameter(description = "파이프라인 설명", required = false)
|
|
|
|
|
|
|
|
@RequestParam(value = "description", required = false) String description,
|
|
|
|
@RequestParam(value = "description", required = false) String description,
|
|
|
|
|
|
|
|
@RequestParam(value = "namespace", required = false) String namespace,
|
|
|
|
@io.swagger.v3.oas.annotations.Parameter(description = "Kubeflow 네임스페이스", required = false)
|
|
|
|
@RequestParam(value = "regUserId") String regUserId,
|
|
|
|
@RequestParam(value = "namespace", required = false) String namespace
|
|
|
|
@RequestParam(value = "projectId") Long projectId
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
// Kubeflow 업로드
|
|
|
|
Map<String, Object> result = pipelineUploadService.uploadPipeline(file, name, displayName, description, namespace);
|
|
|
|
Map<String, Object> result = pipelineUploadService.uploadPipeline(file, name, displayName, description, namespace);
|
|
|
|
return ResponseEntity.ok(result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (HttpClientErrorException e) {
|
|
|
|
// WorkflowEntity 매핑 후 DB 저장
|
|
|
|
log.error("Kubeflow API Error: status={}, response={}", e.getStatusCode(), e.getResponseBodyAsString(), e);
|
|
|
|
WorkflowEntity workflow = WorkflowEntity.builder()
|
|
|
|
|
|
|
|
.pipelineId((String) result.get("pipeline_id"))
|
|
|
|
|
|
|
|
.displayName((String) result.get("display_name"))
|
|
|
|
|
|
|
|
.name((String) result.get("name"))
|
|
|
|
|
|
|
|
.description((String) result.get("description"))
|
|
|
|
|
|
|
|
.namespace((String) result.get("namespace"))
|
|
|
|
|
|
|
|
.regUserId(regUserId)
|
|
|
|
|
|
|
|
.projectId(projectId)
|
|
|
|
|
|
|
|
.kubeflowStatus("Created")
|
|
|
|
|
|
|
|
.version(1)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 저장
|
|
|
|
|
|
|
|
workFlowService.save(workflow);
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> error = new HashMap<>();
|
|
|
|
return ResponseEntity.ok(result);
|
|
|
|
error.put("status", e.getStatusCode().value());
|
|
|
|
|
|
|
|
error.put("error", e.getStatusText());
|
|
|
|
|
|
|
|
error.put("message", e.getResponseBodyAsString());
|
|
|
|
|
|
|
|
return ResponseEntity.status(e.getStatusCode()).body(error);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("Pipeline upload failed", e);
|
|
|
|
log.error("Pipeline upload failed", e);
|
|
|
|
|
|
|
|
Map<String, Object> error = Map.of(
|
|
|
|
Map<String, Object> error = new HashMap<>();
|
|
|
|
"status", 500,
|
|
|
|
error.put("status", 500);
|
|
|
|
"error", "Internal Server Error",
|
|
|
|
error.put("error", "Internal Server Error");
|
|
|
|
"message", e.getMessage()
|
|
|
|
error.put("message", e.getMessage());
|
|
|
|
);
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error);
|
|
|
|
return ResponseEntity.status(500).body(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|