use of io.hops.hopsworks.persistence.entity.tensorflow.TensorBoardPK 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;
}
Aggregations