use of io.hops.hopsworks.persistence.entity.python.CondaCommands in project hopsworks by logicalclocks.
the class LibraryInstaller method getCondaCommandsByProject.
private Map<Project, List<CondaCommands>> getCondaCommandsByProject(List<CondaCommands> condaCommands) {
Map<Project, List<CondaCommands>> condaCommandsByProject = new HashMap<>();
for (CondaCommands condacommand : condaCommands) {
// "REMOVE" command as it needs to be processed even after the project has been deleted
if (condacommand.getOp() != CondaOp.REMOVE && (condacommand.getProjectId() == null || condacommand.getProjectId().getPythonEnvironment() == null)) {
LOG.log(Level.FINEST, "Removing condacommand: " + condacommand);
condaCommandFacade.remove(condacommand);
} else {
Project project = condacommand.getProjectId();
if (!condaCommandsByProject.containsKey(project)) {
condaCommandsByProject.put(project, new ArrayList<>());
}
condaCommandsByProject.get(project).add(condacommand);
}
}
return condaCommandsByProject;
}
use of io.hops.hopsworks.persistence.entity.python.CondaCommands in project hopsworks by logicalclocks.
the class LibraryInstaller method isAlive.
@Timeout
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void isAlive() {
try {
LOG.log(Level.FINE, "isAlive-start: " + System.currentTimeMillis());
registryGCCycles.incrementAndGet();
final List<CondaCommands> allCondaCommandsOngoing = condaCommandFacade.findByStatus(CondaStatus.ONGOING);
// other conda ops
if (registryGCCycles.get() % 10 == 0 && allCondaCommandsOngoing.isEmpty()) {
registryGCCycles.set(0);
// Run registry GC
try {
LOG.log(Level.FINE, "registryGC-start: " + System.currentTimeMillis());
registry.gc();
LOG.log(Level.FINE, "registryGC-stop: " + System.currentTimeMillis());
} catch (Exception ex) {
LOG.log(Level.WARNING, "Could not run conda remove commands", ex);
}
} else {
// Group new commands by project and run in parallel
Map<Project, List<CondaCommands>> allCondaCommandsNewByProject = getCondaCommandsByProject(condaCommandFacade.findByStatus(CondaStatus.NEW));
Map<Project, List<CondaCommands>> allCondaCommandsOngoingByProject = getCondaCommandsByProject(condaCommandFacade.findByStatus(CondaStatus.ONGOING));
LOG.log(Level.FINE, "allCondaCommandsOngoingByProject:" + allCondaCommandsOngoingByProject);
for (Project project : allCondaCommandsNewByProject.keySet()) {
if (!allCondaCommandsOngoingByProject.containsKey(project)) {
try {
executorService.submit(() -> condaCommandHandler(allCondaCommandsNewByProject.get(project)));
} catch (Exception ex) {
LOG.log(Level.WARNING, "Could not run conda commands for project: " + project, ex);
}
} else {
LOG.log(Level.FINE, "Project " + project.getName() + " is already processing a conda command, skipping...");
}
}
}
} finally {
LOG.log(Level.FINE, "isAlive-stop: " + System.currentTimeMillis());
schedule();
}
}
use of io.hops.hopsworks.persistence.entity.python.CondaCommands in project hopsworks by logicalclocks.
the class EnvironmentController method condaEnvironmentOp.
/**
* Asynchronous execution of conda operations
*
* @param op
* @param proj
* @param pythonVersion
* @param arg
*/
private void condaEnvironmentOp(CondaOp op, String pythonVersion, Project proj, Users user, String arg, String environmentFile, Boolean installJupyter) {
if (projectUtils.isReservedProjectName(proj.getName())) {
throw new IllegalStateException("Tried to execute a conda env op on a reserved project name");
}
CondaCommands cc = new CondaCommands(user, op, CondaStatus.NEW, CondaInstallType.ENVIRONMENT, proj, pythonVersion, "", "defaults", new Date(), arg, environmentFile, installJupyter);
condaCommandFacade.save(cc);
}
use of io.hops.hopsworks.persistence.entity.python.CondaCommands in project hopsworks by logicalclocks.
the class LibraryController method addOngoingOperations.
public Project addOngoingOperations(Project project) throws ServiceException {
Collection<CondaCommands> commands = project.getCondaCommandsCollection();
for (CondaCommands condaCommand : commands) {
if (condaCommand.getInstallType().equals(CondaInstallType.ENVIRONMENT))
continue;
PythonDep pythonDep = new PythonDep();
pythonDep.setDependency(condaCommand.getLib());
pythonDep.setInstallType(condaCommand.getInstallType());
pythonDep.setPreinstalled(false);
AnacondaRepo repo = libraryFacade.getRepo(condaCommand.getChannelUrl(), false);
pythonDep.setRepoUrl(repo);
pythonDep.setVersion(condaCommand.getVersion());
pythonDep = libraryFacade.getOrCreateDep(pythonDep);
if (!project.getPythonDepCollection().contains(pythonDep)) {
project.getPythonDepCollection().add(pythonDep);
}
}
return projectFacade.update(project);
}
use of io.hops.hopsworks.persistence.entity.python.CondaCommands in project hopsworks by logicalclocks.
the class CondaCommandFacade method removeCondaCommand.
public void removeCondaCommand(int commandId) {
CondaCommands cc = findCondaCommand(commandId);
if (cc != null) {
em.remove(cc);
em.flush();
} else {
LOGGER.log(Level.FINE, "Could not remove CondaCommand with id: {0}", commandId);
}
}
Aggregations