use of io.hops.hopsworks.persistence.entity.tensorflow.TensorBoard in project hopsworks by logicalclocks.
the class TensorBoardController method startTensorBoard.
/**
* Start the TensorBoard for the specific user in this project with the specified elasticId containing the logdir
* @param mlId
* @param project
* @param user
* @param tensorBoardLogdir
* @return
* @throws IOException
*/
public TensorBoardDTO startTensorBoard(String mlId, Project project, Users user, String tensorBoardLogdir) throws TensorBoardException, ServiceDiscoveryException {
tensorBoardLogdir = prependNameNode(tensorBoardLogdir);
TensorBoardDTO tensorBoardDTO = null;
TensorBoard tb = tensorBoardFacade.findForProjectAndUser(project, user);
if (tb != null) {
cleanup(tb);
}
String hdfsUsername = hdfsUsersController.getHdfsUserName(project, user);
HdfsUsers hdfsUser = hdfsUsersFacade.findByName(hdfsUsername);
String tensorBoardDirectory = DigestUtils.sha256Hex(Integer.toString(ThreadLocalRandom.current().nextInt()));
tensorBoardDTO = tensorBoardProcessMgr.startTensorBoard(project, user, hdfsUser, tensorBoardLogdir, tensorBoardDirectory);
Date lastAccessed = new Date();
tensorBoardDTO.setMlId(mlId);
tensorBoardDTO.setLastAccessed(lastAccessed);
tensorBoardDTO.setHdfsLogdir(tensorBoardLogdir);
TensorBoard newTensorBoard = new TensorBoard();
TensorBoardPK tensorBoardPK = new TensorBoardPK();
tensorBoardPK.setProjectId(project.getId());
tensorBoardPK.setUserId(user.getUid());
newTensorBoard.setTensorBoardPK(tensorBoardPK);
newTensorBoard.setCid(tensorBoardDTO.getCid());
newTensorBoard.setEndpoint(tensorBoardDTO.getEndpoint());
newTensorBoard.setHdfsUserId(hdfsUser.getId());
newTensorBoard.setMlId(mlId);
newTensorBoard.setLastAccessed(lastAccessed);
newTensorBoard.setHdfsLogdir(tensorBoardLogdir);
newTensorBoard.setSecret(tensorBoardDirectory);
tensorBoardFacade.persist(newTensorBoard);
return tensorBoardDTO;
}
use of io.hops.hopsworks.persistence.entity.tensorflow.TensorBoard in project hopsworks by logicalclocks.
the class TensorBoardController method getTensorBoard.
/**
* Fetch the TensorBoard from the database for the user in this project
* @param project
* @param user
* @return
*/
public TensorBoardDTO getTensorBoard(Project project, Users user) {
TensorBoard tb;
tb = tensorBoardFacade.findForProjectAndUser(project, user);
if (tb == null) {
return null;
}
tb.setLastAccessed(new Date());
tensorBoardFacade.update(tb);
return new TensorBoardDTO(tb);
}
use of io.hops.hopsworks.persistence.entity.tensorflow.TensorBoard in project hopsworks by logicalclocks.
the class TensorBoardController method cleanup.
/**
* Stop and cleanup a TensorBoard for the given project and user
* @param project
* @param user
*/
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void cleanup(Project project, Users user) throws TensorBoardException {
TensorBoard tb = tensorBoardFacade.findForProjectAndUser(project, user);
this.cleanup(tb);
}
use of io.hops.hopsworks.persistence.entity.tensorflow.TensorBoard in project hopsworks by logicalclocks.
the class TensorBoardBuilder method build.
public TensorBoardDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Project project, String mlId) {
TensorBoardDTO dto = new TensorBoardDTO();
uri(dto, uriInfo, project, mlId);
expand(dto, resourceRequest);
if (dto.isExpand()) {
TensorBoard tensorBoard = tensorBoardFacade.findByMlId(mlId);
dto.setMlId(mlId);
dto.setEndpoint(tensorBoard.getEndpoint());
dto.setHdfsLogdir(tensorBoard.getHdfsLogdir());
dto.setLastAccessed(tensorBoard.getLastAccessed());
}
return dto;
}
Aggregations