use of io.hops.hopsworks.persistence.entity.python.PythonEnvironment in project hopsworks by logicalclocks.
the class EnvironmentController method createProjectDockerImage.
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void createProjectDockerImage(Project project, Users user) {
// Check if there is no pending CREATE op for this project
List<CondaStatus> statuses = new ArrayList<>();
statuses.add(CondaStatus.NEW);
statuses.add(CondaStatus.ONGOING);
if (!condaCommandFacade.findByStatusAndCondaOpAndProject(statuses, CondaOp.CREATE, project).isEmpty()) {
LOGGER.log(Level.INFO, "There is already a " + CondaOp.CREATE.name() + " operation for this project.");
return;
}
condaEnvironmentOp(CondaOp.CREATE, project.getPythonEnvironment().getPythonVersion(), project, user, project.getPythonEnvironment().getPythonVersion(), null, false);
if (project.getPythonEnvironment() == null) {
PythonEnvironment pythonEnvironment = new PythonEnvironment();
pythonEnvironment.setPythonVersion(settings.getDockerBaseImagePythonVersion());
pythonEnvironment.setProjectId(project.getId());
project.setPythonEnvironment(pythonEnvironment);
}
project.setDockerImage(settings.getBaseDockerImagePythonName());
projectFacade.update(project);
projectFacade.flushEm();
}
use of io.hops.hopsworks.persistence.entity.python.PythonEnvironment in project hopsworks by logicalclocks.
the class EnvironmentController method createProjectDockerImageFromImport.
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public String createProjectDockerImageFromImport(String importPath, boolean installJupyter, Users user, Project project) throws PythonException, ServiceException {
if (project.getPythonEnvironment() != null) {
throw new PythonException(RESTCodes.PythonErrorCode.ANACONDA_ENVIRONMENT_ALREADY_INITIALIZED, Level.FINE);
}
String username = hdfsUsersController.getHdfsUserName(project, user);
String importContent = validateImportFile(new Path(importPath), username);
if (!importPath.endsWith(".yml") && !importPath.endsWith("/requirements.txt")) {
throw new PythonException(RESTCodes.PythonErrorCode.ANACONDA_ENVIRONMENT_FILE_INVALID, Level.FINE);
}
String pythonVersion = findPythonVersion(importContent);
if (Strings.isNullOrEmpty(pythonVersion)) {
pythonVersion = settings.getDockerBaseImagePythonVersion();
}
condaEnvironmentOp(CondaOp.IMPORT, pythonVersion, project, user, pythonVersion, importPath, installJupyter);
PythonEnvironment pythonEnvironment = new PythonEnvironment();
pythonEnvironment.setPythonVersion(pythonVersion);
pythonEnvironment.setProjectId(project.getId());
project.setPythonEnvironment(pythonEnvironment);
projectFacade.update(project);
return pythonVersion;
}
use of io.hops.hopsworks.persistence.entity.python.PythonEnvironment 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