tangzhankun commented on a change in pull request #135: SUBMARINE-321. Add 
JobManager and SubmitterManager components
URL: https://github.com/apache/submarine/pull/135#discussion_r361890676
 
 

 ##########
 File path: 
submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sJobSubmitter.java
 ##########
 @@ -29,29 +34,67 @@
 import io.kubernetes.client.models.V1DeleteOptionsBuilder;
 import io.kubernetes.client.util.ClientBuilder;
 import io.kubernetes.client.util.KubeConfig;
+import org.apache.submarine.server.api.JobSubmitter;
+import org.apache.submarine.server.api.exception.UnsupportedJobTypeException;
+import org.apache.submarine.server.api.job.Job;
+import org.apache.submarine.server.api.spec.JobSpec;
 import org.apache.submarine.server.submitter.k8s.model.CustomResourceJob;
 import org.apache.submarine.server.submitter.k8s.model.CustomResourceJobList;
+import org.apache.submarine.server.submitter.k8s.model.MLJob;
+import org.apache.submarine.server.submitter.k8s.parser.JobSpecParser;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.FileReader;
-import java.io.IOException;
-
 /**
  * JobSubmitter for Kubernetes Cluster.
  */
-// TODO(jiwq): It should implement the JobSubmitter interface
-public class K8sJobSubmitter {
+public class K8sJobSubmitter implements JobSubmitter {
   private final Logger LOG = LoggerFactory.getLogger(K8sJobSubmitter.class);
 
+  /**
+   * Key: kind of CRD, such as TFJob/PyTorchJob
+   * Value: the CRD api with version
+   */
+  private Map<String, String> supportedCRDMap;
+
   public K8sJobSubmitter(String confPath) throws IOException {
     ApiClient client =
         ClientBuilder.kubeconfig(KubeConfig.loadKubeConfig(new 
FileReader(confPath))).build();
     Configuration.setDefaultApiClient(client);
   }
 
-  public String submitJob(K8sJobRequest request) {
-    return "job_id";
+  @Override
+  public void initialize() {
+    supportedCRDMap = new HashMap<>();
+    supportedCRDMap.put("TFJob", "kubeflow.org/v1");
+  }
+
+  @Override
+  public String getSubmitterType() {
+    return "k8s";
+  }
+
+  @Override
+  public Job submitJob(JobSpec jobSpec) throws UnsupportedJobTypeException {
+    if (!supportedCRDMap.containsKey(jobSpec.getSubmitterSpec().getType())) {
+      throw new UnsupportedJobTypeException();
+    }
+
+    Job job = new Job();
 
 Review comment:
   Why not using JobManager to submit this job? If I understand correctly, the 
job manager is the job submittion entry?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to