From df87d16d8f1684bd7effb689374f11df3ccf8168 Mon Sep 17 00:00:00 2001
From: fanshuai <1141904845@qq.com>
Date: Fri, 30 Aug 2024 10:03:07 +0800
Subject: [PATCH] dvc
---
ruoyi-modules/management-platform/pom.xml | 16 +-
.../controller/dataset/DatasetController.java | 2 +
.../dataset/NewDatasetFromGitController.java | 110 +++++++++
.../controller/jupyter/JupyterController.java | 7 +-
.../platform/service/DatasetService.java | 9 +
.../service/impl/DatasetServiceImpl.java | 217 +++++++++++++++++-
.../com/ruoyi/platform/utils/ConvertUtil.java | 64 +++++-
.../com/ruoyi/platform/utils/DVCUtils.java | 32 ++-
.../com/ruoyi/platform/utils/HttpUtils.java | 57 ++++-
.../com/ruoyi/platform/utils/JsonUtils.java | 5 +
.../com/ruoyi/platform/utils/YamlUtils.java | 28 +++
.../java/com/ruoyi/platform/vo/DatasetVo.java | 10 +-
.../com/ruoyi/platform/vo/GitProjectVo.java | 67 ++++++
.../com/ruoyi/platform/vo/NewDatasetVo.java | 41 ++++
14 files changed, 638 insertions(+), 27 deletions(-)
create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java
create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/YamlUtils.java
create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/GitProjectVo.java
create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/NewDatasetVo.java
diff --git a/ruoyi-modules/management-platform/pom.xml b/ruoyi-modules/management-platform/pom.xml
index c004f9a..e7c559f 100644
--- a/ruoyi-modules/management-platform/pom.xml
+++ b/ruoyi-modules/management-platform/pom.xml
@@ -142,6 +142,11 @@
docker-java
3.2.13
+
+ commons-beanutils
+ commons-beanutils
+ 1.9.4
+
com.github.docker-java
docker-java-transport-httpclient5
@@ -227,7 +232,16 @@
2.6
compile
-
+
+ org.eclipse.jgit
+ org.eclipse.jgit
+ 5.13.0.202109080827-r
+
+
+ redis.clients
+ jedis
+ 3.6.0
+
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java
index cbd87f4..8e36471 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java
@@ -224,5 +224,7 @@ public class DatasetController {
public AjaxResult uploadDatasetPipeline(@RequestBody(required =false) DatasetVersion datasetVersion) throws Exception {
return AjaxResult.success(this.datasetService.uploadDatasetPipeline(datasetVersion));
}
+
+
}
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java
new file mode 100644
index 0000000..0821d3a
--- /dev/null
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java
@@ -0,0 +1,110 @@
+package com.ruoyi.platform.controller.dataset;
+
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.platform.domain.Dataset;
+import com.ruoyi.platform.service.DatasetService;
+import com.ruoyi.platform.vo.DatasetVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+@RestController
+@RequestMapping("newdataset")
+@Api(value = "新数据集管理")
+public class NewDatasetFromGitController {
+ /**
+ * 服务对象
+ */
+ @Resource
+ private DatasetService datasetService;
+
+
+
+ /**
+ * 新增数据集与版本新
+ *
+ * @param datasetVo 实体
+ * @return 新增结果
+ */
+ @PostMapping("/addDatasetAndVersion")
+ @ApiOperation("添加数据集和版本")
+ public AjaxResult addDatasetAndVersion(@RequestBody DatasetVo datasetVo) throws Exception {
+ return AjaxResult.success(this.datasetService.newCreateDataset(datasetVo));
+
+ }
+
+
+ /**
+ * 新增数据集与版本新
+ *
+ * @param datasetVo 实体
+ * @return 新增结果
+ */
+ @PostMapping("/addVersion")
+ @ApiOperation("添加版本")
+ public AjaxResult addVersion(@RequestBody DatasetVo datasetVo) throws Exception {
+ return AjaxResult.success(this.datasetService.newCreateVersion(datasetVo));
+
+ }
+
+
+ /**
+ * 上传数据集
+ *
+ * @param files 上传的数据集文件
+ * @param uuid 上传唯一标识,构建url
+ * @return 上传结果
+ */
+ @CrossOrigin(origins = "*", allowedHeaders = "*")
+ @PostMapping("/upload")
+ @ApiOperation(value = "上传数据集")
+ public AjaxResult uploadDataset(@RequestParam("file") MultipartFile[] files, @RequestParam("uuid") String uuid) throws Exception {
+ return AjaxResult.success(this.datasetService.uploadDatasetlocal(files,uuid));
+ }
+
+ /**
+ * 数据集打包下载
+ *
+ * @param version 数据集版本
+ * @return 单条数据
+ */
+ @GetMapping("/downloadAllFiles")
+ @ApiOperation(value = "下载同一版本下所有数据集,并打包")
+ public ResponseEntity downloadAllDatasetFiles(@RequestParam("repository_name") String repositoryName, @RequestParam("version") String version) throws Exception {
+ return datasetService.downloadAllDatasetFilesNew(repositoryName, version);
+ }
+
+ /**
+ * 下载数据集
+ *
+ * @param dataset_version_id ps:这里的id是dataset_version表的主键
+ * @return 单条数据
+ */
+
+ @GetMapping("/download/{dataset_version_id}")
+ @ApiOperation(value = "下载单个数据集文件", notes = "根据数据集版本表id下载单个数据集文件")
+ public ResponseEntity downloadDataset(@PathVariable("dataset_version_id") Integer dataset_version_id) throws Exception {
+ return datasetService.downloadDataset(dataset_version_id);
+ }
+
+ @GetMapping("/queryDatasets")
+ @ApiOperation("数据集广场公开数据集分页查询,根据data_type,data_tag筛选,true公开false私有")
+ public AjaxResult queryDatasets(Dataset dataset, @RequestParam("page") int page,
+ @RequestParam("size") int size,
+ @RequestParam(value = "is_public") Boolean isPublic,
+ @RequestParam(value = "data_type", required = false) String dataType,
+ @RequestParam(value = "data_tag", required = false) String dataTag) throws Exception {
+ PageRequest pageRequest = PageRequest.of(page, size);
+ if(isPublic){
+ return AjaxResult.success(this.datasetService.newPubilcQueryByPage(dataset, pageRequest));
+ }else {
+ return AjaxResult.success(this.datasetService.newPersonalQueryByPage(dataset, pageRequest));
+ }
+ }
+
+}
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/jupyter/JupyterController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/jupyter/JupyterController.java
index 080698c..02bff0d 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/jupyter/JupyterController.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/jupyter/JupyterController.java
@@ -90,7 +90,7 @@ public class JupyterController extends BaseController {
@GetMapping(value = "/testdvc")
public AjaxResult testdvc() throws Exception {
DatasetVo datasetVo = new DatasetVo();
- datasetVo.setName("testdvc82sas155");
+ datasetVo.setName("testdassad23");
datasetVo.setDescription("sss");
datasetVo.setAvailableRange(0);
datasetVo.setDataTag("计算机视觉");
@@ -98,10 +98,9 @@ public class JupyterController extends BaseController {
datasetVo.setVersion("dev");
List datasetVersionVos = new ArrayList<>();
VersionVo versionVo = new VersionVo();
- versionVo.setUrl("/home/xxx.txt");
+ versionVo.setUrl("E:/test/bb/data/xssa.doc");
datasetVersionVos.add(versionVo);
datasetVo.setDatasetVersionVos(datasetVersionVos);
- datasetService.newCreateDataset(datasetVo);
- return AjaxResult.success();
+ return AjaxResult.success(datasetService.newCreateDataset(datasetVo));
}
}
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/DatasetService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/DatasetService.java
index 148a1eb..a22e710 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/DatasetService.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/DatasetService.java
@@ -3,12 +3,14 @@ package com.ruoyi.platform.service;
import com.ruoyi.platform.domain.Dataset;
import com.ruoyi.platform.domain.DatasetVersion;
import com.ruoyi.platform.vo.DatasetVo;
+import com.ruoyi.platform.vo.NewDatasetVo;
import org.springframework.core.io.InputStreamResource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
@@ -91,6 +93,13 @@ DatasetService {
CompletableFuture newCreateDataset(DatasetVo datasetVo) throws Exception;
+ CompletableFuture newCreateVersion(DatasetVo datasetVo);
+
+ List