This is an automated email from the ASF dual-hosted git repository.

byronhsu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new 56bf9c1  SUBMARINE-865. Clean up deleted experiment in mlflow
56bf9c1 is described below

commit 56bf9c16531156a48963f58cd3b5994b31b74b66
Author: jeff-901 <[email protected]>
AuthorDate: Tue Jul 6 16:07:30 2021 +0800

    SUBMARINE-865. Clean up deleted experiment in mlflow
    
    ### What is this PR for?
    When delete an experiment through web GUI, the mlflow param and metric that 
the same experiment creates are not deleted. We need to delete the resources 
concurrently by calling mlflow java API.
    
    ### What type of PR is it?
    Improvement
    
    ### Todos
    
    ### What is the Jira issue?
    https://issues.apache.org/jira/browse/SUBMARINE-865
    
    ### How should this be tested?
    
    ### Screenshots (if appropriate)
    
    ### Questions:
    * Do the license files need updating? No
    * Are there breaking changes for older versions? No
    * Does this need new documentation? No
    
    Author: jeff-901 <[email protected]>
    Author: jeff-901 <[email protected]>
    
    Signed-off-by: byronhsu <[email protected]>
    
    Closes #651 from jeff-901/SUBMARINE-865 and squashes the following commits:
    
    a132206d [jeff-901] clean code in RestApi
    e5c89bbc [jeff-901] move delete to experiment manager
    e491f8cc [jeff-901] delete by mlflow_id
    88daf84c [jeff-901] delete mlflow experiment
---
 submarine-server/server-core/pom.xml                      |  7 +++++++
 .../submarine/server/experiment/ExperimentManager.java    | 15 ++++++++++++++-
 .../apache/submarine/server/rest/ExperimentRestApi.java   |  7 ++++---
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/submarine-server/server-core/pom.xml 
b/submarine-server/server-core/pom.xml
index 4bade8a..70863d7 100644
--- a/submarine-server/server-core/pom.xml
+++ b/submarine-server/server-core/pom.xml
@@ -474,6 +474,13 @@
         </exclusion>
       </exclusions>
     </dependency>
+
+    <dependency>
+      <groupId>org.mlflow</groupId>
+      <artifactId>mlflow-client</artifactId>
+      <version>1.18.0</version>
+    </dependency>
+
   </dependencies>
 
   <build>
diff --git 
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/experiment/ExperimentManager.java
 
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/experiment/ExperimentManager.java
index 6c62a30..fe5757d 100644
--- 
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/experiment/ExperimentManager.java
+++ 
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/experiment/ExperimentManager.java
@@ -21,6 +21,7 @@ package org.apache.submarine.server.experiment;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -48,6 +49,7 @@ import 
org.apache.submarine.server.experiment.database.ExperimentService;
 import org.apache.submarine.server.rest.RestConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.mlflow.tracking.MlflowClient;
 
 /**
  * It's responsible for managing the experiment CRUD and cache them
@@ -59,6 +61,8 @@ public class ExperimentManager {
 
   private final AtomicInteger experimentCounter = new AtomicInteger(0);
 
+  private Optional<org.mlflow.api.proto.Service.Experiment> 
MlflowExperimentOptional;
+  private org.mlflow.api.proto.Service.Experiment MlflowExperiment;
   /**
    * Used to cache the specs by the experiment id.
    * key: the string of experiment id
@@ -222,7 +226,16 @@ public class ExperimentManager {
     experimentService.delete(id);
 
     experiment.rebuild(deletedExperiment);
-    return experiment;
+
+    MlflowClient mlflowClient = new 
MlflowClient("http://submarine-mlflow-service:5000";);
+    try {
+      MlflowExperimentOptional = mlflowClient.getExperimentByName(id);
+      MlflowExperiment = MlflowExperimentOptional.get();
+      String mlflowId = MlflowExperiment.getExperimentId();
+      mlflowClient.deleteExperiment(mlflowId);
+    } finally {
+      return experiment;
+    }
   }
 
   /**
diff --git 
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/rest/ExperimentRestApi.java
 
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/rest/ExperimentRestApi.java
index 588486f..a803de9 100644
--- 
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/rest/ExperimentRestApi.java
+++ 
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/rest/ExperimentRestApi.java
@@ -216,13 +216,14 @@ public class ExperimentRestApi {
               schema = @Schema(implementation = JsonResponse.class))),
           @ApiResponse(responseCode = "404", description = "Experiment not 
found")})
   public Response deleteExperiment(@PathParam(RestConstants.ID) String id) {
+    Experiment experiment;
     try {
-      Experiment experiment = experimentManager.deleteExperiment(id);
-      return new 
JsonResponse.Builder<Experiment>(Response.Status.OK).success(true)
-          .result(experiment).build();
+      experiment = experimentManager.deleteExperiment(id);
     } catch (SubmarineRuntimeException e) {
       return parseExperimentServiceException(e);
     }
+    return new 
JsonResponse.Builder<Experiment>(Response.Status.OK).success(true)
+          .result(experiment).build();
   }
 
   @GET

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to