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

ykinash pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git


The following commit(s) were added to refs/heads/develop by this push:
     new 4a87d1b  [DEVELOP] -- GPU fix
4a87d1b is described below

commit 4a87d1b41523b80a10271d8fad24661e29a054a8
Author: KinashYurii <[email protected]>
AuthorDate: Tue May 25 10:48:57 2021 +0300

    [DEVELOP] -- GPU fix
---
 .../service/impl/InfrastructureTemplateServiceImpl.java     | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git 
a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/InfrastructureTemplateServiceImpl.java
 
b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/InfrastructureTemplateServiceImpl.java
index 03c56e5..4508397 100644
--- 
a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/InfrastructureTemplateServiceImpl.java
+++ 
b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/InfrastructureTemplateServiceImpl.java
@@ -40,6 +40,7 @@ import 
com.epam.datalab.dto.base.computational.FullComputationalTemplate;
 import com.epam.datalab.dto.imagemetadata.ComputationalMetadataDTO;
 import com.epam.datalab.dto.imagemetadata.ComputationalResourceShapeDto;
 import com.epam.datalab.dto.imagemetadata.ExploratoryMetadataDTO;
+import com.epam.datalab.dto.imagemetadata.ImageMetadataDTO;
 import com.epam.datalab.exceptions.DatalabException;
 import com.epam.datalab.rest.client.RESTService;
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -212,8 +213,7 @@ public class InfrastructureTemplateServiceImpl implements 
InfrastructureTemplate
                                                                 CloudProvider 
cloudProvider, String projectName) {
 
         DataEngineType dataEngineType = 
DataEngineType.fromDockerImageName(metadataDTO.getImage());
-        gpuDAO.getGPUByProjectName(projectName).ifPresent(edgeGPU -> 
metadataDTO.setComputationGPU(edgeGPU.getGpus()));
-
+        addGpu(metadataDTO, projectName);
         if (dataEngineType == DataEngineType.CLOUD_SERVICE) {
             return getCloudFullComputationalTemplate(metadataDTO, 
cloudProvider);
         } else if (dataEngineType == DataEngineType.SPARK_STANDALONE) {
@@ -227,10 +227,15 @@ public class InfrastructureTemplateServiceImpl implements 
InfrastructureTemplate
         }
     }
 
-    private void addGpu(ExploratoryMetadataDTO e, String projectName) {
+    private void addGpu(ImageMetadataDTO e, String projectName) {
         log.info("Trying to read GPU from DB for {}", projectName);
         try {
-            gpuDAO.getGPUByProjectName(projectName).ifPresent(edgeGPU -> 
e.setComputationGPU(edgeGPU.getGpus()));
+            if (e instanceof ExploratoryMetadataDTO) {
+                gpuDAO.getGPUByProjectName(projectName).ifPresent(edgeGPU ->
+                        ((ExploratoryMetadataDTO) 
e).setComputationGPU(edgeGPU.getGpus()));
+            } else
+                gpuDAO.getGPUByProjectName(projectName).ifPresent(edgeGPU ->
+                        ((ComputationalMetadataDTO) 
e).setComputationGPU(edgeGPU.getGpus()));
         } catch (Exception ex) {
             log.info(ex.getMessage());
         }

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

Reply via email to