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;
}
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);
}
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;
}
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);
}
}
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);
}
Aggregations