Search in sources :

Example 6 with TensorBoard

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;
}
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)

Example 7 with TensorBoard

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

Example 8 with TensorBoard

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);
}
Also used : TensorBoard(io.hops.hopsworks.persistence.entity.tensorflow.TensorBoard) TransactionAttribute(javax.ejb.TransactionAttribute)

Example 9 with TensorBoard

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;
}
Also used : TensorBoardDTO(io.hops.hopsworks.common.dao.tensorflow.config.TensorBoardDTO) TensorBoard(io.hops.hopsworks.persistence.entity.tensorflow.TensorBoard)

Aggregations

TensorBoard (io.hops.hopsworks.persistence.entity.tensorflow.TensorBoard)9 TensorBoardDTO (io.hops.hopsworks.common.dao.tensorflow.config.TensorBoardDTO)3 Date (java.util.Date)3 IOException (java.io.IOException)2 NoResultException (javax.persistence.NoResultException)2 TensorBoardException (io.hops.hopsworks.exceptions.TensorBoardException)1 HdfsUsers (io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers)1 YarnApplicationstate (io.hops.hopsworks.persistence.entity.jobs.history.YarnApplicationstate)1 Project (io.hops.hopsworks.persistence.entity.project.Project)1 TensorBoardPK (io.hops.hopsworks.persistence.entity.tensorflow.TensorBoardPK)1 Users (io.hops.hopsworks.persistence.entity.user.Users)1 File (java.io.File)1 URI (java.net.URI)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Schedule (javax.ejb.Schedule)1 TransactionAttribute (javax.ejb.TransactionAttribute)1 ServletException (javax.servlet.ServletException)1