Search in sources :

Example 1 with TensorBoardPK

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;
}
Also used : TensorBoardPK(io.hops.hopsworks.persistence.entity.tensorflow.TensorBoardPK) TensorBoardDTO(io.hops.hopsworks.common.dao.tensorflow.config.TensorBoardDTO) TensorBoard(io.hops.hopsworks.persistence.entity.tensorflow.TensorBoard) HdfsUsers(io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers) Date(java.util.Date)

Aggregations

TensorBoardDTO (io.hops.hopsworks.common.dao.tensorflow.config.TensorBoardDTO)1 HdfsUsers (io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers)1 TensorBoard (io.hops.hopsworks.persistence.entity.tensorflow.TensorBoard)1 TensorBoardPK (io.hops.hopsworks.persistence.entity.tensorflow.TensorBoardPK)1 Date (java.util.Date)1