Class VertxUIServer

  • All Implemented Interfaces:
    io.vertx.core.Verticle, UIServer

    public class VertxUIServer
    extends io.vertx.core.AbstractVerticle
    implements UIServer
    • Constructor Detail

      • VertxUIServer

        public VertxUIServer()
    • Method Detail

      • getInstance

        public static VertxUIServer getInstance​(Integer port,
                                                boolean multiSession,
                                                org.nd4j.common.function.Function<String,​StatsStorage> statsStorageProvider)
                                         throws org.deeplearning4j.exception.DL4JException
        Get (and, initialize if necessary) the UI server. This synchronous function will wait until the server started.
        Parameters:
        port - TCP socket port for HttpServer to listen
        multiSession - in multi-session mode, multiple training sessions can be visualized in separate browser tabs.
        URL path will include session ID as a parameter, i.e.: /train becomes /train/:sessionId
        statsStorageProvider - function that returns a StatsStorage containing the given session ID.
        Use this to auto-attach StatsStorage if an unknown session ID is passed as URL path parameter in multi-session mode, or leave it null.
        Returns:
        UI instance for this JVM
        Throws:
        org.deeplearning4j.exception.DL4JException - if UI server failed to start; if the instance has already started in a different mode (multi/single-session); if interrupted while waiting for completion
      • getInstance

        public static VertxUIServer getInstance​(Integer port,
                                                boolean multiSession,
                                                org.nd4j.common.function.Function<String,​StatsStorage> statsStorageProvider,
                                                io.vertx.core.Promise<String> startCallback)
                                         throws org.deeplearning4j.exception.DL4JException
        Get (and, initialize if necessary) the UI server. This function will wait until the server started (synchronous way), or pass the given callback to handle success or failure (asynchronous way).
        Parameters:
        port - TCP socket port for HttpServer to listen
        multiSession - in multi-session mode, multiple training sessions can be visualized in separate browser tabs.
        URL path will include session ID as a parameter, i.e.: /train becomes /train/:sessionId
        statsStorageProvider - function that returns a StatsStorage containing the given session ID.
        Use this to auto-attach StatsStorage if an unknown session ID is passed as URL path parameter in multi-session mode, or leave it null.
        startCallback - asynchronous deployment handler callback that will be notify of success or failure. If null given, then this method will wait until deployment is complete. If the deployment is successful the result will contain a String representing the unique deployment ID of the deployment.
        Returns:
        UI server instance
        Throws:
        org.deeplearning4j.exception.DL4JException - if UI server failed to start; if the instance has already started in a different mode (multi/single-session); if interrupted while waiting for completion
      • stopInstance

        public static void stopInstance()
                                 throws Exception
        Description copied from interface: UIServer
        Stop UIServer instance, if already running
        Throws:
        Exception
      • autoAttachStatsStorageBySessionId

        public void autoAttachStatsStorageBySessionId​(org.nd4j.common.function.Function<String,​StatsStorage> statsStorageProvider)
        Auto-attach StatsStorage if an unknown session ID is passed as URL path parameter in multi-session mode
        Parameters:
        statsStorageProvider - function that returns a StatsStorage containing the given session ID
      • start

        public void start​(io.vertx.core.Promise<Void> startCallback)
                   throws Exception
        Specified by:
        start in interface io.vertx.core.Verticle
        Throws:
        Exception
      • stop

        public void stop()
                  throws InterruptedException
        Description copied from interface: UIServer
        Stop/shut down the UI server. This synchronous function should wait until the server is stopped.
        Specified by:
        stop in interface UIServer
        Overrides:
        stop in class io.vertx.core.AbstractVerticle
        Throws:
        InterruptedException - if the current thread is interrupted while waiting
      • stopAsync

        public void stopAsync​(io.vertx.core.Promise<Void> stopCallback)
        Description copied from interface: UIServer
        Stop/shut down the UI server. This asynchronous function should immediately return, and notify the callback Promise on completion: either call Promise.complete(T) or Promise.fail(java.lang.Throwable).
        Specified by:
        stopAsync in interface UIServer
        Parameters:
        stopCallback - callback Promise to notify on completion
      • stop

        public void stop​(io.vertx.core.Promise<Void> stopCallback)
        Specified by:
        stop in interface io.vertx.core.Verticle
      • isStopped

        public boolean isStopped()
        Specified by:
        isStopped in interface UIServer
      • getAddress

        public String getAddress()
        Description copied from interface: UIServer
        Get the address of the UI
        Specified by:
        getAddress in interface UIServer
        Returns:
        Address of the UI
      • getPort

        public int getPort()
        Description copied from interface: UIServer
        Get the current port for the UI
        Specified by:
        getPort in interface UIServer
      • attach

        public void attach​(StatsStorage statsStorage)
        Description copied from interface: UIServer
        Attach the given StatsStorage instance to the UI, so the data can be visualized
        Specified by:
        attach in interface UIServer
        Parameters:
        statsStorage - StatsStorage instance to attach to the UI
      • detach

        public void detach​(StatsStorage statsStorage)
        Description copied from interface: UIServer
        Detach the specified StatsStorage instance from the UI
        Specified by:
        detach in interface UIServer
        Parameters:
        statsStorage - StatsStorage instance to detach. If not attached: no op.
      • isAttached

        public boolean isAttached​(StatsStorage statsStorage)
        Description copied from interface: UIServer
        Check whether the specified StatsStorage instance is attached to the UI instance
        Specified by:
        isAttached in interface UIServer
        Parameters:
        statsStorage - StatsStorage instance to attach
        Returns:
        True if attached
      • enableRemoteListener

        public void enableRemoteListener​(StatsStorageRouter statsStorage,
                                         boolean attach)
        Description copied from interface: UIServer
        Enable the remote listener functionality, storing the received results in the specified StatsStorageRouter. If the StatsStorageRouter is a StatsStorage instance, it may (optionally) be attached to the UI, as if UIServer.attach(StatsStorage) was called on it.
        Specified by:
        enableRemoteListener in interface UIServer
        Parameters:
        statsStorage - StatsStorageRouter to post the received results to
        attach - Whether to attach the given StatsStorage instance to the UI server
      • disableRemoteListener

        public void disableRemoteListener()
        Description copied from interface: UIServer
        Disable the remote listener functionality (disabled by default)
        Specified by:
        disableRemoteListener in interface UIServer
      • isRemoteListenerEnabled

        public boolean isRemoteListenerEnabled()
        Specified by:
        isRemoteListenerEnabled in interface UIServer
        Returns:
        Whether the remote listener functionality is currently enabled
      • main

        public void main​(String[] args)