372 lines
14 KiB
Java
Raw Normal View History

2021-02-01 14:31:20 +09:00
/*
* ******************************************************************************
* *
* *
* * This program and the accompanying materials are made available under the
* * terms of the Apache License, Version 2.0 which is available at
* * https://www.apache.org/licenses/LICENSE-2.0.
* *
2021-02-01 17:47:29 +09:00
* * See the NOTICE file distributed with this work for additional
* * information regarding copyright ownership.
2021-02-01 14:31:20 +09:00
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* * License for the specific language governing permissions and limitations
* * under the License.
* *
* * SPDX-License-Identifier: Apache-2.0
* *****************************************************************************
*/
2019-06-06 15:21:15 +03:00
DL4J UI: Migrate from Play to Vertx (#68) * Vertx transition initial steps Signed-off-by: AlexDBlack <blacka101@gmail.com> * Assets serving works Signed-off-by: AlexDBlack <blacka101@gmail.com> * Next steps Signed-off-by: AlexDBlack <blacka101@gmail.com> * Add other pages Signed-off-by: AlexDBlack <blacka101@gmail.com> * Add remaining modules Signed-off-by: AlexDBlack <blacka101@gmail.com> * Delete deeplearning4j-play module Signed-off-by: AlexDBlack <blacka101@gmail.com> * SD UI module Signed-off-by: AlexDBlack <blacka101@gmail.com> * Main UI works Signed-off-by: AlexDBlack <blacka101@gmail.com> * Multi-session UI fixed Signed-off-by: AlexDBlack <blacka101@gmail.com> * TSNE fixed Signed-off-by: AlexDBlack <blacka101@gmail.com> * Polish, fixes, re-add CLI launch option Signed-off-by: AlexDBlack <blacka101@gmail.com> * Fix remote UI functionality Signed-off-by: AlexDBlack <blacka101@gmail.com> * Final tweaks Signed-off-by: AlexDBlack <blacka101@gmail.com> * Remove Scala version suffix from deeplearning4j-ui Signed-off-by: AlexDBlack <blacka101@gmail.com> * Update Arbiter UI to vertx Signed-off-by: AlexDBlack <blacka101@gmail.com> * Missing version tag Signed-off-by: AlexDBlack <blacka101@gmail.com> * Remove (now unneeded) scala from arbiter UI Signed-off-by: AlexDBlack <blacka101@gmail.com> * Move vertx version to parent pom Signed-off-by: AlexDBlack <blacka101@gmail.com> * Switch template loading from classpath to a more reliable mechanism Signed-off-by: AlexDBlack <blacka101@gmail.com> * Small fix for I18N message loading Signed-off-by: AlexDBlack <blacka101@gmail.com> * Switch to shaded jackson for UI module JSON conversion Signed-off-by: AlexDBlack <blacka101@gmail.com> * Small test tweaks and copyright header fix Signed-off-by: AlexDBlack <blacka101@gmail.com> * pom file copyright headers Signed-off-by: AlexDBlack <blacka101@gmail.com> * plugins -> pliginManagement for java 8 modules Signed-off-by: AlexDBlack <blacka101@gmail.com> * plugins -> pliginManagement for java 8 modules Signed-off-by: AlexDBlack <blacka101@gmail.com>
2019-11-22 23:50:34 +11:00
package org.deeplearning4j.ui;
2019-06-06 15:21:15 +03:00
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
Various fixes (#143) * #8568 ArrayUtil optimization Signed-off-by: AlexDBlack <blacka101@gmail.com> * #6171 Keras ReLU and ELU support Signed-off-by: AlexDBlack <blacka101@gmail.com> * Keras softmax layer import Signed-off-by: AlexDBlack <blacka101@gmail.com> * #8549 Webjars dependency management Signed-off-by: AlexDBlack <blacka101@gmail.com> * Fix for TF import names ':0' suffix issue / NPE Signed-off-by: AlexDBlack <blacka101@gmail.com> * BiasAdd: fix default data format for TF import Signed-off-by: AlexDBlack <blacka101@gmail.com> * Update zoo test ignores Signed-off-by: AlexDBlack <blacka101@gmail.com> * #8509 SameDiff Listener API - provide frame + iteration Signed-off-by: AlexDBlack <blacka101@gmail.com> * #8520 ND4J Environment Signed-off-by: AlexDBlack <blacka101@gmail.com> * Deconv3d Signed-off-by: AlexDBlack <blacka101@gmail.com> * Deconv3d fixes + gradient check Signed-off-by: AlexDBlack <blacka101@gmail.com> * Conv3d fixes + deconv3d DType test Signed-off-by: AlexDBlack <blacka101@gmail.com> * Fix issue with deconv3d gradinet check weight init Signed-off-by: AlexDBlack <blacka101@gmail.com> * #8579 Fix BaseCudaDataBuffer constructor fix for UINT16 Signed-off-by: AlexDBlack <blacka101@gmail.com> * DataType.isNumerical() returns false for BOOL type Signed-off-by: AlexDBlack <blacka101@gmail.com> * #8504 Reduce Spark log spam for tests Signed-off-by: AlexDBlack <blacka101@gmail.com> * Clean up DL4J gradient check test spam Signed-off-by: AlexDBlack <blacka101@gmail.com> * More Gradient check spam reduction Signed-off-by: AlexDBlack <blacka101@gmail.com> * SameDiff test spam reduction Signed-off-by: AlexDBlack <blacka101@gmail.com> * Fixes for FlatBuffers mapping Signed-off-by: AlexDBlack <blacka101@gmail.com> * SameDiff log spam cleanup Signed-off-by: AlexDBlack <blacka101@gmail.com> * Tests should extend BaseNd4jTest Signed-off-by: AlexDBlack <blacka101@gmail.com> * Remove debug line in c++ op Signed-off-by: AlexDBlack <blacka101@gmail.com> * ND4J test spam cleanup Signed-off-by: AlexDBlack <blacka101@gmail.com> * DL4J test spam reduction Signed-off-by: AlexDBlack <blacka101@gmail.com> * More Dl4J and datavec test spam cleanup Signed-off-by: AlexDBlack <blacka101@gmail.com> * Fix for bad conv3d test Signed-off-by: AlexDBlack <blacka101@gmail.com> * Additional test Signed-off-by: AlexDBlack <blacka101@gmail.com> * Embedding layers: don't inherit global default activation function Signed-off-by: AlexDBlack <blacka101@gmail.com> * Trigger CI Signed-off-by: AlexDBlack <blacka101@gmail.com> * Consolidate all BaseDL4JTest classes to single class used everywhere; make timeout configurable per class Signed-off-by: AlexDBlack <blacka101@gmail.com> * Test fixes and timeout increases Signed-off-by: AlexDBlack <blacka101@gmail.com> * Timeouts and PReLU fixes Signed-off-by: AlexDBlack <blacka101@gmail.com> * Restore libnd4j build threads arg for CUDA build Signed-off-by: AlexDBlack <blacka101@gmail.com> * Increase timeouts on a few tests to avoid spurious failures on some CI machines Signed-off-by: AlexDBlack <blacka101@gmail.com> * More timeout fixes Signed-off-by: AlexDBlack <blacka101@gmail.com> * More test timeout fixes Signed-off-by: AlexDBlack <blacka101@gmail.com> * Tweak timeout for one more test Signed-off-by: AlexDBlack <blacka101@gmail.com> * Final tweaks Signed-off-by: AlexDBlack <blacka101@gmail.com> * One more ignore Signed-off-by: AlexDBlack <blacka101@gmail.com>
2020-01-04 13:45:07 +11:00
import org.deeplearning4j.BaseDL4JTest;
Refactor packages to fix split package issues (#411) * Refactor nd4j-common: org.nd4j.* -> org.nd4j.common.* Signed-off-by: Alex Black <blacka101@gmail.com> * Fix CUDA (missed nd4j-common package refactoring changes) Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-kryo: org.nd4j -> org.nd4j.kryo Signed-off-by: Alex Black <blacka101@gmail.com> * Fix nd4j-common for deeplearning4j-cuda Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-grppc-client: org.nd4j.graph -> org.nd4j.remote.grpc Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-common: org.deeplearning4.* -> org.deeplearning4j.common.* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-core: org.deeplearning4j.* -> org.deeplearning.core.* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-cuda: org.deeplearning4j.nn.layers.* -> org.deeplearning4j.cuda.* Signed-off-by: Alex Black <blacka101@gmail.com> * Import fixes Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-nlp-*: org.deeplearning4.text.* -> org.deeplearning4j.nlp.(language).* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-ui-model: org.deeplearning4j.ui -> org.deeplearning4j.ui.model Signed-off-by: Alex Black <blacka101@gmail.com> * datavec-spark-inference-{server/model/client}: org.datavec.spark.transform -> org.datavec.spark.inference.{server/model/client} Signed-off-by: Alex Black <blacka101@gmail.com> * datavec-jdbc: org.datavec.api -> org.datavec.jdbc Signed-off-by: Alex Black <blacka101@gmail.com> * Delete org.deeplearning4j.datasets.iterator.impl.MultiDataSetIteratorAdapter in favor of (essentially identical) org.nd4j.linalg.dataset.adapter.MultiDataSetIteratorAdapter Signed-off-by: Alex Black <blacka101@gmail.com> * ND4S fixes Signed-off-by: Alex Black <blacka101@gmail.com> * Fixes Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-common-tests: org.nd4j.* -> org.nd4j.common.tests Signed-off-by: Alex Black <blacka101@gmail.com> * Trigger CI Signed-off-by: Alex Black <blacka101@gmail.com> * Fixes Signed-off-by: Alex Black <blacka101@gmail.com> * #8878 Ignore CUDA tests on modules with 'nd4j-native under cuda' issue Signed-off-by: Alex Black <blacka101@gmail.com> * Fix bad imports in tests Signed-off-by: Alex Black <blacka101@gmail.com> * Add ignore on test (already failing) due to #8882 Signed-off-by: Alex Black <blacka101@gmail.com> * Import fixes Signed-off-by: Alex Black <blacka101@gmail.com> * Additional import fixes Signed-off-by: Alex Black <blacka101@gmail.com>
2020-04-29 11:19:26 +10:00
import org.deeplearning4j.core.storage.StatsStorage;
2019-06-06 15:21:15 +03:00
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
import org.deeplearning4j.exception.DL4JException;
2019-06-06 15:21:15 +03:00
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.deeplearning4j.nn.conf.layers.DenseLayer;
import org.deeplearning4j.nn.conf.layers.OutputLayer;
import org.deeplearning4j.nn.conf.layers.variational.GaussianReconstructionDistribution;
import org.deeplearning4j.nn.conf.layers.variational.VariationalAutoencoder;
import org.deeplearning4j.nn.conf.serde.JsonMappers;
2019-06-06 15:21:15 +03:00
import org.deeplearning4j.nn.graph.ComputationGraph;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
import org.deeplearning4j.nn.weights.WeightInit;
import org.deeplearning4j.optimize.listeners.ScoreIterationListener;
import org.deeplearning4j.ui.api.UIServer;
Refactor packages to fix split package issues (#411) * Refactor nd4j-common: org.nd4j.* -> org.nd4j.common.* Signed-off-by: Alex Black <blacka101@gmail.com> * Fix CUDA (missed nd4j-common package refactoring changes) Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-kryo: org.nd4j -> org.nd4j.kryo Signed-off-by: Alex Black <blacka101@gmail.com> * Fix nd4j-common for deeplearning4j-cuda Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-grppc-client: org.nd4j.graph -> org.nd4j.remote.grpc Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-common: org.deeplearning4.* -> org.deeplearning4j.common.* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-core: org.deeplearning4j.* -> org.deeplearning.core.* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-cuda: org.deeplearning4j.nn.layers.* -> org.deeplearning4j.cuda.* Signed-off-by: Alex Black <blacka101@gmail.com> * Import fixes Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-nlp-*: org.deeplearning4.text.* -> org.deeplearning4j.nlp.(language).* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-ui-model: org.deeplearning4j.ui -> org.deeplearning4j.ui.model Signed-off-by: Alex Black <blacka101@gmail.com> * datavec-spark-inference-{server/model/client}: org.datavec.spark.transform -> org.datavec.spark.inference.{server/model/client} Signed-off-by: Alex Black <blacka101@gmail.com> * datavec-jdbc: org.datavec.api -> org.datavec.jdbc Signed-off-by: Alex Black <blacka101@gmail.com> * Delete org.deeplearning4j.datasets.iterator.impl.MultiDataSetIteratorAdapter in favor of (essentially identical) org.nd4j.linalg.dataset.adapter.MultiDataSetIteratorAdapter Signed-off-by: Alex Black <blacka101@gmail.com> * ND4S fixes Signed-off-by: Alex Black <blacka101@gmail.com> * Fixes Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-common-tests: org.nd4j.* -> org.nd4j.common.tests Signed-off-by: Alex Black <blacka101@gmail.com> * Trigger CI Signed-off-by: Alex Black <blacka101@gmail.com> * Fixes Signed-off-by: Alex Black <blacka101@gmail.com> * #8878 Ignore CUDA tests on modules with 'nd4j-native under cuda' issue Signed-off-by: Alex Black <blacka101@gmail.com> * Fix bad imports in tests Signed-off-by: Alex Black <blacka101@gmail.com> * Add ignore on test (already failing) due to #8882 Signed-off-by: Alex Black <blacka101@gmail.com> * Import fixes Signed-off-by: Alex Black <blacka101@gmail.com> * Additional import fixes Signed-off-by: Alex Black <blacka101@gmail.com>
2020-04-29 11:19:26 +10:00
import org.deeplearning4j.ui.model.stats.StatsListener;
import org.deeplearning4j.ui.model.storage.InMemoryStatsStorage;
import org.junit.jupiter.api.AfterAll;
2021-03-16 11:57:24 +09:00
import org.junit.jupiter.api.BeforeEach;
2021-03-16 11:57:24 +09:00
import org.junit.jupiter.api.Test;
2019-06-06 15:21:15 +03:00
import org.nd4j.linalg.activations.Activation;
import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;
Refactor packages to fix split package issues (#411) * Refactor nd4j-common: org.nd4j.* -> org.nd4j.common.* Signed-off-by: Alex Black <blacka101@gmail.com> * Fix CUDA (missed nd4j-common package refactoring changes) Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-kryo: org.nd4j -> org.nd4j.kryo Signed-off-by: Alex Black <blacka101@gmail.com> * Fix nd4j-common for deeplearning4j-cuda Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-grppc-client: org.nd4j.graph -> org.nd4j.remote.grpc Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-common: org.deeplearning4.* -> org.deeplearning4j.common.* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-core: org.deeplearning4j.* -> org.deeplearning.core.* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-cuda: org.deeplearning4j.nn.layers.* -> org.deeplearning4j.cuda.* Signed-off-by: Alex Black <blacka101@gmail.com> * Import fixes Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-nlp-*: org.deeplearning4.text.* -> org.deeplearning4j.nlp.(language).* Signed-off-by: Alex Black <blacka101@gmail.com> * deeplearning4j-ui-model: org.deeplearning4j.ui -> org.deeplearning4j.ui.model Signed-off-by: Alex Black <blacka101@gmail.com> * datavec-spark-inference-{server/model/client}: org.datavec.spark.transform -> org.datavec.spark.inference.{server/model/client} Signed-off-by: Alex Black <blacka101@gmail.com> * datavec-jdbc: org.datavec.api -> org.datavec.jdbc Signed-off-by: Alex Black <blacka101@gmail.com> * Delete org.deeplearning4j.datasets.iterator.impl.MultiDataSetIteratorAdapter in favor of (essentially identical) org.nd4j.linalg.dataset.adapter.MultiDataSetIteratorAdapter Signed-off-by: Alex Black <blacka101@gmail.com> * ND4S fixes Signed-off-by: Alex Black <blacka101@gmail.com> * Fixes Signed-off-by: Alex Black <blacka101@gmail.com> * nd4j-common-tests: org.nd4j.* -> org.nd4j.common.tests Signed-off-by: Alex Black <blacka101@gmail.com> * Trigger CI Signed-off-by: Alex Black <blacka101@gmail.com> * Fixes Signed-off-by: Alex Black <blacka101@gmail.com> * #8878 Ignore CUDA tests on modules with 'nd4j-native under cuda' issue Signed-off-by: Alex Black <blacka101@gmail.com> * Fix bad imports in tests Signed-off-by: Alex Black <blacka101@gmail.com> * Add ignore on test (already failing) due to #8882 Signed-off-by: Alex Black <blacka101@gmail.com> * Import fixes Signed-off-by: Alex Black <blacka101@gmail.com> * Additional import fixes Signed-off-by: Alex Black <blacka101@gmail.com>
2020-04-29 11:19:26 +10:00
import org.nd4j.common.function.Function;
2019-06-06 15:21:15 +03:00
import org.nd4j.linalg.learning.config.Sgd;
import org.nd4j.linalg.lossfunctions.LossFunctions;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
2021-03-16 11:57:24 +09:00
import static org.junit.jupiter.api.Assertions.*;
2019-06-06 15:21:15 +03:00
@Slf4j
//@Ignore
Various fixes (#143) * #8568 ArrayUtil optimization Signed-off-by: AlexDBlack <blacka101@gmail.com> * #6171 Keras ReLU and ELU support Signed-off-by: AlexDBlack <blacka101@gmail.com> * Keras softmax layer import Signed-off-by: AlexDBlack <blacka101@gmail.com> * #8549 Webjars dependency management Signed-off-by: AlexDBlack <blacka101@gmail.com> * Fix for TF import names ':0' suffix issue / NPE Signed-off-by: AlexDBlack <blacka101@gmail.com> * BiasAdd: fix default data format for TF import Signed-off-by: AlexDBlack <blacka101@gmail.com> * Update zoo test ignores Signed-off-by: AlexDBlack <blacka101@gmail.com> * #8509 SameDiff Listener API - provide frame + iteration Signed-off-by: AlexDBlack <blacka101@gmail.com> * #8520 ND4J Environment Signed-off-by: AlexDBlack <blacka101@gmail.com> * Deconv3d Signed-off-by: AlexDBlack <blacka101@gmail.com> * Deconv3d fixes + gradient check Signed-off-by: AlexDBlack <blacka101@gmail.com> * Conv3d fixes + deconv3d DType test Signed-off-by: AlexDBlack <blacka101@gmail.com> * Fix issue with deconv3d gradinet check weight init Signed-off-by: AlexDBlack <blacka101@gmail.com> * #8579 Fix BaseCudaDataBuffer constructor fix for UINT16 Signed-off-by: AlexDBlack <blacka101@gmail.com> * DataType.isNumerical() returns false for BOOL type Signed-off-by: AlexDBlack <blacka101@gmail.com> * #8504 Reduce Spark log spam for tests Signed-off-by: AlexDBlack <blacka101@gmail.com> * Clean up DL4J gradient check test spam Signed-off-by: AlexDBlack <blacka101@gmail.com> * More Gradient check spam reduction Signed-off-by: AlexDBlack <blacka101@gmail.com> * SameDiff test spam reduction Signed-off-by: AlexDBlack <blacka101@gmail.com> * Fixes for FlatBuffers mapping Signed-off-by: AlexDBlack <blacka101@gmail.com> * SameDiff log spam cleanup Signed-off-by: AlexDBlack <blacka101@gmail.com> * Tests should extend BaseNd4jTest Signed-off-by: AlexDBlack <blacka101@gmail.com> * Remove debug line in c++ op Signed-off-by: AlexDBlack <blacka101@gmail.com> * ND4J test spam cleanup Signed-off-by: AlexDBlack <blacka101@gmail.com> * DL4J test spam reduction Signed-off-by: AlexDBlack <blacka101@gmail.com> * More Dl4J and datavec test spam cleanup Signed-off-by: AlexDBlack <blacka101@gmail.com> * Fix for bad conv3d test Signed-off-by: AlexDBlack <blacka101@gmail.com> * Additional test Signed-off-by: AlexDBlack <blacka101@gmail.com> * Embedding layers: don't inherit global default activation function Signed-off-by: AlexDBlack <blacka101@gmail.com> * Trigger CI Signed-off-by: AlexDBlack <blacka101@gmail.com> * Consolidate all BaseDL4JTest classes to single class used everywhere; make timeout configurable per class Signed-off-by: AlexDBlack <blacka101@gmail.com> * Test fixes and timeout increases Signed-off-by: AlexDBlack <blacka101@gmail.com> * Timeouts and PReLU fixes Signed-off-by: AlexDBlack <blacka101@gmail.com> * Restore libnd4j build threads arg for CUDA build Signed-off-by: AlexDBlack <blacka101@gmail.com> * Increase timeouts on a few tests to avoid spurious failures on some CI machines Signed-off-by: AlexDBlack <blacka101@gmail.com> * More timeout fixes Signed-off-by: AlexDBlack <blacka101@gmail.com> * More test timeout fixes Signed-off-by: AlexDBlack <blacka101@gmail.com> * Tweak timeout for one more test Signed-off-by: AlexDBlack <blacka101@gmail.com> * Final tweaks Signed-off-by: AlexDBlack <blacka101@gmail.com> * One more ignore Signed-off-by: AlexDBlack <blacka101@gmail.com>
2020-01-04 13:45:07 +11:00
public class TestVertxUI extends BaseDL4JTest {
2021-03-16 11:57:24 +09:00
@BeforeEach
2019-06-06 15:21:15 +03:00
public void setUp() throws Exception {
UIServer.stopInstance();
}
@AfterAll
public void shutdownServer() throws InterruptedException {
UIServer.getInstance().stop();
}
2019-06-06 15:21:15 +03:00
@Test
public void testUI() throws Exception {
DL4J UI: Migrate from Play to Vertx (#68) * Vertx transition initial steps Signed-off-by: AlexDBlack <blacka101@gmail.com> * Assets serving works Signed-off-by: AlexDBlack <blacka101@gmail.com> * Next steps Signed-off-by: AlexDBlack <blacka101@gmail.com> * Add other pages Signed-off-by: AlexDBlack <blacka101@gmail.com> * Add remaining modules Signed-off-by: AlexDBlack <blacka101@gmail.com> * Delete deeplearning4j-play module Signed-off-by: AlexDBlack <blacka101@gmail.com> * SD UI module Signed-off-by: AlexDBlack <blacka101@gmail.com> * Main UI works Signed-off-by: AlexDBlack <blacka101@gmail.com> * Multi-session UI fixed Signed-off-by: AlexDBlack <blacka101@gmail.com> * TSNE fixed Signed-off-by: AlexDBlack <blacka101@gmail.com> * Polish, fixes, re-add CLI launch option Signed-off-by: AlexDBlack <blacka101@gmail.com> * Fix remote UI functionality Signed-off-by: AlexDBlack <blacka101@gmail.com> * Final tweaks Signed-off-by: AlexDBlack <blacka101@gmail.com> * Remove Scala version suffix from deeplearning4j-ui Signed-off-by: AlexDBlack <blacka101@gmail.com> * Update Arbiter UI to vertx Signed-off-by: AlexDBlack <blacka101@gmail.com> * Missing version tag Signed-off-by: AlexDBlack <blacka101@gmail.com> * Remove (now unneeded) scala from arbiter UI Signed-off-by: AlexDBlack <blacka101@gmail.com> * Move vertx version to parent pom Signed-off-by: AlexDBlack <blacka101@gmail.com> * Switch template loading from classpath to a more reliable mechanism Signed-off-by: AlexDBlack <blacka101@gmail.com> * Small fix for I18N message loading Signed-off-by: AlexDBlack <blacka101@gmail.com> * Switch to shaded jackson for UI module JSON conversion Signed-off-by: AlexDBlack <blacka101@gmail.com> * Small test tweaks and copyright header fix Signed-off-by: AlexDBlack <blacka101@gmail.com> * pom file copyright headers Signed-off-by: AlexDBlack <blacka101@gmail.com> * plugins -> pliginManagement for java 8 modules Signed-off-by: AlexDBlack <blacka101@gmail.com> * plugins -> pliginManagement for java 8 modules Signed-off-by: AlexDBlack <blacka101@gmail.com>
2019-11-22 23:50:34 +11:00
VertxUIServer uiServer = (VertxUIServer) UIServer.getInstance();
2019-06-06 15:21:15 +03:00
assertEquals(9000, uiServer.getPort());
uiServer.stop();
}
@Test
public void testUI_VAE() throws Exception {
//Variational autoencoder - for unsupervised layerwise pretraining
StatsStorage ss = new InMemoryStatsStorage();
UIServer uiServer = UIServer.getInstance();
uiServer.attach(ss);
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
.updater(new Sgd(1e-5))
.list().layer(0,
new VariationalAutoencoder.Builder().nIn(4).nOut(3).encoderLayerSizes(10, 11)
.decoderLayerSizes(12, 13).weightInit(WeightInit.XAVIER)
.pzxActivationFunction(Activation.IDENTITY)
.reconstructionDistribution(
new GaussianReconstructionDistribution())
.activation(Activation.LEAKYRELU).build())
.layer(1, new VariationalAutoencoder.Builder().nIn(3).nOut(3).encoderLayerSizes(7)
.decoderLayerSizes(8).weightInit(WeightInit.XAVIER)
.pzxActivationFunction(Activation.IDENTITY)
.reconstructionDistribution(new GaussianReconstructionDistribution())
.activation(Activation.LEAKYRELU).build())
.layer(2, new OutputLayer.Builder().nIn(3).nOut(3).build())
.build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
net.setListeners(new StatsListener(ss), new ScoreIterationListener(1));
DataSetIterator iter = new IrisDataSetIterator(150, 150);
for (int i = 0; i < 50; i++) {
net.fit(iter);
Thread.sleep(100);
}
}
@Test
public void testUIMultipleSessions() throws Exception {
for (int session = 0; session < 3; session++) {
StatsStorage ss = new InMemoryStatsStorage();
UIServer uiServer = UIServer.getInstance();
uiServer.attach(ss);
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
.layer(0, new DenseLayer.Builder().activation(Activation.TANH).nIn(4).nOut(4).build())
.layer(1, new OutputLayer.Builder().lossFunction(LossFunctions.LossFunction.MCXENT)
.activation(Activation.SOFTMAX).nIn(4).nOut(3).build())
.build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
net.setListeners(new StatsListener(ss, 1), new ScoreIterationListener(1));
DataSetIterator iter = new IrisDataSetIterator(150, 150);
for (int i = 0; i < 20; i++) {
net.fit(iter);
Thread.sleep(100);
}
}
}
@Test
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
public void testUICompGraph() {
2019-06-06 15:21:15 +03:00
StatsStorage ss = new InMemoryStatsStorage();
UIServer uiServer = UIServer.getInstance();
uiServer.attach(ss);
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().graphBuilder().addInputs("in")
.addLayer("L0", new DenseLayer.Builder().activation(Activation.TANH).nIn(4).nOut(4).build(),
"in")
.addLayer("L1", new OutputLayer.Builder().lossFunction(LossFunctions.LossFunction.MCXENT)
.activation(Activation.SOFTMAX).nIn(4).nOut(3).build(), "L0")
.setOutputs("L1").build();
ComputationGraph net = new ComputationGraph(conf);
net.init();
net.setListeners(new StatsListener(ss), new ScoreIterationListener(1));
DataSetIterator iter = new IrisDataSetIterator(150, 150);
for (int i = 0; i < 100; i++) {
net.fit(iter);
}
}
@Test
public void testAutoAttach() throws Exception {
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().graphBuilder().addInputs("in")
.addLayer("L0", new DenseLayer.Builder().activation(Activation.TANH).nIn(4).nOut(4).build(),
"in")
.addLayer("L1", new OutputLayer.Builder().lossFunction(LossFunctions.LossFunction.MCXENT)
.activation(Activation.SOFTMAX).nIn(4).nOut(3).build(), "L0")
.setOutputs("L1").build();
ComputationGraph net = new ComputationGraph(conf);
net.init();
StatsStorage ss1 = new InMemoryStatsStorage();
net.setListeners(new StatsListener(ss1, 1, "ss1"));
DataSetIterator iter = new IrisDataSetIterator(150, 150);
for (int i = 0; i < 5; i++) {
net.fit(iter);
}
StatsStorage ss2 = new InMemoryStatsStorage();
net.setListeners(new StatsListener(ss2, 1, "ss2"));
for (int i = 0; i < 4; i++) {
net.fit(iter);
}
UIServer ui = UIServer.getInstance(true, null);
try {
((VertxUIServer) ui).autoAttachStatsStorageBySessionId(new Function<String, StatsStorage>() {
@Override
public StatsStorage apply(String s) {
if ("ss1".equals(s)) {
return ss1;
} else if ("ss2".equals(s)) {
return ss2;
}
return null;
}
});
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
String json1 = IOUtils.toString(new URL("http://localhost:9000/train/ss1/overview/data"),
StandardCharsets.UTF_8);
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
String json2 = IOUtils.toString(new URL("http://localhost:9000/train/ss2/overview/data"),
StandardCharsets.UTF_8);
assertNotEquals(json1, json2);
Map<String, Object> m1 = JsonMappers.getMapper().readValue(json1, Map.class);
Map<String, Object> m2 = JsonMappers.getMapper().readValue(json2, Map.class);
List<Object> s1 = (List<Object>) m1.get("scores");
List<Object> s2 = (List<Object>) m2.get("scores");
assertEquals(5, s1.size());
assertEquals(4, s2.size());
} finally {
ui.stop();
}
}
2019-06-06 15:21:15 +03:00
@Test
public void testUIAttachDetach() throws Exception {
StatsStorage ss = new InMemoryStatsStorage();
UIServer uiServer = UIServer.getInstance();
uiServer.attach(ss);
assertFalse(uiServer.getStatsStorageInstances().isEmpty());
uiServer.detach(ss);
assertTrue(uiServer.getStatsStorageInstances().isEmpty());
}
@Test
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
public void testUIServerStop() throws Exception {
2019-06-06 15:21:15 +03:00
UIServer uiServer = UIServer.getInstance(true, null);
assertTrue(uiServer.isMultiSession());
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
assertFalse(uiServer.isStopped());
long sleepMilliseconds = 1_000;
log.info("Waiting {} ms before stopping.", sleepMilliseconds);
Thread.sleep(sleepMilliseconds);
2019-06-06 15:21:15 +03:00
uiServer.stop();
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
assertTrue(uiServer.isStopped());
log.info("UI server is stopped. Waiting {} ms before starting new UI server.", sleepMilliseconds);
Thread.sleep(sleepMilliseconds);
uiServer = UIServer.getInstance(false, null);
assertFalse(uiServer.isMultiSession());
assertFalse(uiServer.isStopped());
log.info("Waiting {} ms before stopping.", sleepMilliseconds);
Thread.sleep(sleepMilliseconds);
uiServer.stop();
assertTrue(uiServer.isStopped());
}
@Test
public void testUIServerStopAsync() throws Exception {
UIServer uiServer = UIServer.getInstance(true, null);
assertTrue(uiServer.isMultiSession());
assertFalse(uiServer.isStopped());
long sleepMilliseconds = 1_000;
log.info("Waiting {} ms before stopping.", sleepMilliseconds);
Thread.sleep(sleepMilliseconds);
CountDownLatch latch = new CountDownLatch(1);
Promise<Void> promise = Promise.promise();
promise.future().compose(
success -> Future.future(prom -> latch.countDown()),
failure -> Future.future(prom -> latch.countDown())
);
uiServer.stopAsync(promise);
latch.await();
assertTrue(uiServer.isStopped());
log.info("UI server is stopped. Waiting {} ms before starting new UI server.", sleepMilliseconds);
Thread.sleep(sleepMilliseconds);
2019-06-06 15:21:15 +03:00
uiServer = UIServer.getInstance(false, null);
assertFalse(uiServer.isMultiSession());
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
log.info("Waiting {} ms before stopping.", sleepMilliseconds);
Thread.sleep(sleepMilliseconds);
uiServer.stop();
}
@Test
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
public void testUIStartPortAlreadyBound() throws InterruptedException {
assertThrows(DL4JException.class, () -> {
2021-03-16 11:57:24 +09:00
CountDownLatch latch = new CountDownLatch(1);
2021-03-16 11:57:24 +09:00
//Create HttpServer that binds the same port
int port = VertxUIServer.DEFAULT_UI_PORT;
Vertx vertx = Vertx.vertx();
vertx.createHttpServer()
.requestHandler(event -> {
})
2021-03-16 11:57:24 +09:00
.listen(port, result -> latch.countDown());
latch.await();
try {
//DL4JException signals that the port cannot be bound, UI server cannot start
UIServer.getInstance();
} finally {
vertx.close();
}
});
Fix UIServer features in multi-session mode, synchronous start and stop (#8856) * fix Freemarker version mismatch: change version requested in TrainModule to 2.3.23 (freemarker.version in pom.xml) Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix checking multi-session mode in VertxUIServer.getInstance. Tested multiple calls in TestVertxUIMultiSession. Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * extend timeout for manual UI tests from 30 to 600 seconds Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * start and stop UI server synchronously (wait until complete), tests Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix for auto-attaching StatsStorage given in VertxUIServer#getInstance(Integer, boolean, Function<String,StatsStorage>), test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * exception handling, test improvements Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * add asynchronous method to start UI server Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UIServer.getInstance() to return existing instance Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server language setting in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix UI server system tab not loading data in multi-session mode Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * undo added InterruptedException in UIServer.getInstance() Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * fix async stopping of UIServer.stopAsync(Promise<Void>), added test Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * restore the daemon thread style behaviour of UIServer: don't keep the process alive just because the UI is running Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu> * speed up and don't @Ignore tests in TestVertxUI and TestVertxUIMultiSession, put longer tests to separate class TestVertxUIManual Signed-off-by: Tamás Fenyvesi <tamas.fenyvesi@doknet.hu>
2020-04-23 02:26:51 +02:00
}
@Test
public void testUIStartAsync() throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
Promise<String> promise = Promise.promise();
promise.future().compose(
success -> Future.future(prom -> latch.countDown()),
failure -> Future.future(prom -> latch.countDown())
);
int port = VertxUIServer.DEFAULT_UI_PORT;
VertxUIServer.getInstance(port, false, null, promise);
latch.await();
if (promise.future().succeeded()) {
String deploymentId = promise.future().result();
log.debug("UI server deployed, deployment ID = {}", deploymentId);
} else {
log.debug("UI server failed to deploy.", promise.future().cause());
}
}
@Test
public void testUIShutdownHook() throws InterruptedException {
UIServer uIServer = UIServer.getInstance();
Thread shutdownHook = UIServer.getShutdownHook();
shutdownHook.start();
shutdownHook.join();
/*
* running the shutdown hook thread before the Runtime is terminated
* enables us to check if the UI server has been shut down or not
*/
assertTrue(uIServer.isStopped());
log.info("Deeplearning4j UI server stopped in shutdown hook.");
2019-06-06 15:21:15 +03:00
}
}