Package org.deeplearning4j.ui
Class VertxUIServer
- java.lang.Object
-
- io.vertx.core.AbstractVerticle
-
- org.deeplearning4j.ui.VertxUIServer
-
-
Field Summary
Fields Modifier and Type Field Description static StringASSETS_ROOT_DIRECTORYstatic intDEFAULT_UI_PORT
-
Constructor Summary
Constructors Constructor Description VertxUIServer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattach(StatsStorage statsStorage)Attach the given StatsStorage instance to the UI, so the data can be visualizedvoidautoAttachStatsStorageBySessionId(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 modevoiddetach(StatsStorage statsStorage)Detach the specified StatsStorage instance from the UIvoiddisableRemoteListener()Disable the remote listener functionality (disabled by default)voidenableRemoteListener()Enable the remote listener functionality, storing all data in memory, and attaching the instance to the UI.voidenableRemoteListener(StatsStorageRouter statsStorage, boolean attach)Enable the remote listener functionality, storing the received results in the specified StatsStorageRouter.StringgetAddress()Get the address of the UIstatic VertxUIServergetInstance(Integer port, boolean multiSession, org.nd4j.common.function.Function<String,StatsStorage> statsStorageProvider)Get (and, initialize if necessary) the UI server.static VertxUIServergetInstance(Integer port, boolean multiSession, org.nd4j.common.function.Function<String,StatsStorage> statsStorageProvider, io.vertx.core.Promise<String> startCallback)Get (and, initialize if necessary) the UI server.intgetPort()Get the current port for the UIList<StatsStorage>getStatsStorageInstances()booleanisAttached(StatsStorage statsStorage)Check whether the specified StatsStorage instance is attached to the UI instancebooleanisMultiSession()Check if the instance initialized with one of the factory methods (UIServer.getInstance()orUIServer.getInstance(boolean, Function)) is in multi-session modebooleanisRemoteListenerEnabled()booleanisStopped()voidmain(String[] args)voidstart(io.vertx.core.Promise<Void> startCallback)voidstop()Stop/shut down the UI server.voidstop(io.vertx.core.Promise<Void> stopCallback)voidstopAsync(io.vertx.core.Promise<Void> stopCallback)Stop/shut down the UI server.static voidstopInstance()Stop UIServer instance, if already running
-
-
-
Field Detail
-
DEFAULT_UI_PORT
public static final int DEFAULT_UI_PORT
- See Also:
- Constant Field Values
-
ASSETS_ROOT_DIRECTORY
public static final String ASSETS_ROOT_DIRECTORY
- See Also:
- Constant Field Values
-
-
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 forHttpServerto listenmultiSession- 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/:sessionIdstatsStorageProvider- 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 itnull.- 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 forHttpServerto listenmultiSession- 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/:sessionIdstatsStorageProvider- 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 itnull.startCallback- asynchronous deployment handler callback that will be notify of success or failure. Ifnullgiven, 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 ExceptionDescription copied from interface:UIServerStop 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:
startin interfaceio.vertx.core.Verticle- Throws:
Exception
-
stop
public void stop() throws InterruptedExceptionDescription copied from interface:UIServerStop/shut down the UI server. This synchronous function should wait until the server is stopped.- Specified by:
stopin interfaceUIServer- Overrides:
stopin classio.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:UIServerStop/shut down the UI server. This asynchronous function should immediately return, and notify the callbackPromiseon completion: either callPromise.complete(T)orPromise.fail(java.lang.Throwable).
-
stop
public void stop(io.vertx.core.Promise<Void> stopCallback)
- Specified by:
stopin interfaceio.vertx.core.Verticle
-
isMultiSession
public boolean isMultiSession()
Description copied from interface:UIServerCheck if the instance initialized with one of the factory methods (UIServer.getInstance()orUIServer.getInstance(boolean, Function)) is in multi-session mode- Specified by:
isMultiSessionin interfaceUIServer- Returns:
trueif the instance is in multi-session
-
getAddress
public String getAddress()
Description copied from interface:UIServerGet the address of the UI- Specified by:
getAddressin interfaceUIServer- Returns:
- Address of the UI
-
getPort
public int getPort()
Description copied from interface:UIServerGet the current port for the UI
-
attach
public void attach(StatsStorage statsStorage)
Description copied from interface:UIServerAttach the given StatsStorage instance to the UI, so the data can be visualized
-
detach
public void detach(StatsStorage statsStorage)
Description copied from interface:UIServerDetach the specified StatsStorage instance from the UI
-
isAttached
public boolean isAttached(StatsStorage statsStorage)
Description copied from interface:UIServerCheck whether the specified StatsStorage instance is attached to the UI instance- Specified by:
isAttachedin interfaceUIServer- Parameters:
statsStorage- StatsStorage instance to attach- Returns:
- True if attached
-
getStatsStorageInstances
public List<StatsStorage> getStatsStorageInstances()
- Specified by:
getStatsStorageInstancesin interfaceUIServer- Returns:
- A list of all StatsStorage instances currently attached
-
enableRemoteListener
public void enableRemoteListener()
Description copied from interface:UIServerEnable the remote listener functionality, storing all data in memory, and attaching the instance to the UI. Typically used withRemoteUIStatsStorageRouter, which will send information remotely to this UI instance- Specified by:
enableRemoteListenerin interfaceUIServer- See Also:
UIServer.enableRemoteListener(StatsStorageRouter, boolean)
-
enableRemoteListener
public void enableRemoteListener(StatsStorageRouter statsStorage, boolean attach)
Description copied from interface:UIServerEnable the remote listener functionality, storing the received results in the specified StatsStorageRouter. If the StatsStorageRouter is aStatsStorageinstance, it may (optionally) be attached to the UI, as ifUIServer.attach(StatsStorage)was called on it.- Specified by:
enableRemoteListenerin interfaceUIServer- Parameters:
statsStorage- StatsStorageRouter to post the received results toattach- Whether to attach the given StatsStorage instance to the UI server
-
disableRemoteListener
public void disableRemoteListener()
Description copied from interface:UIServerDisable the remote listener functionality (disabled by default)- Specified by:
disableRemoteListenerin interfaceUIServer
-
isRemoteListenerEnabled
public boolean isRemoteListenerEnabled()
- Specified by:
isRemoteListenerEnabledin interfaceUIServer- Returns:
- Whether the remote listener functionality is currently enabled
-
main
public void main(String[] args)
-
-