Browse Source

改造为可配置使用代理服务器

dev-DXTZYK
fanshuai 1 year ago
parent
commit
d38703abd7
4 changed files with 115 additions and 79 deletions
  1. +10
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DvcServiceImpl.java
  2. +25
    -23
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java
  3. +24
    -23
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java
  4. +56
    -27
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java

+ 10
- 6
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DvcServiceImpl.java View File

@@ -7,6 +7,8 @@ import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class DvcServiceImpl implements DvcService {
@Value("${minio.accessKey}")
@@ -15,20 +17,22 @@ public class DvcServiceImpl implements DvcService {
String secretAccessKey;
@Value("${minio.endpoint}")
String endpoint;
@Resource
private DVCUtils dvcUtils;
@Override
public void initaddpushDvc(String localPath) throws Exception {
LoginUser loginUser = SecurityUtils.getLoginUser();
// dvc init 初始化
DVCUtils.dvcInit(localPath);
dvcUtils.dvcInit(localPath);
// 配置远程S3地址
DVCUtils.dvcRemoteAdd(localPath,"");
// DVCUtils.dvcConfigS3Credentials(localPath,endpoint, accessKeyId, secretAccessKey);
dvcUtils.dvcRemoteAdd(localPath,"");
// dvcUtils.dvcConfigS3Credentials(localPath,endpoint, accessKeyId, secretAccessKey);
// dvc 跟踪
DVCUtils.dvcAdd(localPath , "data");
dvcUtils.dvcAdd(localPath , "data");
// git commit
DVCUtils.gitCommit(localPath, "commit from ci4s with "+loginUser.getUsername());
dvcUtils.gitCommit(localPath, "commit from ci4s with "+loginUser.getUsername());
// dvc push 到远程S3
DVCUtils.dvcPush(localPath);
dvcUtils.dvcPush(localPath);
}

}

+ 25
- 23
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java View File

@@ -78,6 +78,8 @@ public class ModelsServiceImpl implements ModelsService {
private AssetIconService assetIconService;
@Resource
private NewHttpUtils httpUtils;
@Resource
private DVCUtils dvcUtils;

// 固定存储桶名
@Value("${minio.dataReleaseBucketName}")
@@ -597,8 +599,8 @@ public class ModelsServiceImpl implements ModelsService {
String modelPath = rootPath + "/model";
String metaPath = rootPath + "/metadata";

DVCUtils.gitClone(rootPath, projectUrl, branchName, gitLinkUsername, gitLinkPassword);
DVCUtils.moveFiles(sourcePath, modelPath);
dvcUtils.gitClone(rootPath, projectUrl, branchName, gitLinkUsername, gitLinkPassword);
dvcUtils.moveFiles(sourcePath, modelPath);

//拼接生产的元数据后写入yaml文件
ModelMetaVo modelMetaVo = new ModelMetaVo();
@@ -625,21 +627,21 @@ public class ModelsServiceImpl implements ModelsService {
YamlUtils.generateYamlFile(metaMap, metaPath, "metadata");
String meta = JSON.toJSONString(modelMetaVo);

DVCUtils.dvcInit(rootPath);
dvcUtils.dvcInit(rootPath);
// 配置远程S3地址
String s3Path = "management-platform-files/" + ci4sUsername + "/model/" + gitlinIid + "/" + repositoryName + "/" + branchName;
DVCUtils.dvcRemoteAdd(rootPath, s3Path);
DVCUtils.dvcConfigS3Credentials(rootPath, endpoint);
DVCUtils.dvcConfigS3Credentials2(rootPath, accessKeyId);
DVCUtils.dvcConfigS3Credentials3(rootPath, secretAccessKey);
dvcUtils.dvcRemoteAdd(rootPath, s3Path);
dvcUtils.dvcConfigS3Credentials(rootPath, endpoint);
dvcUtils.dvcConfigS3Credentials2(rootPath, accessKeyId);
dvcUtils.dvcConfigS3Credentials3(rootPath, secretAccessKey);

// dvc 跟踪
DVCUtils.dvcAdd(rootPath, "model");
dvcUtils.dvcAdd(rootPath, "model");
// git commit
DVCUtils.gitAdd(rootPath, ".");
DVCUtils.gitCommit(rootPath, "commit from ci4s with " + ci4sUsername);
DVCUtils.gitPush(rootPath, gitLinkUsername, gitLinkPassword);
DVCUtils.dvcPush(rootPath);
dvcUtils.gitAdd(rootPath, ".");
dvcUtils.gitCommit(rootPath, "commit from ci4s with " + ci4sUsername);
dvcUtils.gitPush(rootPath, gitLinkUsername, gitLinkPassword);
dvcUtils.dvcPush(rootPath);

//保存模型依赖
modelDependency.setRepoId(gitlinIid);
@@ -694,10 +696,10 @@ public class ModelsServiceImpl implements ModelsService {
ModelMetaVo oldModelVo = ConvertUtil.convertMapToObject(stringObjectMap, ModelMetaVo.class);

// 创建本地分支
DVCUtils.createLocalBranchBasedOnMaster(rootPath, branchName);
dvcUtils.createLocalBranchBasedOnMaster(rootPath, branchName);
//dvc checkout
DVCUtils.dvcCheckout(rootPath);
DVCUtils.moveFiles(sourcePath, modelPath);
dvcUtils.dvcCheckout(rootPath);
dvcUtils.moveFiles(sourcePath, modelPath);

//拼接生产的元数据后写入yaml文件
ModelMetaVo modelMetaVo = new ModelMetaVo();
@@ -727,15 +729,15 @@ public class ModelsServiceImpl implements ModelsService {

// 配置远程S3地址
String s3Path = "management-platform-files/" + ci4sUsername + "/model/" + modelsVo.getId() + "/" + repositoryName + "/" + branchName;
DVCUtils.dvcRemoteAdd(rootPath, s3Path);
DVCUtils.dvcConfigS3Credentials(rootPath, endpoint);
DVCUtils.dvcConfigS3Credentials2(rootPath, accessKeyId);
DVCUtils.dvcConfigS3Credentials3(rootPath, secretAccessKey);
dvcUtils.dvcRemoteAdd(rootPath, s3Path);
dvcUtils.dvcConfigS3Credentials(rootPath, endpoint);
dvcUtils.dvcConfigS3Credentials2(rootPath, accessKeyId);
dvcUtils.dvcConfigS3Credentials3(rootPath, secretAccessKey);
// dvc 跟踪
DVCUtils.dvcAdd(rootPath, "model");
DVCUtils.pushNewBranchToRemote(rootPath, gitLinkUsername, gitLinkPassword, branchName);
dvcUtils.dvcAdd(rootPath, "model");
dvcUtils.pushNewBranchToRemote(rootPath, gitLinkUsername, gitLinkPassword, branchName);
//dvc push 到远程S3
DVCUtils.dvcPush(rootPath);
dvcUtils.dvcPush(rootPath);

//保存模型依赖
modelDependency.setRepoId(modelsVo.getId());
@@ -912,7 +914,7 @@ public class ModelsServiceImpl implements ModelsService {
}

// git pull操作,然后读取里面的文件列表,列出每个文件的大小和名称,封装成MAP
List<Map<String, Object>> fileDetailsAfterGitPull = DVCUtils.getFileDetailsAfterGitPull(localPath + ci4sUsername + "/model/" + id, name, version, "model", gitLinkUsername, gitLinkPassword);
List<Map<String, Object>> fileDetailsAfterGitPull = dvcUtils.getFileDetailsAfterGitPull(localPath + ci4sUsername + "/model/" + id, name, version, "model", gitLinkUsername, gitLinkPassword);

Map<String, Object> stringObjectMap = YamlUtils.loadYamlFile(localPath + ci4sUsername + "/model/" + id + "/" + name + "/metadata/metadata.yaml");



+ 24
- 23
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java View File

@@ -66,6 +66,8 @@ public class NewDatasetServiceImpl implements NewDatasetService {
private NewHttpUtils httpUtils;
@Resource
private DatasetTempStorageService datasetTempStorageService;
@Resource
private DVCUtils dvcUtils;
@Override
public String newCreateDataset(NewDatasetVo datasetVo) throws Exception {
String token = gitService.checkoutToken();
@@ -109,10 +111,10 @@ public class NewDatasetServiceImpl implements NewDatasetService {
String datasetPath = localPath + "/dataset";

// 命令行操作 git clone 项目地址
DVCUtils.gitClone(localPath, projectUrl, branchName, gitLinkUsername, gitLinkPassword);
dvcUtils.gitClone(localPath, projectUrl, branchName, gitLinkUsername, gitLinkPassword);
String s3Path = "management-platform-files" + "/" + relatePath + "/" + branchName;

DVCUtils.moveFiles(sourcePath, datasetPath);
dvcUtils.moveFiles(sourcePath, datasetPath);
// 拼接生产的元数据后写入yaml文件
datasetVo.setCreateBy(String.valueOf(StringUtils.isNotEmpty((String) userInfo.get("nickname")) ? userInfo.get("nickname") : userInfo.get("login")));
datasetVo.setUpdateTime(DateUtils.getTime());
@@ -132,20 +134,19 @@ public class NewDatasetServiceImpl implements NewDatasetService {

YamlUtils.generateYamlFile(JsonUtils.objectToMap(datasetVo), localPath, "dataset");
// dvc init 初始化
DVCUtils.dvcInit(localPath);
dvcUtils.dvcInit(localPath);
// 配置远程S3地址
DVCUtils.dvcRemoteAdd(localPath, s3Path);
DVCUtils.dvcConfigS3Credentials(localPath, endpoint);
DVCUtils.dvcConfigS3Credentials2(localPath, accessKeyId);
DVCUtils.dvcConfigS3Credentials3(localPath, secretAccessKey);
dvcUtils.dvcRemoteAdd(localPath, s3Path);
dvcUtils.dvcConfigS3Credentials(localPath, endpoint);
dvcUtils.dvcConfigS3Credentials2(localPath, accessKeyId);
dvcUtils.dvcConfigS3Credentials3(localPath, secretAccessKey);
// dvc 跟踪
DVCUtils.dvcAdd(localPath, "dataset");
dvcUtils.dvcAdd(localPath, "dataset");
// git commit
DVCUtils.gitAdd(localPath, ".");
DVCUtils.gitCommit(localPath, "commit from ci4s with " + loginUser.getUsername());
DVCUtils.gitPush(localPath, gitLinkUsername, gitLinkPassword);
dvcUtils.gitCommit(localPath, "commit from ci4s with " + loginUser.getUsername());
dvcUtils.gitPush(localPath, gitLinkUsername, gitLinkPassword);
// dvc push 到远程S3
DVCUtils.dvcPush(localPath);
dvcUtils.dvcPush(localPath);
return "新增数据集成功";
}

@@ -172,15 +173,15 @@ public class NewDatasetServiceImpl implements NewDatasetService {
NewDatasetVo newDatasetVo = ConvertUtil.convertMapToObject(stringObjectMap, NewDatasetVo.class);

// 创建本地分支
DVCUtils.createLocalBranchBasedOnMaster(localPath, branchName);
dvcUtils.createLocalBranchBasedOnMaster(localPath, branchName);

//dvc checkout
DVCUtils.dvcCheckout(localPath);
dvcUtils.dvcCheckout(localPath);

// 准备数据
String s3Path = "management-platform-files" + "/" + relatePath + "/" + branchName;

DVCUtils.moveFiles(sourcePath, datasetPath);
dvcUtils.moveFiles(sourcePath, datasetPath);
// 拼接生产的元数据后写入yaml文件
datasetVo.setCreateBy(String.valueOf(StringUtils.isNotEmpty((String) userInfo.get("nickname")) ? userInfo.get("nickname") : userInfo.get("login")));
datasetVo.setUpdateTime(DateUtils.getTime());
@@ -205,15 +206,15 @@ public class NewDatasetServiceImpl implements NewDatasetService {
YamlUtils.generateYamlFile(JsonUtils.objectToMap(datasetVo), localPath, "dataset");
//dvc数据跟踪
// 配置远程S3地址
DVCUtils.dvcRemoteAdd(localPath, s3Path);
DVCUtils.dvcConfigS3Credentials(localPath, endpoint);
DVCUtils.dvcConfigS3Credentials2(localPath, accessKeyId);
DVCUtils.dvcConfigS3Credentials3(localPath, secretAccessKey);
dvcUtils.dvcRemoteAdd(localPath, s3Path);
dvcUtils.dvcConfigS3Credentials(localPath, endpoint);
dvcUtils.dvcConfigS3Credentials2(localPath, accessKeyId);
dvcUtils.dvcConfigS3Credentials3(localPath, secretAccessKey);
// dvc 跟踪
DVCUtils.dvcAdd(localPath, "dataset");
DVCUtils.pushNewBranchToRemote(localPath,gitLinkUsername,gitLinkPassword,branchName);
dvcUtils.dvcAdd(localPath, "dataset");
dvcUtils.pushNewBranchToRemote(localPath,gitLinkUsername,gitLinkPassword,branchName);
//dvc push 到远程S3
DVCUtils.dvcPush(localPath);
dvcUtils.dvcPush(localPath);
return "新增数据集成功";
}

@@ -289,7 +290,7 @@ public class NewDatasetServiceImpl implements NewDatasetService {
}
version = (String) versionList.get(0).get("name");
}
List<Map<String, Object>> fileDetailsAfterGitPull = DVCUtils.getFileDetailsAfterGitPull(localPathlocal +loginUser.getUsername()+"/datasets/" + id, name, version, "data",gitLinkUsername, gitLinkPassword);
List<Map<String, Object>> fileDetailsAfterGitPull = dvcUtils.getFileDetailsAfterGitPull(localPathlocal +loginUser.getUsername()+"/datasets/" + id, name, version, "data",gitLinkUsername, gitLinkPassword);
// 在localPathlocal+id+"/"+repositoryName目录下的dataset.yaml中取到元数据
Map<String, Object> stringObjectMap = YamlUtils.loadYamlFile(localPathlocal +loginUser.getUsername()+"/datasets/" + id + "/" + name + "/" + "dataset.yaml");
NewDatasetVo newDatasetVo = ConvertUtil.convertMapToObject(stringObjectMap, NewDatasetVo.class);


+ 56
- 27
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java View File

@@ -9,6 +9,8 @@ import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.transport.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.BufferedReader;
import java.io.File;
@@ -24,10 +26,32 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

@Component
public class DVCUtils {
private static final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
private static final Logger log = LoggerFactory.getLogger(DVCUtils.class);
private static final ExecutorCompletionService<Void> completionService = new ExecutorCompletionService<>(executorService);
@Value("${proxy.useProxy:false}")
private boolean useProxy;

@Value("${proxy.host}")
private String host;

@Value("${proxy.port}")
private Integer port;
private class ProxyConfigCallback implements TransportConfigCallback {
@Override
public void configure(Transport transport) {
if (useProxy) {
System.setProperty("http.proxyHost", host);
System.setProperty("http.proxyPort", String.valueOf(port));
System.setProperty("https.proxyHost", host);
System.setProperty("https.proxyPort", String.valueOf(port));
log.info("Proxy configured: {}:{}", host, port);
}
}
}

private static void runCommand(String command, String workingDir) throws Exception {
ProcessBuilder processBuilder = new ProcessBuilder(command.split(" "));
processBuilder.directory(new File(workingDir));
@@ -43,7 +67,7 @@ public class DVCUtils {
}
}

public static void moveFiles(String sourcePath, String targetPath) throws Exception {
public void moveFiles(String sourcePath, String targetPath) throws Exception {
Path sourceDir = Paths.get(sourcePath);
Path targetDir = Paths.get(targetPath);

@@ -54,17 +78,18 @@ public class DVCUtils {
Files.move(sourceDir, targetDir, StandardCopyOption.REPLACE_EXISTING);
}

public static void gitClone(String localPath, String repoUrl, String branch, String username, String password) throws GitAPIException {
public void gitClone(String localPath, String repoUrl, String branch, String username, String password) throws GitAPIException {
CloneCommand cloneCommand = Git.cloneRepository()
.setURI(repoUrl)
.setBranch(branch)
.setDirectory(new java.io.File(localPath))
.setTransportConfigCallback(new ProxyConfigCallback())
.setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password));

cloneCommand.call();
}

public static void gitClone(String localPath, String repoUrl, String username, String password) throws GitAPIException {
public void gitClone(String localPath, String repoUrl, String username, String password) throws GitAPIException {
CloneCommand cloneCommand = Git.cloneRepository()
.setURI(repoUrl)
.setDirectory(new java.io.File(localPath))
@@ -74,7 +99,7 @@ public class DVCUtils {
}


public static void gitAdd(String localPath, String filePath) throws IOException, GitAPIException {
public void gitAdd(String localPath, String filePath) throws IOException, GitAPIException {
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File(localPath, ".git"))
.readEnvironment()
@@ -87,7 +112,7 @@ public class DVCUtils {
}
}

public static void gitCommit(String localPath, String commitMessage) throws IOException, GitAPIException {
public void gitCommit(String localPath, String commitMessage) throws IOException, GitAPIException {
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File(localPath, ".git"))
.readEnvironment()
@@ -105,7 +130,7 @@ public class DVCUtils {
}
}

public static void gitPush(String localPath, String username, String password) throws IOException, GitAPIException {
public void gitPush(String localPath, String username, String password) throws IOException, GitAPIException {
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File(localPath, ".git"))
.readEnvironment()
@@ -116,6 +141,7 @@ public class DVCUtils {
CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(username, password);
PushCommand pushCommand = git.push();
pushCommand.setCredentialsProvider(credentialsProvider)
.setTransportConfigCallback(new ProxyConfigCallback())
.setForce(true)
.call();
}
@@ -129,7 +155,7 @@ public class DVCUtils {
* @param username 远程仓库用户名
* @param password 远程仓库密码
*/
public static void updateAllBranches(String localPath, String username, String password) {
public void updateAllBranches(String localPath, String username, String password) {
try (Git git = Git.open(new File(localPath))) {
// 设置凭证,用于远程仓库的认证
UsernamePasswordCredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(username, password);
@@ -171,7 +197,7 @@ public class DVCUtils {
* @param password 远程仓库密码
* @param branchName 需要更新的分支名称
*/
public static void updateBranch(String localPath, String username, String password, String branchName) {
public void updateBranch(String localPath, String username, String password, String branchName) {
try (Git git = Git.open(new File(localPath))) {
// 设置凭证,用于远程仓库的认证
UsernamePasswordCredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(username, password);
@@ -202,7 +228,7 @@ public class DVCUtils {
* @param localPath 本地仓库路径
* @param branchName 要创建的分支名称
*/
public static void createLocalBranch(String localPath, String branchName) {
public void createLocalBranch(String localPath, String branchName) {
try (Git git = Git.open(new File(localPath))) {
// 创建本地分支
git.branchCreate().setName(branchName).call();
@@ -219,7 +245,7 @@ public class DVCUtils {
* @param localPath 本地仓库路径
* @param branchName 要创建的分支名称
*/
public static void createLocalBranchBasedOnMaster(String localPath, String branchName) {
public void createLocalBranchBasedOnMaster(String localPath, String branchName) {
try (Git git = Git.open(new File(localPath))) {
// 切换到 master 分支
git.checkout()
@@ -241,7 +267,7 @@ public class DVCUtils {
* @param password 远程仓库密码
* @param branchName 要推送的分支名称
*/
public static void pushLocalBranchToRemote(String localPath, String username, String password, String branchName) {
public void pushLocalBranchToRemote(String localPath, String username, String password, String branchName) {
try (Git git = Git.open(new File(localPath))) {
// 设置凭证,用于远程仓库的认证
UsernamePasswordCredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(username, password);
@@ -279,7 +305,7 @@ public class DVCUtils {
* @throws IOException 如果仓库路径无效
* @throws GitAPIException 如果Git操作失败
*/
public static void pushNewBranchToRemote(String localPath, String username, String password, String branchName) throws IOException, GitAPIException {
public void pushNewBranchToRemote(String localPath, String username, String password, String branchName) throws IOException, GitAPIException {
try (Git git = Git.open(new File(localPath))) {
// 设置凭证,用于远程仓库的认证
UsernamePasswordCredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(username, password);
@@ -300,6 +326,7 @@ public class DVCUtils {
.setRemote("origin")
.setRefSpecs(refSpec)
.setCredentialsProvider(credentialsProvider)
.setTransportConfigCallback(new ProxyConfigCallback())
.call();

// 打印结果
@@ -326,7 +353,7 @@ public class DVCUtils {
return false;
}

public static void refreshRemoteBranches(String localPath, String username, String password, String branch) throws Exception {
public void refreshRemoteBranches(String localPath, String username, String password, String branch) throws Exception {
try (Repository repository = new FileRepositoryBuilder()
.setGitDir(new File(localPath + "/.git"))
.readEnvironment()
@@ -349,6 +376,7 @@ public class DVCUtils {
FetchResult fetchResult = git.fetch()
.setRemote("origin")
.setCredentialsProvider(credentialsProvider)
.setTransportConfigCallback(new ProxyConfigCallback()) // 设置代理
.call();

// 打印获取的远程分支
@@ -394,7 +422,7 @@ public class DVCUtils {
dvcCheckout(localPath);
}

private static void processBranch(Git git, Repository repository, UsernamePasswordCredentialsProvider credentialsProvider, String fullBranchName, String branchName) throws Exception {
private void processBranch(Git git, Repository repository, UsernamePasswordCredentialsProvider credentialsProvider, String fullBranchName, String branchName) throws Exception {
// 检查本地分支是否存在
Ref localRef = repository.findRef("refs/heads/" + branchName);
if (localRef != null) {
@@ -422,6 +450,7 @@ public class DVCUtils {
}
// 执行 git pull
PullCommand pullCommand = git.pull()
.setTransportConfigCallback(new ProxyConfigCallback())
.setCredentialsProvider(credentialsProvider);
pullCommand.call();
}
@@ -447,7 +476,7 @@ public class DVCUtils {


public static void gitFetch(String localPath, String username, String password) throws IOException, GitAPIException {
public void gitFetch(String localPath, String username, String password) throws IOException, GitAPIException {
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File(localPath, ".git"))
.readEnvironment()
@@ -460,7 +489,7 @@ public class DVCUtils {
fetchCommand.setCredentialsProvider(credentialsProvider).call();
}
}
public static void gitCheckoutBranch(String localPath, String branchName) throws IOException, GitAPIException {
public void gitCheckoutBranch(String localPath, String branchName) throws IOException, GitAPIException {
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File(localPath, ".git"))
.readEnvironment()
@@ -473,7 +502,7 @@ public class DVCUtils {
}
}

public static void gitPull(String localPath, String username, String password) throws IOException, GitAPIException {
public void gitPull(String localPath, String username, String password) throws IOException, GitAPIException {
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File(localPath, ".git"))
.readEnvironment()
@@ -487,50 +516,50 @@ public class DVCUtils {
}
}

public static void dvcInit(String localPath) throws Exception {
public void dvcInit(String localPath) throws Exception {
String command = "dvc init";
runCommand(command, localPath);
}

public static void dvcAdd(String localPath, String filePath) throws Exception {
public void dvcAdd(String localPath, String filePath) throws Exception {
String command = "dvc add " + filePath;
runCommand(command, localPath);
}

public static void dvcRemoteAdd(String localPath, String s3RemoteUrl) throws Exception {
public void dvcRemoteAdd(String localPath, String s3RemoteUrl) throws Exception {
String command = "dvc remote add -d myremote s3://" + s3RemoteUrl;
runCommand(command, localPath);
}

public static void dvcConfigS3Credentials(String localPath, String endpointurl) throws Exception {
public void dvcConfigS3Credentials(String localPath, String endpointurl) throws Exception {
String command = "dvc remote modify myremote endpointurl " + endpointurl;
runCommand(command, localPath);
}

public static void dvcConfigS3Credentials2(String localPath, String accessKeyId) throws Exception {
public void dvcConfigS3Credentials2(String localPath, String accessKeyId) throws Exception {
String command = "dvc remote modify myremote access_key_id " + accessKeyId;
runCommand(command, localPath);
}

public static void dvcConfigS3Credentials3(String localPath, String secretAccessKey) throws Exception {
public void dvcConfigS3Credentials3(String localPath, String secretAccessKey) throws Exception {
String command = "dvc remote modify myremote secret_access_key " + secretAccessKey;
runCommand(command, localPath);
}

public static void dvcPush(String localPath) throws Exception {
public void dvcPush(String localPath) throws Exception {
String command = "dvc push -v";
runCommand(command, localPath);
}

// 更新的 dvcPull 方法
public static void dvcPull(String localPath) throws Exception {
public void dvcPull(String localPath) throws Exception {
String command = "dvc pull";
runCommand(command, localPath);
}


// 方法
public static void dvcCheckout(String localPath) throws Exception {
public void dvcCheckout(String localPath) throws Exception {
String command = "dvc checkout";
runCommand(command, localPath);
}
@@ -544,7 +573,7 @@ public class DVCUtils {
* @param branch 分支名称
* @return 包含文件路径、名称和大小的List<Map<String, Object>>
*/
public static List<Map<String, Object>> getFileDetailsAfterGitPull(String localPath, String repoFolder, String branch, String filePath , String username, String password) {
public List<Map<String, Object>> getFileDetailsAfterGitPull(String localPath, String repoFolder, String branch, String filePath , String username, String password) {
List<Map<String, Object>> fileInfoList = new ArrayList<>();

try {


Loading…
Cancel
Save