use of io.hops.hopsworks.persistence.entity.python.CondaCommands 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.CondaCommands in project hopsworks by logicalclocks.
the class EnvironmentController method createEnv.
public Project createEnv(Project project, Users user) throws PythonException {
List<CondaStatus> statuses = new ArrayList<>();
statuses.add(CondaStatus.NEW);
statuses.add(CondaStatus.ONGOING);
if (!condaCommandFacade.findByStatusAndCondaOpAndProject(statuses, CondaOp.CREATE, project).isEmpty()) {
throw new PythonException(RESTCodes.PythonErrorCode.ANACONDA_ENVIRONMENT_INITIALIZING, Level.INFO);
}
if (project.getPythonEnvironment() != null) {
throw new PythonException(RESTCodes.PythonErrorCode.ANACONDA_ENVIRONMENT_ALREADY_INITIALIZED, Level.FINE);
}
PythonEnvironment pythonEnvironment = new PythonEnvironment();
pythonEnvironment.setPythonVersion(settings.getDockerBaseImagePythonVersion());
pythonEnvironment.setProjectId(project.getId());
project.setPythonEnvironment(pythonEnvironment);
project.setDockerImage(settings.getBaseDockerImagePythonName());
CondaCommands cc = new CondaCommands(user, CondaOp.SYNC_BASE_ENV, CondaStatus.NEW, CondaInstallType.ENVIRONMENT, project, settings.getDockerBaseImagePythonVersion(), null, null, new Date(), null, null, false);
condaCommandFacade.save(cc);
return projectFacade.update(project);
}
Aggregations