Browse Source

[bug] 修改算法管理和算法任务部分的bug

zishang 3 months ago
parent
commit
fcc40625a1

+ 5 - 2
src/main/java/io/renren/common/utils/DockerClientUtils.java

@@ -32,10 +32,10 @@ public class DockerClientUtils {
     /**
      * Description:创建dockerClient
      */
-    public void createDockerClient(){
+    public static void createDockerClient(){
         try {
             System.out.println("初始化docker连接:"+dockerUrl);
-            this.docker= DefaultDockerClient.builder().uri(URI.create(dockerUrl))
+            docker= DefaultDockerClient.builder().uri(URI.create(dockerUrl))
                     .dockerCertificates(new DockerCertificates(Paths.get(docker_ca)))
                     .build();
         }catch (DockerCertificateException e){
@@ -104,6 +104,9 @@ public class DockerClientUtils {
                 .memory(memory)
                 .cpusetCpus(setCpus)
                 .build();
+        if (docker == null) {
+            createDockerClient();
+        }
         ContainerCreation container=docker.createContainer(ContainerConfig.builder().image(imageName).hostConfig(hostConfig).exposedPorts("6006")
 
                 .env("PYTHONPATH=$PYTHONPATH:/opt/"+filePath).tty(true).openStdin(true).attachStdin(true)

+ 1 - 1
src/main/java/io/renren/common/utils/FTPUtils.java

@@ -77,7 +77,7 @@ public class FTPUtils {
      * 检查连接是否建立,如何没有则重新获取链接
      */
     private static void checkIsConnect() {
-        if (!sftp.isConnected()) {
+        if (sftp == null || !sftp.isConnected()) {
             initFTPUtil();
         }
     }

+ 3 - 1
src/main/java/io/renren/common/utils/ToEnglish.java

@@ -1,11 +1,13 @@
 package io.renren.common.utils;
 
+import cn.hutool.core.util.StrUtil;
 import net.sourceforge.pinyin4j.PinyinHelper;
 import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
 import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
 import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
 import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
 import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
+import org.apache.shiro.util.StringUtils;
 
 public class ToEnglish {
     /**
@@ -41,7 +43,7 @@ public class ToEnglish {
             e.printStackTrace();
 //    		Log.v(TAG, "BadHanyuPinyinOutputFormatCombination");
         }
-        return StringUtils.strSpecialFilter(output) ;
+        return output ;
     }
 
 }

+ 6 - 6
src/main/java/io/renren/modules/sys/controller/algs/algTrainController.java

@@ -236,8 +236,8 @@ public class algTrainController {
 
         //完成训练后,将任务状态改为已结束,并保存结束时间
         algTrain.setMissStatus((byte) 3);
-
         //将对应版本训练状态改为已训练
+        algTrain.setHasRun(1);
         /*Version version=versionService.getById(algTrain.getVersionId());
         version.setVersionStatus((byte) 1);
         versionService.update(version);*/
@@ -263,11 +263,11 @@ public class algTrainController {
                 saveTensorboardFile(algorithmTrainingId);
             }
         }*/
-        try {
-            saveTensorboardFile(algorithmTrainingId);
-        }catch (Exception e){
-            throw e;
-        }
+//        try {
+//            saveTensorboardFile(algorithmTrainingId);
+//        }catch (Exception e){
+//            throw e;
+//        }
         return R.ok();
     }
     /**

+ 9 - 5
src/main/java/io/renren/modules/sys/controller/algs/algsController.java

@@ -193,10 +193,14 @@ public class algsController{
                 if (DataSetType.DIR_DATASET.getClassificationName().equals(category.getCategoryName())) {
                     MinIoUtils.copyFolder("algorithm", "alg"+algId+"/", DataSetType.STATIC_DATASET.getBucketName(), dataSet.getDatasetName() + "/");
                 } else {
+//                    MinIoUtils.copyFile("algorithm",
+//                                        "alg"+algId+"/version"+versionService.getMaxId()+"/"+ dataSet.getDatasetName()+".csv",
+//                                                     DataSetType.STATIC_DATASET.getBucketName(),
+//                                      dataSet.getDatasetName()+".csv");
                     MinIoUtils.copyFile("algorithm",
-                                        "alg"+algId+"/version"+versionService.getMaxId()+"/"+ dataSet.getDatasetName()+".csv",
-                                                     DataSetType.STATIC_DATASET.getBucketName(),
-                                      dataSet.getDatasetName()+".csv");
+                            "alg"+algId+"/version"+versionService.getMaxId()+"/"+ dataSet.getDatasetName(),
+                            DataSetType.STATIC_DATASET.getBucketName(),
+                            dataSet.getDatasetName());
                 }
             }
         }
@@ -204,9 +208,9 @@ public class algsController{
         if (!dataSetsDy.isEmpty()) {
             for (DataSetDy dataSetDy : dataSetsDy) {
                 MinIoUtils.copyFile("algorithm",
-                                    "alg"+algId+"/version"+versionService.getMaxId()+"/"+ dataSetDy.getDatasetName()+".csv",
+                                    "alg"+algId+"/version"+versionService.getMaxId()+"/"+ dataSetDy.getDatasetName(),
                                                  DataSetType.DYNAMIC_DATASET.getBucketName(),
-                                  dataSetDy.getDatasetName()+".csv");
+                                  dataSetDy.getDatasetName());
             }
         }
 //        if(dataSetsString.length()!=0){

+ 2 - 0
src/main/java/io/renren/modules/sys/entity/algs/AlgTrain.java

@@ -37,4 +37,6 @@ public class AlgTrain {
     private String runfileName;
 
     private String ipAddress;
+
+    private Integer hasRun;
 }

+ 2 - 0
src/main/java/io/renren/modules/sys/entity/algs/AlgTrain_Vo.java

@@ -41,4 +41,6 @@ public class AlgTrain_Vo {
     private String runfileName;
 
     private String ipAddress;
+
+    private Integer hasRun;
 }

+ 15 - 4
src/main/resources/mapper/sys/algs/AlgTrainMapper.xml

@@ -16,10 +16,11 @@
     <result column="container_id" jdbcType="VARCHAR" property="containerId" />
     <result column="runfile_name" jdbcType="VARCHAR" property="runfileName" />
     <result column="ip_address" jdbcType="VARCHAR" property="ipAddress" />
+    <result column="has_run" jdbcType="INTEGER" property="hasRun" />
   </resultMap>
   <sql id="Base_Column_List">
     algorithm_training_id, miss_name, alg_frame_id, category_id, miss_status, miss_creation_time, miss_stop_time, remark,
-    uid, algorithm_id, version_id, container_id, runfile_name, ip_address
+    uid, algorithm_id, version_id, container_id, runfile_name, ip_address, has_run
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     select 
@@ -41,11 +42,11 @@
     insert into algorithm_training (algorithm_training_id, miss_name, alg_frame_id, category_id,
       miss_status, miss_creation_time, miss_stop_time, remark,
       uid, algorithm_id, version_id, 
-      container_id,runfile_name,ip_address)
+      container_id,runfile_name,ip_address, has_run)
     values (#{algorithmTrainingId,jdbcType=BIGINT}, #{missName,jdbcType=VARCHAR}, #{algFrameId,jdbcType=BIGINT}, #{categoryId,jdbcType=BIGINT},
       #{missStatus,jdbcType=TINYINT}, #{missCreationTime,jdbcType=TIMESTAMP}, #{missStopTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR},
       #{uid,jdbcType=BIGINT}, #{algorithmId,jdbcType=BIGINT}, #{versionId,jdbcType=BIGINT}, 
-      #{containerId,jdbcType=VARCHAR},#{runfileName,jdbcType=VARCHAR},#{ipAddress,jdbcType=VARCHAR})
+      #{containerId,jdbcType=VARCHAR},#{runfileName,jdbcType=VARCHAR},#{ipAddress,jdbcType=VARCHAR}, #{hasRun,jdbcType=INTEGER})
   </insert>
   <insert id="insertSelective" parameterType="io.renren.modules.sys.entity.algs.AlgTrain">
     insert into algorithm_training
@@ -92,6 +93,9 @@
       <if test="ipAddress != null">
         ip_address,
       </if>
+      <if test="hasRun != null">
+        has_run,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="algorithmTrainingId != null">
@@ -136,6 +140,9 @@
       <if test="ipAddress != null">
         #{ipAddress,jdbcType=VARCHAR},
       </if>
+      <if test="hasRun != null">
+        #{hasRun,jdbcType=INTEGER},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="io.renren.modules.sys.entity.algs.AlgTrain">
@@ -180,6 +187,9 @@
       <if test="ipAddress !=null">
         ip_address = #{ipAddress,jdbcType=VARCHAR},
       </if>
+      <if test="hasRun !=null">
+        has_run = #{hasRun,jdbcType=INTEGER},
+      </if>
     </set>
     where algorithm_training_id = #{algorithmTrainingId,jdbcType=BIGINT}
   </update>
@@ -197,7 +207,8 @@
       version_id = #{versionId,jdbcType=BIGINT},
       container_id = #{containerId,jdbcType=VARCHAR},
       runfile_name=#{runfileName,jdbcType=VARCHAR},
-      ip_address = #{ipAddress,jdbcType=VARCHAR}
+      ip_address = #{ipAddress,jdbcType=VARCHAR},
+      has_run = #{hasRun,jdbcType=INTEGER}
     where algorithm_training_id = #{algorithmTrainingId,jdbcType=BIGINT}
   </update>
 </mapper>