This is an automated email from the ASF dual-hosted git repository. ofuks pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/develop by this push: new da179de [DLAB-1995] Updated library groups for notebooks and compute new b91a360 Merge remote-tracking branch 'origin/develop' into develop da179de is described below commit da179dee3f328f19563542eacd6c83fde8ea8db7 Author: Oleh Fuks <olegfuk...@gmail.com> AuthorDate: Wed Aug 19 12:57:21 2020 +0300 [DLAB-1995] Updated library groups for notebooks and compute --- .../service/impl/LibraryServiceImpl.java | 52 ++++++++++++---------- .../service/impl/LibraryServiceImplTest.java | 12 ++--- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/LibraryServiceImpl.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/LibraryServiceImpl.java index 9b53e47..852ee74 100644 --- a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/LibraryServiceImpl.java +++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/LibraryServiceImpl.java @@ -29,6 +29,7 @@ import com.epam.dlab.backendapi.dao.BaseDAO; import com.epam.dlab.backendapi.dao.ExploratoryDAO; import com.epam.dlab.backendapi.dao.ExploratoryLibDAO; import com.epam.dlab.backendapi.domain.EndpointDTO; +import com.epam.dlab.backendapi.domain.NotebookTemplate; import com.epam.dlab.backendapi.domain.RequestId; import com.epam.dlab.backendapi.resources.dto.LibInfoRecord; import com.epam.dlab.backendapi.resources.dto.LibKey; @@ -67,9 +68,11 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import static com.epam.dlab.backendapi.domain.AuditActionEnum.INSTALL_LIBS; +import static com.epam.dlab.backendapi.domain.AuditResourceTypeEnum.COMPUTE; +import static com.epam.dlab.backendapi.domain.AuditResourceTypeEnum.NOTEBOOK; import static com.epam.dlab.backendapi.domain.NotebookTemplate.DEEP_LEARNING; import static com.epam.dlab.backendapi.domain.NotebookTemplate.JUPYTER; -import static com.epam.dlab.backendapi.domain.NotebookTemplate.JUPYTER_LAB; import static com.epam.dlab.backendapi.domain.NotebookTemplate.RSTUDIO; import static com.epam.dlab.backendapi.domain.NotebookTemplate.TENSOR; import static com.epam.dlab.backendapi.domain.NotebookTemplate.TENSOR_RSTUDIO; @@ -80,9 +83,6 @@ import static com.epam.dlab.dto.LibraryGroups.GROUP_OTHERS; import static com.epam.dlab.dto.LibraryGroups.GROUP_PIP2; import static com.epam.dlab.dto.LibraryGroups.GROUP_PIP3; import static com.epam.dlab.dto.LibraryGroups.GROUP_R_PKG; -import static com.epam.dlab.backendapi.domain.AuditActionEnum.INSTALL_LIBS; -import static com.epam.dlab.backendapi.domain.AuditResourceTypeEnum.NOTEBOOK; -import static com.epam.dlab.backendapi.domain.AuditResourceTypeEnum.COMPUTE; @Slf4j @@ -149,18 +149,19 @@ public class LibraryServiceImpl implements LibraryService { return libInfoRecords; } - @Audit(action = INSTALL_LIBS, type = COMPUTE) - @Override - public String installComputationalLibs(@User UserInfo ui, @Project String project, String expName, @ResourceName String compName, List<LibInstallDTO> libs, @Info String auditInfo) { - final UserInstanceDTO userInstance = exploratoryDAO.fetchExploratoryFields(ui.getName(), project, expName, compName); - EndpointDTO endpointDTO = endpointService.get(userInstance.getEndpoint()); - final String uuid = provisioningService.post(endpointDTO.getUrl() + ComputationalAPI.COMPUTATIONAL_LIB_INSTALL, - ui.getAccessToken(), - toComputationalLibraryInstallDto(ui, project, expName, compName, libs, userInstance, endpointDTO), - String.class); - requestId.put(ui.getName(), uuid); - return uuid; - } + @Audit(action = INSTALL_LIBS, type = COMPUTE) + @Override + public String installComputationalLibs(@User UserInfo ui, @Project String project, String expName, @ResourceName String compName, + List<LibInstallDTO> libs, @Info String auditInfo) { + final UserInstanceDTO userInstance = exploratoryDAO.fetchExploratoryFields(ui.getName(), project, expName, compName); + EndpointDTO endpointDTO = endpointService.get(userInstance.getEndpoint()); + final String uuid = provisioningService.post(endpointDTO.getUrl() + ComputationalAPI.COMPUTATIONAL_LIB_INSTALL, + ui.getAccessToken(), + toComputationalLibraryInstallDto(ui, project, expName, compName, libs, userInstance, endpointDTO), + String.class); + requestId.put(ui.getName(), uuid); + return uuid; + } @Audit(action = INSTALL_LIBS, type = NOTEBOOK) @Override @@ -178,14 +179,13 @@ public class LibraryServiceImpl implements LibraryService { public List<String> getExploratoryLibGroups(UserInfo userInfo, String projectName, String exploratoryName) { UserInstanceDTO userInstanceDTO = exploratoryDAO.fetchExploratoryFields(userInfo.getName(), projectName, exploratoryName); final String templateName = userInstanceDTO.getTemplateName(); - List<LibraryGroups> groups = new ArrayList<>(Arrays.asList(GROUP_JAVA, GROUP_OS_PKG)); + List<LibraryGroups> groups = new ArrayList<>(Arrays.asList(GROUP_PIP3, GROUP_OTHERS, GROUP_R_PKG, GROUP_OS_PKG)); - if (Arrays.asList(JUPYTER.getName(), JUPYTER_LAB.getName(), ZEPPELIN.getName(), DEEP_LEARNING.getName(), TENSOR.getName(), TENSOR_RSTUDIO.getName(), - RSTUDIO.getName()).contains(templateName)) { - groups.addAll(Arrays.asList(GROUP_PIP2, GROUP_PIP3, GROUP_OTHERS)); + if (isTemplateGroup(templateName, Stream.of(JUPYTER, ZEPPELIN, DEEP_LEARNING, TENSOR))) { + groups.addAll(Arrays.asList(GROUP_PIP2, GROUP_JAVA)); } - if (Arrays.asList(JUPYTER.getName(), JUPYTER_LAB.getName(), ZEPPELIN.getName(), TENSOR_RSTUDIO.getName(), RSTUDIO.getName()).contains(templateName)) { - groups.add(GROUP_R_PKG); + if (isTemplateGroup(templateName, Stream.of(RSTUDIO, TENSOR_RSTUDIO))) { + groups.add(GROUP_PIP2); } return groups @@ -196,11 +196,17 @@ public class LibraryServiceImpl implements LibraryService { @Override public List<String> getComputeLibGroups() { - return Stream.of(GROUP_JAVA, GROUP_OS_PKG, GROUP_PIP2, GROUP_PIP3, GROUP_OTHERS) + return Stream.of(GROUP_PIP3, GROUP_OTHERS, GROUP_R_PKG, GROUP_OS_PKG, GROUP_JAVA) .map(LibraryGroups::toString) .collect(Collectors.toList()); } + private boolean isTemplateGroup(String templateName, Stream<NotebookTemplate> templateStream) { + return templateStream + .map(NotebookTemplate::getName) + .anyMatch(name -> name.equals(templateName)); + } + private LibraryInstallDTO toExploratoryLibraryInstallDto(UserInfo userInfo, String project, String exploratoryName, List<LibInstallDTO> libs, UserInstanceDTO userInstance, EndpointDTO endpointDTO) { final List<LibInstallDTO> libsToInstall = libs.stream() diff --git a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/LibraryServiceImplTest.java b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/LibraryServiceImplTest.java index 9c3a4cb..dd61462 100644 --- a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/LibraryServiceImplTest.java +++ b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/impl/LibraryServiceImplTest.java @@ -357,32 +357,32 @@ public class LibraryServiceImplTest { @Test public void getComputeLibGroups() { - List<Object> computeGroups = Arrays.asList(GROUP_JAVA, GROUP_OS_PKG, GROUP_PIP2, GROUP_PIP3, GROUP_OTHERS); + List<Object> computeGroups = Arrays.asList(GROUP_PIP3, GROUP_OTHERS, GROUP_R_PKG, GROUP_OS_PKG, GROUP_JAVA); List<String> computeGroupsResult = libraryService.getComputeLibGroups(); - assertEquals("lists are not equals", computeGroups, computeGroupsResult); + assertEquals("lists are not equal", computeGroups, computeGroupsResult); } @Test public void getExploratoryJupyterLibGroups() { - List<Object> exploratoryGroups = Arrays.asList(GROUP_JAVA, GROUP_OS_PKG, GROUP_PIP2, GROUP_PIP3, GROUP_OTHERS, GROUP_R_PKG); + List<Object> exploratoryGroups = Arrays.asList(GROUP_PIP3, GROUP_OTHERS, GROUP_R_PKG, GROUP_OS_PKG, GROUP_PIP2, GROUP_JAVA); when(exploratoryDAO.fetchExploratoryFields(anyString(), anyString(), anyString())).thenReturn(getJupyterUserInstanceDtoForLibGroups()); List<String> exploratoryGroupsResult = libraryService.getExploratoryLibGroups(getUser(), PROJECT, EXPLORATORY_NAME); - assertEquals("lists are not equals", exploratoryGroups, exploratoryGroupsResult); + assertEquals("lists are not equal", exploratoryGroups, exploratoryGroupsResult); verify(exploratoryDAO).fetchExploratoryFields(USER, PROJECT, EXPLORATORY_NAME); } @Test public void getExploratoryRstudioLibGroups() { - List<Object> exploratoryGroups = Arrays.asList(GROUP_JAVA, GROUP_OS_PKG, GROUP_PIP2, GROUP_PIP3, GROUP_OTHERS, GROUP_R_PKG); + List<Object> exploratoryGroups = Arrays.asList(GROUP_PIP3, GROUP_OTHERS, GROUP_R_PKG, GROUP_OS_PKG, GROUP_PIP2); when(exploratoryDAO.fetchExploratoryFields(anyString(), anyString(), anyString())).thenReturn(getRstudioUserInstanceDtoForLibGroups()); List<String> exploratoryGroupsResult = libraryService.getExploratoryLibGroups(getUser(), PROJECT, EXPLORATORY_NAME); - assertEquals("lists are not equals", exploratoryGroups, exploratoryGroupsResult); + assertEquals("lists are not equal", exploratoryGroups, exploratoryGroupsResult); verify(exploratoryDAO).fetchExploratoryFields(USER, PROJECT, EXPLORATORY_NAME); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org For additional commands, e-mail: commits-h...@dlab.apache.org