This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch NLPCRAFT-194
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-194 by this push:
     new db70a46  WIP.
db70a46 is described below

commit db70a461cf1f0844f7451ac5c08f065b0073b388
Author: Aaron Radzinski <[email protected]>
AuthorDate: Thu Dec 17 13:01:08 2020 -0800

    WIP.
---
 .../scala/org/apache/nlpcraft/examples/time/TimeModelApp.java    | 4 +++-
 .../apache/nlpcraft/model/tools/embedded/NCEmbeddedProbe.java    | 4 +++-
 .../model/tools/test/impl/NCTestAutoModelValidatorImpl.scala     | 9 +++++++--
 .../src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala   | 9 +++++----
 nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala  | 4 +++-
 .../scala/org/apache/nlpcraft/model/intent/dsl/NCDslSpec.scala   | 5 +++--
 6 files changed, 24 insertions(+), 11 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/TimeModelApp.java 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/TimeModelApp.java
index d6ddf54..8f52122 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/TimeModelApp.java
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/TimeModelApp.java
@@ -19,6 +19,8 @@ package org.apache.nlpcraft.examples.time;
 
 import org.apache.nlpcraft.model.tools.embedded.NCEmbeddedProbe;
 
+import java.util.Collections;
+
 /**
  * An app that demo the usage of embedded probe. This is an alternative way to
  * deploy data models using embedded probe that can run in any host JVM 
application.
@@ -32,7 +34,7 @@ public class TimeModelApp {
      */
     public static void main(String[] args) throws Exception {
         // Start the data probe "in place" with 'TimeModel' model.
-        if (NCEmbeddedProbe.start(null, TimeModel.class.getName()))
+        if (NCEmbeddedProbe.start(null, 
Collections.singletonList(TimeModel.class.getName())))
             Thread.currentThread().join();
     }
 }
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/embedded/NCEmbeddedProbe.java
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/embedded/NCEmbeddedProbe.java
index 7786ea4..3ab85d8 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/embedded/NCEmbeddedProbe.java
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/embedded/NCEmbeddedProbe.java
@@ -21,6 +21,8 @@ import org.apache.nlpcraft.common.*;
 import org.apache.nlpcraft.model.tools.test.*;
 import org.apache.nlpcraft.probe.*;
 import org.apache.nlpcraft.probe.mgrs.nlp.*;
+
+import java.util.Collection;
 import java.util.concurrent.*;
 import java.util.function.*;
 
@@ -93,7 +95,7 @@ public class NCEmbeddedProbe {
      * @throws NCException Thrown in case of any errors starting the data 
probe.
      * @return Whether or not probe started ok.
      */
-    public static boolean start(String cfgFile, String... mdlClasses) {
+    public static boolean start(String cfgFile, Collection<String> mdlClasses) 
{
         CompletableFuture<Integer> fut = new CompletableFuture<>();
 
         NCProbeBoot$.MODULE$.startEmbedded(cfgFile, mdlClasses, fut);
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/impl/NCTestAutoModelValidatorImpl.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/impl/NCTestAutoModelValidatorImpl.scala
index 2a72c77..30dca04 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/impl/NCTestAutoModelValidatorImpl.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/impl/NCTestAutoModelValidatorImpl.scala
@@ -24,6 +24,8 @@ import 
org.apache.nlpcraft.model.tools.embedded.NCEmbeddedProbe
 import org.apache.nlpcraft.model.tools.test.NCTestClientBuilder
 import org.apache.nlpcraft.probe.mgrs.model.NCModelManager
 
+import scala.collection.JavaConverters._
+
 /**
   * Implementation for `NCTestAutoModelValidator` class.
   */
@@ -38,10 +40,13 @@ private [test] object NCTestAutoModelValidatorImpl extends 
LazyLogging {
      */
     @throws[Exception]
     def isValid: Boolean = {
-        val classes = U.sysEnv(PROP_MODELS).orNull
+        val classes = U.sysEnv(PROP_MODELS) match {
+            case Some(s) ⇒ U.splitTrimFilter(s, ",")
+            case None ⇒ null
+        }
         val cfgFile = U.sysEnv(PROP_PROBE_CFG).orNull
 
-        if (NCEmbeddedProbe.start(cfgFile, classes))
+        if (NCEmbeddedProbe.start(cfgFile, classes.asJava))
             try
                 process(NCModelManager.getAllModels().map(p ⇒ p.model.getId → 
p.samples.toMap).toMap.filter(_._2.nonEmpty))
             finally
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
index 96120b9..a54e22f 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/NCProbeBoot.scala
@@ -100,7 +100,6 @@ private [probe] object NCProbeBoot extends LazyLogging with 
NCOpenCensusTrace {
             withValue(s"$prefix.token", fromAnyRef("3141592653589793")).
             withValue(s"$prefix.upLink", fromAnyRef("localhost:8201")).
             withValue(s"$prefix.downLink", fromAnyRef("localhost:8202")).
-            withValue(s"$prefix.model", fromAnyRef(null)).
             withValue(s"$prefix.models", fromAnyRef("")).
             withValue(s"$prefix.lifecycle", fromIterable(Seq().asJava)).
             withValue(s"$prefix.resultMaxSizeBytes", fromAnyRef(1048576)).
@@ -156,6 +155,8 @@ private [probe] object NCProbeBoot extends LazyLogging with 
NCOpenCensusTrace {
             val models: String = getString(s"$prefix.models")
             val lifecycle: Seq[String] = getStringList(s"$prefix.lifecycle")
         }
+
+        println(s"Models -> ${Cfg.models}")
         
         ProbeConfig(
             Cfg.id,
@@ -337,7 +338,7 @@ private [probe] object NCProbeBoot extends LazyLogging with 
NCOpenCensusTrace {
       */
     private [probe] def startEmbedded(
         cfgFile: String,
-        mdlClasses: Array[String],
+        mdlClasses: java.util.Collection[String],
         fut: CompletableFuture[Integer]): Unit = {
         checkStarted()
     
@@ -351,7 +352,7 @@ private [probe] object NCProbeBoot extends LazyLogging with 
NCOpenCensusTrace {
                 Some(
                     ConfigFactory.empty().withValue(
                         "nlpcraft.probe.models",
-                        fromAnyRef(mdlClasses.mkString(","))
+                        fromAnyRef(mdlClasses.asScala.mkString(","))
                     )
                 )
         )
@@ -449,7 +450,7 @@ private [probe] object NCProbeBoot extends LazyLogging with 
NCOpenCensusTrace {
         tbl += (s"${B}Down-Link$RST", cfg.downLinkString)
         tbl += (s"${B}Up-Link$RST", cfg.upLinkString)
         tbl += (s"${B}Lifecycle$RST", cfg.lifecycle)
-        tbl += (s"${B}Models (${cfg.modelsSeq.size})$RST" , cfg.modelsSeq)
+        tbl += (s"${B}Models (${cfg.modelsSeq.size})$RST", cfg.modelsSeq)
         tbl += (s"${B}JARs Folder$RST", cfg.jarsFolder.getOrElse(""))
 
         tbl.info(logger, Some("Probe Configuration:"))
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala
index a48c934..8bb384b 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala
@@ -23,6 +23,8 @@ import org.apache.nlpcraft.probe.mgrs.model.NCModelManager
 import org.junit.jupiter.api.TestInstance.Lifecycle
 import org.junit.jupiter.api._
 
+import java.util.Collections
+
 /**
   *
   */
@@ -74,7 +76,7 @@ abstract class NCTestContext {
 
                 probeStarted = false
 
-                if (NCEmbeddedProbe.start(null, ann.model().getName)) {
+                if (NCEmbeddedProbe.start(null, 
Collections.singletonList(ann.model().getName))) {
                     probeStarted = true
                 
                     if (ann.startClient()) {
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslSpec.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslSpec.scala
index 8dc75c5..8487dc5 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslSpec.scala
@@ -18,13 +18,14 @@
 package org.apache.nlpcraft.model.intent.dsl
 
 import java.io.IOException
-
 import org.apache.nlpcraft.common.NCException
 import org.apache.nlpcraft.model.tools.embedded.NCEmbeddedProbe
 import org.apache.nlpcraft.model.tools.test.{NCTestClient, NCTestClientBuilder}
 import org.junit.jupiter.api.Assertions.assertTrue
 import org.junit.jupiter.api.{AfterEach, BeforeEach, Test}
 
+import java.util.Collections
+
 /**
  * DSL test model test. Make sure to start up the NLPCraft server before 
running this test.
  */
@@ -36,7 +37,7 @@ class NCDslSpec {
     @throws[IOException]
     private[dsl] def setUp(): Unit = {
         // Start embedded probe with the test model.
-        if (NCEmbeddedProbe.start(null, classOf[NCDslTestModel].getName)) {
+        if (NCEmbeddedProbe.start(null, 
Collections.singletonList(classOf[NCDslTestModel].getName))) {
             cli = new NCTestClientBuilder().newBuilder.build
 
             cli.open("nlpcraft.dsl.test")

Reply via email to