Search in sources :

Example 6 with PythonDep

use of io.hops.hopsworks.persistence.entity.python.PythonDep in project hopsworks by logicalclocks.

the class LibrarySearchBuilder method build.

public LibrarySearchDTO build(UriInfo uriInfo, List<LibraryVersionDTO> libVersions, String foundLibrary, Collection<PythonDep> installedDeps, String url) {
    LibrarySearchDTO dto = new LibrarySearchDTO();
    if (url != null) {
        uri(dto, uriInfo, foundLibrary, url);
    } else {
        uri(dto, uriInfo, foundLibrary);
    }
    dto.setLibrary(foundLibrary);
    dto.setVersions(libVersions);
    for (PythonDep pd : installedDeps) {
        if (pd.getDependency().equalsIgnoreCase(foundLibrary)) {
            dto.setStatus("Installed");
        }
    }
    return dto;
}
Also used : PythonDep(io.hops.hopsworks.persistence.entity.python.PythonDep)

Example 7 with PythonDep

use of io.hops.hopsworks.persistence.entity.python.PythonDep in project hopsworks by logicalclocks.

the class LibraryFacade method findInstalledPythonDepsByProject.

public CollectionInfo findInstalledPythonDepsByProject(Integer offset, Integer limit, Set<? extends AbstractFacade.FilterBy> filter, Set<? extends AbstractFacade.SortBy> sort, Project project) {
    String queryStr = buildQuery("SELECT p FROM PythonDep p ", filter, sort, ":project MEMBER OF p.projectCollection ");
    String queryCountStr = buildQuery("SELECT COUNT(p.id) FROM PythonDep p ", filter, sort, ":project MEMBER OF p.projectCollection ");
    Query query = em.createQuery(queryStr, PythonDep.class).setParameter("project", project);
    Query queryCount = em.createQuery(queryCountStr, PythonDep.class).setParameter("project", project);
    return findAll(offset, limit, filter, query, queryCount);
}
Also used : TypedQuery(javax.persistence.TypedQuery) Query(javax.persistence.Query) PythonDep(io.hops.hopsworks.persistence.entity.python.PythonDep)

Example 8 with PythonDep

use of io.hops.hopsworks.persistence.entity.python.PythonDep in project hopsworks by logicalclocks.

the class LibraryFacade method getOrCreateDep.

public PythonDep getOrCreateDep(AnacondaRepo repo, CondaInstallType installType, String dependency, String version, boolean persist, boolean preinstalled) {
    TypedQuery<PythonDep> deps = em.createNamedQuery("PythonDep.findUniqueDependency", PythonDep.class);
    deps.setParameter("dependency", dependency);
    deps.setParameter("version", version);
    deps.setParameter("installType", installType);
    deps.setParameter("repoUrl", repo);
    PythonDep dep = null;
    try {
        dep = deps.getSingleResult();
    } catch (NoResultException ex) {
        dep = new PythonDep();
        dep.setRepoUrl(repo);
        dep.setDependency(dependency);
        dep.setVersion(version);
        dep.setPreinstalled(preinstalled);
        dep.setInstallType(installType);
        if (persist) {
            em.persist(dep);
            em.flush();
        }
    }
    return dep;
}
Also used : PythonDep(io.hops.hopsworks.persistence.entity.python.PythonDep) NoResultException(javax.persistence.NoResultException)

Example 9 with PythonDep

use of io.hops.hopsworks.persistence.entity.python.PythonDep in project hopsworks by logicalclocks.

the class CommandsController method updateCondaCommandStatus.

public void updateCondaCommandStatus(int commandId, CondaStatus condaStatus, String arg, CondaOp opType, String errorMessage) throws ServiceException, ProjectException {
    CondaCommands cc = condaCommandFacade.findCondaCommand(commandId);
    if (cc != null) {
        if (condaStatus == CondaStatus.SUCCESS) {
            // remove completed commands
            condaCommandFacade.remove(cc);
            // returned => CondaEnv operation is finished).
            if (CondaOp.isLibraryOp(opType)) {
                Project project = projectFacade.findById(cc.getProjectId().getId()).orElseThrow(() -> new ProjectException(RESTCodes.ProjectErrorCode.PROJECT_NOT_FOUND, Level.FINE, "projectId: " + cc.getProjectId().getId()));
                PythonDep dep = libraryFacade.getOrCreateDep(libraryFacade.getRepo(cc.getChannelUrl(), false), cc.getInstallType(), cc.getLib(), cc.getVersion(), true, false);
                Collection<PythonDep> deps = project.getPythonDepCollection();
                if (isPlaceholderDep(cc, opType) || opType.equals(CondaOp.UNINSTALL)) {
                    deps.remove(dep);
                }
                project.setPythonDepCollection(deps);
                projectFacade.update(project);
                projectFacade.flushEm();
            }
        } else if (condaStatus == CondaStatus.FAILED) {
            cc.setStatus(condaStatus);
            cc.setArg(arg);
            cc.setErrorMsg(errorMessage);
            condaCommandFacade.update(cc);
        } else if (condaStatus == CondaStatus.ONGOING) {
            cc.setStatus(condaStatus);
            condaCommandFacade.update(cc);
        }
    } else {
        LOGGER.log(Level.FINE, "Could not remove CondaCommand with id: {0}", commandId);
    }
}
Also used : ProjectException(io.hops.hopsworks.exceptions.ProjectException) Project(io.hops.hopsworks.persistence.entity.project.Project) CondaCommands(io.hops.hopsworks.persistence.entity.python.CondaCommands) PythonDep(io.hops.hopsworks.persistence.entity.python.PythonDep)

Example 10 with PythonDep

use of io.hops.hopsworks.persistence.entity.python.PythonDep in project hopsworks by logicalclocks.

the class LibraryInstaller method syncBaseLibraries.

public void syncBaseLibraries(CondaCommands cc) throws ServiceException, ServiceDiscoveryException, ProjectException, IOException, PythonException {
    Project project = projectFacade.findById(cc.getProjectId().getId()).orElseThrow(() -> new ProjectException(RESTCodes.ProjectErrorCode.PROJECT_NOT_FOUND, Level.FINE, "projectId: " + cc.getProjectId().getId()));
    String condaListOutput = libraryController.condaList(projectUtils.getFullDockerImageName(project, true));
    Collection<PythonDep> projectDeps = libraryController.parseCondaList(condaListOutput);
    projectDeps = libraryController.persistAndMarkImmutable(projectDeps);
    project = projectFacade.findById(cc.getProjectId().getId()).orElseThrow(() -> new ProjectException(RESTCodes.ProjectErrorCode.PROJECT_NOT_FOUND, Level.FINE, "projectId: " + cc.getProjectId().getId()));
    setPipConflicts(project);
    project.setPythonDepCollection(projectDeps);
    projectFacade.update(project);
    exportEnvironment(project, cc.getUserId(), Utils.getProjectPath(project.getName()) + Settings.PROJECT_PYTHON_ENVIRONMENT_FILE);
}
Also used : ProjectException(io.hops.hopsworks.exceptions.ProjectException) Project(io.hops.hopsworks.persistence.entity.project.Project) PythonDep(io.hops.hopsworks.persistence.entity.python.PythonDep)

Aggregations

PythonDep (io.hops.hopsworks.persistence.entity.python.PythonDep)12 ProjectException (io.hops.hopsworks.exceptions.ProjectException)3 Project (io.hops.hopsworks.persistence.entity.project.Project)3 AnacondaRepo (io.hops.hopsworks.persistence.entity.python.AnacondaRepo)3 CondaCommands (io.hops.hopsworks.persistence.entity.python.CondaCommands)3 ArrayList (java.util.ArrayList)3 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)2 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)2 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)2 ServiceException (io.hops.hopsworks.exceptions.ServiceException)2 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)2 CondaInstallType (io.hops.hopsworks.persistence.entity.python.CondaInstallType)2 Users (io.hops.hopsworks.persistence.entity.user.Users)2 ApiOperation (io.swagger.annotations.ApiOperation)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Strings (com.google.common.base.Strings)1 ServiceDiscoveryException (com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)1 ProjectFacade (io.hops.hopsworks.common.dao.project.ProjectFacade)1 CondaCommandFacade (io.hops.hopsworks.common.dao.python.CondaCommandFacade)1