Search in sources :

Example 11 with PythonDep

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

the class LibraryController method persistAndMarkImmutable.

/**
 * For each library in the conda environment figure out if it should be marked as unmutable.
 *
 * @param pyDepsInImage
 * @return
 */
public Collection<PythonDep> persistAndMarkImmutable(Collection<PythonDep> pyDepsInImage) {
    Collection<PythonDep> deps = new ArrayList();
    for (PythonDep dep : pyDepsInImage) {
        String libraryName = dep.getDependency();
        if (settings.getImmutablePythonLibraryNames().contains(libraryName)) {
            PythonDep pyDep = libraryFacade.getOrCreateDep(dep.getRepoUrl(), dep.getInstallType(), libraryName, dep.getVersion(), true, true);
            deps.add(pyDep);
        } else {
            PythonDep pyDep = libraryFacade.getOrCreateDep(dep);
            deps.add(pyDep);
        }
    }
    return deps;
}
Also used : ArrayList(java.util.ArrayList) PythonDep(io.hops.hopsworks.persistence.entity.python.PythonDep)

Example 12 with PythonDep

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

the class LibraryController method parseCondaList.

public Collection<PythonDep> parseCondaList(String condaListStr) throws ServiceException {
    Collection<PythonDep> deps = new ArrayList<>();
    String[] lines = condaListStr.split(System.getProperty("line.separator"));
    for (int i = 3; i < lines.length; i++) {
        String line = lines[i];
        String[] split = line.split(" +");
        String libraryName = split[0];
        String version = split[1];
        String channel = "conda";
        if (split.length > 3) {
            channel = split[3].trim().isEmpty() ? channel : split[3];
        }
        CondaInstallType installType = CondaInstallType.PIP;
        if (!(channel.equals("pypi"))) {
            installType = CondaInstallType.CONDA;
        }
        AnacondaRepo repo = libraryFacade.getRepo(channel, true);
        boolean cannotBeRemoved = channel.equals("default");
        PythonDep pyDep = libraryFacade.getOrCreateDep(repo, installType, libraryName, version, false, cannotBeRemoved);
        deps.add(pyDep);
    }
    return deps;
}
Also used : AnacondaRepo(io.hops.hopsworks.persistence.entity.python.AnacondaRepo) ArrayList(java.util.ArrayList) PythonDep(io.hops.hopsworks.persistence.entity.python.PythonDep) CondaInstallType(io.hops.hopsworks.persistence.entity.python.CondaInstallType)

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