pingsutw commented on a change in pull request #767:
URL: https://github.com/apache/submarine/pull/767#discussion_r729932448



##########
File path: 
submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sSubmitter.java
##########
@@ -565,6 +583,79 @@ public ServeResponse deleteServe(ServeRequest spec)
     }
   }
 
+  public void watchExperiment() throws ApiException{
+
+    Watch<MLJob> watchTF = Watch.createWatch(
+              client,
+              api.listNamespacedCustomObjectCall(
+                      TFJob.CRD_TF_GROUP_V1,
+                      TFJob.CRD_TF_VERSION_V1,
+                      getServerNamespace(),
+                      TFJob.CRD_TF_PLURAL_V1,
+                      "true",
+                      null,
+                      null,
+                      null,
+                      null,
+                      Boolean.TRUE,
+                      null,
+                      null
+              ),
+              new TypeToken<Watch.Response<MLJob>>() {}.getType()
+      );
+
+    Watch<MLJob> watchPytorch = Watch.createWatch(
+            client,
+            api.listNamespacedCustomObjectCall(
+                    PyTorchJob.CRD_PYTORCH_GROUP_V1,
+                    PyTorchJob.CRD_PYTORCH_VERSION_V1,
+                    getServerNamespace(),
+                    PyTorchJob.CRD_PYTORCH_PLURAL_V1,
+                    "true",
+                    null,
+                    null,
+                    null,
+                    null,
+                    Boolean.TRUE,
+                    null,
+                    null
+            ),
+            new TypeToken<Watch.Response<MLJob>>() {}.getType()
+    );
+
+    ExecutorService experimentThread = Executors.newFixedThreadPool(2);
+
+    experimentThread.execute(new Runnable() {
+        @Override
+        public void run() {
+            try {
+              LOG.info("Start watching on TFJobs...");
+              for (Watch.Response<MLJob> experiment : watchTF) {
+                LOG.info("{}", experiment.object.getStatus());
+              }
+            } finally {
+              LOG.info("WATCH TFJob END");
+              throw new RuntimeException();
+            }
+        }
+    });
+
+    experimentThread.execute(new Runnable() {
+        @Override
+        public void run() {
+            try {
+              LOG.info("Start watching on PytorchJobs...");
+              for (Watch.Response<MLJob> experiment : watchPytorch) {
+                LOG.info("{}", experiment.object.getStatus());
+              }
+            } finally {
+              LOG.info("WATCH PytorchJob END");
+              throw new RuntimeException();

Review comment:
       ```suggestion
                 watchPytorch.close();
                 throw new RuntimeException();
   ```

##########
File path: 
submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sSubmitter.java
##########
@@ -565,6 +583,79 @@ public ServeResponse deleteServe(ServeRequest spec)
     }
   }
 
+  public void watchExperiment() throws ApiException{
+
+    Watch<MLJob> watchTF = Watch.createWatch(
+              client,
+              api.listNamespacedCustomObjectCall(
+                      TFJob.CRD_TF_GROUP_V1,
+                      TFJob.CRD_TF_VERSION_V1,
+                      getServerNamespace(),
+                      TFJob.CRD_TF_PLURAL_V1,
+                      "true",
+                      null,
+                      null,
+                      null,
+                      null,
+                      Boolean.TRUE,
+                      null,
+                      null
+              ),
+              new TypeToken<Watch.Response<MLJob>>() {}.getType()
+      );
+
+    Watch<MLJob> watchPytorch = Watch.createWatch(
+            client,
+            api.listNamespacedCustomObjectCall(
+                    PyTorchJob.CRD_PYTORCH_GROUP_V1,
+                    PyTorchJob.CRD_PYTORCH_VERSION_V1,
+                    getServerNamespace(),
+                    PyTorchJob.CRD_PYTORCH_PLURAL_V1,
+                    "true",
+                    null,
+                    null,
+                    null,
+                    null,
+                    Boolean.TRUE,
+                    null,
+                    null
+            ),
+            new TypeToken<Watch.Response<MLJob>>() {}.getType()
+    );
+
+    ExecutorService experimentThread = Executors.newFixedThreadPool(2);
+
+    experimentThread.execute(new Runnable() {
+        @Override
+        public void run() {
+            try {
+              LOG.info("Start watching on TFJobs...");
+              for (Watch.Response<MLJob> experiment : watchTF) {
+                LOG.info("{}", experiment.object.getStatus());
+              }
+            } finally {
+              LOG.info("WATCH TFJob END");
+              throw new RuntimeException();

Review comment:
       ```suggestion
                 watchTF.close();
                 throw new RuntimeException();
   ```

##########
File path: 
submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sSubmitter.java
##########
@@ -565,6 +584,79 @@ public ServeResponse deleteServe(ServeRequest spec)
     }
   }
 
+  public void watchExperiment() throws ApiException{

Review comment:
       okay 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to