From d38703abd7f3bd3728aae4b3369d3754dbdb5562 Mon Sep 17 00:00:00 2001 From: fanshuai <1141904845@qq.com> Date: Wed, 18 Sep 2024 10:23:08 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=94=B9=E9=80=A0=E4=B8=BA=E5=8F=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BD=BF=E7=94=A8=E4=BB=A3=E7=90=86=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/service/impl/DvcServiceImpl.java | 16 ++-- .../service/impl/ModelsServiceImpl.java | 48 ++++++----- .../service/impl/NewDatasetServiceImpl.java | 47 ++++++----- .../com/ruoyi/platform/utils/DVCUtils.java | 83 +++++++++++++------ 4 files changed, 115 insertions(+), 79 deletions(-) diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DvcServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DvcServiceImpl.java index a962588f..192dfe7c 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DvcServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DvcServiceImpl.java @@ -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); } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java index ad2cc90a..762dd69e 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java @@ -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> fileDetailsAfterGitPull = DVCUtils.getFileDetailsAfterGitPull(localPath + ci4sUsername + "/model/" + id, name, version, "model", gitLinkUsername, gitLinkPassword); + List> fileDetailsAfterGitPull = dvcUtils.getFileDetailsAfterGitPull(localPath + ci4sUsername + "/model/" + id, name, version, "model", gitLinkUsername, gitLinkPassword); Map stringObjectMap = YamlUtils.loadYamlFile(localPath + ci4sUsername + "/model/" + id + "/" + name + "/metadata/metadata.yaml"); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java index e0b80170..c09f8a14 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java @@ -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> fileDetailsAfterGitPull = DVCUtils.getFileDetailsAfterGitPull(localPathlocal +loginUser.getUsername()+"/datasets/" + id, name, version, "data",gitLinkUsername, gitLinkPassword); + List> fileDetailsAfterGitPull = dvcUtils.getFileDetailsAfterGitPull(localPathlocal +loginUser.getUsername()+"/datasets/" + id, name, version, "data",gitLinkUsername, gitLinkPassword); // 在localPathlocal+id+"/"+repositoryName目录下的dataset.yaml中取到元数据 Map stringObjectMap = YamlUtils.loadYamlFile(localPathlocal +loginUser.getUsername()+"/datasets/" + id + "/" + name + "/" + "dataset.yaml"); NewDatasetVo newDatasetVo = ConvertUtil.convertMapToObject(stringObjectMap, NewDatasetVo.class); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java index c877721c..785efee6 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java @@ -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 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> */ - public static List> getFileDetailsAfterGitPull(String localPath, String repoFolder, String branch, String filePath , String username, String password) { + public List> getFileDetailsAfterGitPull(String localPath, String repoFolder, String branch, String filePath , String username, String password) { List> fileInfoList = new ArrayList<>(); try { From eeb0d0c14924a5c8c16e858354d7a527b152e6d8 Mon Sep 17 00:00:00 2001 From: cp3hnu Date: Wed, 18 Sep 2024 11:09:46 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E7=A6=81=E6=AD=A2=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=8B=96=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/src/components/KFEmpty/index.tsx | 2 +- react-ui/src/components/ModalTitle/index.tsx | 2 +- .../src/components/SubAreaTitle/index.tsx | 2 +- .../components/CodeConfigItem/index.tsx | 9 +++++++-- .../Dataset/components/CategoryItem/index.tsx | 2 ++ .../Dataset/components/ResourceItem/index.tsx | 9 +++++++-- .../Dataset/components/ResourcePage/index.tsx | 8 ++++---- .../components/ExperimentInstance/index.tsx | 2 ++ .../components/ExperimentStatusCell/index.tsx | 7 ++++++- .../components/TensorBoardStatus/index.tsx | 2 ++ react-ui/src/pages/Experiment/index.jsx | 2 ++ .../Pipeline/components/ModelMenu/index.tsx | 1 + .../Center/components/AvatarCropper/index.tsx | 7 ++++++- react-ui/src/pages/User/Center/index.tsx | 2 +- react-ui/src/pages/User/Login/index.tsx | 5 ++++- .../components/ExperimentTable/index.tsx | 2 ++ .../components/QuickStart/WorkArrow.tsx | 1 + .../components/TotalStatistics/index.tsx | 2 +- .../Workspace/components/UserSpace/index.tsx | 20 ++++++++++++++++--- .../components/WorkspaceIntro/index.tsx | 18 +++++++++++++++-- react-ui/src/pages/Workspace/index.less | 1 + react-ui/src/pages/Workspace/index.tsx | 3 ++- react-ui/src/utils/ui.tsx | 1 + 23 files changed, 88 insertions(+), 22 deletions(-) diff --git a/react-ui/src/components/KFEmpty/index.tsx b/react-ui/src/components/KFEmpty/index.tsx index e36a4b2d..e59b6f6b 100644 --- a/react-ui/src/components/KFEmpty/index.tsx +++ b/react-ui/src/components/KFEmpty/index.tsx @@ -46,7 +46,7 @@ function KFEmpty({ return (
- +
{title}
{content}
{hasFooter && ( diff --git a/react-ui/src/components/ModalTitle/index.tsx b/react-ui/src/components/ModalTitle/index.tsx index adc83227..4c0179eb 100644 --- a/react-ui/src/components/ModalTitle/index.tsx +++ b/react-ui/src/components/ModalTitle/index.tsx @@ -18,7 +18,7 @@ type ModalTitleProps = { function ModalTitle({ title, image, style, className }: ModalTitleProps) { return (
- {image && } + {image && } {title}
); diff --git a/react-ui/src/components/SubAreaTitle/index.tsx b/react-ui/src/components/SubAreaTitle/index.tsx index a1d5e33e..0458f715 100644 --- a/react-ui/src/components/SubAreaTitle/index.tsx +++ b/react-ui/src/components/SubAreaTitle/index.tsx @@ -17,7 +17,7 @@ type SubAreaTitleProps = { function SubAreaTitle({ title, image, style, className }: SubAreaTitleProps) { return (
- + {title}
); diff --git a/react-ui/src/pages/CodeConfig/components/CodeConfigItem/index.tsx b/react-ui/src/pages/CodeConfig/components/CodeConfigItem/index.tsx index e20f76a8..70fcea51 100644 --- a/react-ui/src/pages/CodeConfig/components/CodeConfigItem/index.tsx +++ b/react-ui/src/pages/CodeConfig/components/CodeConfigItem/index.tsx @@ -63,11 +63,16 @@ function CodeConfigItem({ item, onClick, onEdit, onRemove }: CodeConfigItemProps
- + {item.create_by}
- + 最近更新: {formatDate(item.update_time, 'YYYY-MM-DD')}
diff --git a/react-ui/src/pages/Dataset/components/CategoryItem/index.tsx b/react-ui/src/pages/Dataset/components/CategoryItem/index.tsx index ee50e64d..417248fc 100644 --- a/react-ui/src/pages/Dataset/components/CategoryItem/index.tsx +++ b/react-ui/src/pages/Dataset/components/CategoryItem/index.tsx @@ -23,12 +23,14 @@ function CategoryItem({ resourceType, item, isSelected, onClick }: CategoryItemP style={{ width: '22px' }} src={`/assets/images/${config.prefix}/${item.path}.png`} alt="" + draggable={false} /> {item.name} diff --git a/react-ui/src/pages/Dataset/components/ResourceItem/index.tsx b/react-ui/src/pages/Dataset/components/ResourceItem/index.tsx index e00dcdfa..a8cabfe9 100644 --- a/react-ui/src/pages/Dataset/components/ResourceItem/index.tsx +++ b/react-ui/src/pages/Dataset/components/ResourceItem/index.tsx @@ -39,11 +39,16 @@ function ResourceItem({ item, isPublic, onClick, onRemove }: ResourceItemProps)
{item.description}
- + {item.create_by ?? ''}
- + {'最近更新: '} {item.update_time ? formatDate(item.update_time, 'YYYY-MM-DD') : item.time_ago ?? ''} diff --git a/react-ui/src/pages/Dataset/components/ResourcePage/index.tsx b/react-ui/src/pages/Dataset/components/ResourcePage/index.tsx index e5180a01..1dd72472 100644 --- a/react-ui/src/pages/Dataset/components/ResourcePage/index.tsx +++ b/react-ui/src/pages/Dataset/components/ResourcePage/index.tsx @@ -18,8 +18,8 @@ function ResourcePage({ resourceType }: ResourcePageProps) { const [activeTab, setActiveTab] = useState(cacheState?.activeTab ?? CommonTabKeys.Public); const [typeList, setTypeList] = useState([]); const [tagList, setTagList] = useState([]); - const [activeType, setActiveType] = useState(cacheState?.activeType); - const [activeTag, setActiveTag] = useState(cacheState?.activeTag); + const [activeType, setActiveType] = useState(cacheState?.activeType); + const [activeTag, setActiveTag] = useState(cacheState?.activeTag); const dataListRef = useRef(null); const config = resourceConfig[resourceType]; @@ -34,12 +34,12 @@ function ResourcePage({ resourceType }: ResourcePageProps) { // 选择类型 const chooseType = (record: CategoryData) => { - setActiveType((prev) => (prev === record.id ? undefined : record.id)); + setActiveType((prev) => (prev === record.name ? undefined : record.name)); }; // 选择 Tag const chooseTag = (record: CategoryData) => { - setActiveTag((prev) => (prev === record.id ? undefined : record.id)); + setActiveTag((prev) => (prev === record.name ? undefined : record.name)); }; // 获取分类 diff --git a/react-ui/src/pages/Experiment/components/ExperimentInstance/index.tsx b/react-ui/src/pages/Experiment/components/ExperimentInstance/index.tsx index 1fb3441e..e2bdb42f 100644 --- a/react-ui/src/pages/Experiment/components/ExperimentInstance/index.tsx +++ b/react-ui/src/pages/Experiment/components/ExperimentInstance/index.tsx @@ -116,6 +116,8 @@ function ExperimentInstanceComponent({ - + )} diff --git a/react-ui/src/pages/Experiment/index.jsx b/react-ui/src/pages/Experiment/index.jsx index 9faf4eee..b09ba986 100644 --- a/react-ui/src/pages/Experiment/index.jsx +++ b/react-ui/src/pages/Experiment/index.jsx @@ -385,6 +385,8 @@ function Experiment() { style={{ width: '17px', marginRight: '6px' }} key={index} src={experimentStatusInfo[item].icon} + draggable={false} + alt="" /> ); }) diff --git a/react-ui/src/pages/Pipeline/components/ModelMenu/index.tsx b/react-ui/src/pages/Pipeline/components/ModelMenu/index.tsx index 38f68061..1418b4f8 100644 --- a/react-ui/src/pages/Pipeline/components/ModelMenu/index.tsx +++ b/react-ui/src/pages/Pipeline/components/ModelMenu/index.tsx @@ -48,6 +48,7 @@ const ModelMenu = ({ onComponentDragEnd }: ModelMenuProps) => { )} diff --git a/react-ui/src/pages/User/Center/components/AvatarCropper/index.tsx b/react-ui/src/pages/User/Center/components/AvatarCropper/index.tsx index a2e19b0b..5843a937 100644 --- a/react-ui/src/pages/User/Center/components/AvatarCropper/index.tsx +++ b/react-ui/src/pages/User/Center/components/AvatarCropper/index.tsx @@ -116,7 +116,12 @@ const AvatarCropperForm: React.FC = (props) => {
- +
diff --git a/react-ui/src/pages/User/Center/index.tsx b/react-ui/src/pages/User/Center/index.tsx index 824bb8e6..2e38a984 100644 --- a/react-ui/src/pages/User/Center/index.tsx +++ b/react-ui/src/pages/User/Center/index.tsx @@ -141,7 +141,7 @@ const Center: React.FC = () => { setCropperModalOpen(true); }} > - +
{renderUserInfo(currentUser)} diff --git a/react-ui/src/pages/User/Login/index.tsx b/react-ui/src/pages/User/Login/index.tsx index 277c6483..6ad360d4 100644 --- a/react-ui/src/pages/User/Login/index.tsx +++ b/react-ui/src/pages/User/Login/index.tsx @@ -11,7 +11,7 @@ import styles from './login.less'; const LoginInputPrefix = ({ icon }: { icon: string }) => { return (
- +
); @@ -98,6 +98,7 @@ const Login = () => { 智能材料科研平台 @@ -107,6 +108,7 @@ const Login = () => { @@ -116,6 +118,7 @@ const Login = () => { diff --git a/react-ui/src/pages/Workspace/components/ExperimentTable/index.tsx b/react-ui/src/pages/Workspace/components/ExperimentTable/index.tsx index af940b75..66b10167 100644 --- a/react-ui/src/pages/Workspace/components/ExperimentTable/index.tsx +++ b/react-ui/src/pages/Workspace/components/ExperimentTable/index.tsx @@ -31,6 +31,8 @@ function ExperimentTable({ tableData = [], style }: ExperimentTableProps) { src={experimentStatusInfo[item.status as ExperimentStatus]?.icon} width={17} height={17} + draggable={false} + alt="" />
diff --git a/react-ui/src/pages/Workspace/components/QuickStart/WorkArrow.tsx b/react-ui/src/pages/Workspace/components/QuickStart/WorkArrow.tsx index 76ca1ca7..523d8577 100644 --- a/react-ui/src/pages/Workspace/components/QuickStart/WorkArrow.tsx +++ b/react-ui/src/pages/Workspace/components/QuickStart/WorkArrow.tsx @@ -44,6 +44,7 @@ function WorkArrow({ - +
{title} diff --git a/react-ui/src/pages/Workspace/components/UserSpace/index.tsx b/react-ui/src/pages/Workspace/components/UserSpace/index.tsx index bd4bf323..dcfa7698 100644 --- a/react-ui/src/pages/Workspace/components/UserSpace/index.tsx +++ b/react-ui/src/pages/Workspace/components/UserSpace/index.tsx @@ -20,7 +20,15 @@ function UserSpace({ users = [] }: UserSpaceProps) { className={styles['user-space__avatar']} src={currentUser?.avatar} alt="" - icon={} + icon={ + + } >
{currentUser?.nickName}
{currentUser?.roleNames?.[0]?.roleName}
@@ -34,7 +42,7 @@ function UserSpace({ users = [] }: UserSpaceProps) {
8
- {users?.map((item, index) => { + {users?.map((_item, index) => { return ( + } > ); diff --git a/react-ui/src/pages/Workspace/components/WorkspaceIntro/index.tsx b/react-ui/src/pages/Workspace/components/WorkspaceIntro/index.tsx index 49c03711..81ab8f54 100644 --- a/react-ui/src/pages/Workspace/components/WorkspaceIntro/index.tsx +++ b/react-ui/src/pages/Workspace/components/WorkspaceIntro/index.tsx @@ -15,7 +15,13 @@ function WorkspaceIntro() { type="primary" style={{ marginRight: '20px' }} icon={ - + } > 功能材料自主实验系统 @@ -23,7 +29,13 @@ function WorkspaceIntro() {
diff --git a/react-ui/src/pages/Workspace/index.less b/react-ui/src/pages/Workspace/index.less index 09be2848..300887e9 100644 --- a/react-ui/src/pages/Workspace/index.less +++ b/react-ui/src/pages/Workspace/index.less @@ -53,6 +53,7 @@ width: 64px; height: 64px; background-color: white; + border-radius: 10px; cursor: pointer; } } diff --git a/react-ui/src/pages/Workspace/index.tsx b/react-ui/src/pages/Workspace/index.tsx index 7fa3dd22..bdef4f83 100644 --- a/react-ui/src/pages/Workspace/index.tsx +++ b/react-ui/src/pages/Workspace/index.tsx @@ -76,7 +76,8 @@ function Workspace() { className={styles['workspace__robot-img']} src={require('@/assets/img/robot.png')} onClick={handleClick} - onDragStart={(e) => e.preventDefault()} + draggable={false} + alt="" > diff --git a/react-ui/src/utils/ui.tsx b/react-ui/src/utils/ui.tsx index af27f1cc..7625a771 100644 --- a/react-ui/src/utils/ui.tsx +++ b/react-ui/src/utils/ui.tsx @@ -21,6 +21,7 @@ export function modalConfirm({ title, content, onOk, ...rest }: ModalFuncProps)
{title}
From 752e2c851cb4a3ea007a3d8396e5f173ca0b9e7d Mon Sep 17 00:00:00 2001 From: somunslotus Date: Wed, 18 Sep 2024 11:58:58 +0800 Subject: [PATCH 3/4] x --- k8s/build-java.sh | 0 k8s/build-node.sh | 0 k8s/build.sh | 0 k8s/build_and_deploy.sh | 0 k8s/deploy.sh | 0 k8s/dockerfiles/managent-dockerfile | 4 ++-- k8s/template-yaml/deploy/k8s-7management.yaml | 8 ++++++-- 7 files changed, 8 insertions(+), 4 deletions(-) mode change 100644 => 100755 k8s/build-java.sh mode change 100644 => 100755 k8s/build-node.sh mode change 100644 => 100755 k8s/build.sh mode change 100644 => 100755 k8s/build_and_deploy.sh mode change 100644 => 100755 k8s/deploy.sh diff --git a/k8s/build-java.sh b/k8s/build-java.sh old mode 100644 new mode 100755 diff --git a/k8s/build-node.sh b/k8s/build-node.sh old mode 100644 new mode 100755 diff --git a/k8s/build.sh b/k8s/build.sh old mode 100644 new mode 100755 diff --git a/k8s/build_and_deploy.sh b/k8s/build_and_deploy.sh old mode 100644 new mode 100755 diff --git a/k8s/deploy.sh b/k8s/deploy.sh old mode 100644 new mode 100755 diff --git a/k8s/dockerfiles/managent-dockerfile b/k8s/dockerfiles/managent-dockerfile index 7338f094..b36b9eb1 100644 --- a/k8s/dockerfiles/managent-dockerfile +++ b/k8s/dockerfiles/managent-dockerfile @@ -1,6 +1,6 @@ # 基础镜像 -FROM 172.20.32.187/ci4s/openjdk:8u162 -#FROM 172.20.32.187/ci4s/openjdk-dvc:2024829 +#FROM 172.20.32.187/ci4s/openjdk:8u162 +FROM 172.20.32.187/ci4s/openjdk-dvc:2024829 # author MAINTAINER ruoyi diff --git a/k8s/template-yaml/deploy/k8s-7management.yaml b/k8s/template-yaml/deploy/k8s-7management.yaml index d92c2d68..db233ae0 100644 --- a/k8s/template-yaml/deploy/k8s-7management.yaml +++ b/k8s/template-yaml/deploy/k8s-7management.yaml @@ -15,10 +15,14 @@ spec: spec: containers: - name: ci4s-management-platform - image: 172.20.32.187/ci4s/managent:202406121003 + image: 172.20.32.187/ci4s/ci4s-managent:202409181153 ports: - containerPort: 9213 - + env: + - name: http_proxy + value: "http://172.20.32.253:3128" + - name: https_proxy + value: "http://172.20.32.253:3128" --- apiVersion: v1 kind: Service From d429a915eb7e19c3724ea9d2d289e4b7b7482449 Mon Sep 17 00:00:00 2001 From: somunslotus Date: Wed, 18 Sep 2024 12:52:50 +0800 Subject: [PATCH 4/4] x --- k8s/template-yaml/deploy/k8s-7management.yaml | 2 +- k8s/template-yaml/k8s-7management.yaml | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/k8s/template-yaml/deploy/k8s-7management.yaml b/k8s/template-yaml/deploy/k8s-7management.yaml index db233ae0..7ad00856 100644 --- a/k8s/template-yaml/deploy/k8s-7management.yaml +++ b/k8s/template-yaml/deploy/k8s-7management.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: ci4s-management-platform - image: 172.20.32.187/ci4s/ci4s-managent:202409181153 + image: 172.20.32.187/ci4s/ci4s-managent:202409181159 ports: - containerPort: 9213 env: diff --git a/k8s/template-yaml/k8s-7management.yaml b/k8s/template-yaml/k8s-7management.yaml index 222eb354..8e7c69c6 100644 --- a/k8s/template-yaml/k8s-7management.yaml +++ b/k8s/template-yaml/k8s-7management.yaml @@ -18,11 +18,6 @@ spec: image: ${k8s-7management-image} ports: - containerPort: 9213 - env: - - name: http_proxy - value: "http://172.20.32.253:3128" - - name: https_proxy - value: "http://172.20.32.253:3128" --- apiVersion: v1 kind: Service