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

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


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

commit 61c72e826abf417fc1359884519bb0e029613019
Author: Sergey Kamov <[email protected]>
AuthorDate: Fri Aug 28 16:04:02 2020 +0300

    WIP.
---
 .../nlpcraft/common/inspections/NCInspection.scala   | 11 +++++------
 .../nlpcraft/common/inspections/NCInspector.scala    |  7 +++++++
 .../nlpcraft/probe/mgrs/deploy/NCDeployManager.scala |  2 +-
 .../mgrs/inspections/NCProbeInspectionManager.scala  |  3 ++-
 .../inspections/inspectors/NCInspectorIntents.scala  |  5 +++--
 .../inspections/inspectors/NCInspectorMacros.scala   |  5 +++--
 .../inspections/inspectors/NCInspectorSynonyms.scala |  5 +++--
 .../inspectors/NCInspectorSynonymsSuggestions.scala  |  5 +++--
 .../inspections/NCServerInspectorManager.scala       |  7 +++----
 .../inspectors/NCInspectorSynonymsSuggestions.scala  |  7 ++++---
 .../nlpcraft/server/probe/NCProbeManager.scala       | 20 ++------------------
 .../apache/nlpcraft/server/rest/NCBasicRestApi.scala |  5 +----
 12 files changed, 37 insertions(+), 45 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections/NCInspection.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections/NCInspection.scala
index 20078af..e44d31b 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections/NCInspection.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections/NCInspection.scala
@@ -39,7 +39,7 @@ object NCInspection {
     ): NCInspection = {
         def convert[T](optSeq: Option[Seq[T]]): java.util.List[T] = 
optSeq.getOrElse(Seq.empty).asJava
 
-        new NCInspection(
+        NCInspection(
             errors = convert(errors),
             warnings = convert(warnings),
             suggestions = convert(suggestions),
@@ -47,11 +47,10 @@ object NCInspection {
         )
     }
 
-    def apply(
-        errors: Option[Seq[String]],
-        warnings: Option[Seq[String]],
-        suggestions: Option[Seq[AnyRef]]
-    ): NCInspection = apply(errors, warnings, suggestions, None)
+    def apply(errors: Option[Seq[String]], warnings: Option[Seq[String]], 
suggestions: Option[Seq[AnyRef]]): NCInspection =
+        apply(errors, warnings, suggestions, None)
+
+    def apply(data: AnyRef): NCInspection = apply(None, None, None, Some(data))
 
     def apply(): NCInspection  = NCInspection(None, None, None, None)
 }
\ No newline at end of file
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections/NCInspector.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections/NCInspector.scala
index 824c4f6..a0d5310 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections/NCInspector.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections/NCInspector.scala
@@ -19,6 +19,13 @@ package org.apache.nlpcraft.common.inspections
 
 import io.opencensus.trace.Span
 
+// TODO:
 trait NCInspector {
+    /**
+      *
+      * @param mdlId
+      * @param prevLayerInspection
+      * @param parent
+      */
     def inspect(mdlId: String, prevLayerInspection: Option[NCInspection] = 
None, parent: Span = null): NCInspection
 }
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
index f1d36d9..466b51f 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
@@ -18,7 +18,7 @@
 package org.apache.nlpcraft.probe.mgrs.deploy
 
 import java.io._
-import java.util.jar.{JarInputStream => JIS}
+import java.util.jar.{JarInputStream ⇒ JIS}
 
 import io.opencensus.trace.Span
 import org.apache.nlpcraft.common._
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/NCProbeInspectionManager.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/NCProbeInspectionManager.scala
index e5fd81b..91963fe 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/NCProbeInspectionManager.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/NCProbeInspectionManager.scala
@@ -24,6 +24,7 @@ import org.apache.nlpcraft.common.{NCE, NCService}
 import org.apache.nlpcraft.model.opencensus.stats.NCOpenCensusModelStats
 import org.apache.nlpcraft.probe.mgrs.inspections.inspectors._
 
+// TODO:
 object NCProbeInspectionManager extends NCService with NCOpenCensusModelStats {
     private final val INSPECTORS =
         Map(
@@ -49,7 +50,7 @@ object NCProbeInspectionManager extends NCService with 
NCOpenCensusModelStats {
 
     @throws[NCE]
     def inspect(mdlId: String, types: Seq[NCInspectionType], parent: Span = 
null): Map[NCInspectionType, NCInspection] =
-        startScopedSpan("inspect", parent) { _ ⇒
+        startScopedSpan("inspect", parent, "modelId" → mdlId, "types" → 
types.map(_.toString)) { _ ⇒
             types.map(t ⇒  t → INSPECTORS(t).inspect(mdlId, parent = 
parent)).toMap
         }
 }
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorIntents.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorIntents.scala
index bf0eb7e..a973c21 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorIntents.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorIntents.scala
@@ -28,11 +28,12 @@ import org.apache.nlpcraft.probe.mgrs.model.NCModelManager
 import scala.collection.JavaConverters._
 import scala.collection._
 
+// TODO:
 object NCInspectorIntents extends NCService with NCInspector {
     private final val SEPARATORS = Seq('?', ',', '.', '-', '!')
 
     override def inspect(mdlId: String, prevLayerInspection: 
Option[NCInspection], parent: Span = null): NCInspection =
-        startScopedSpan("inspect", parent) { _ ⇒
+        startScopedSpan("inspect", parent, "modelId" → mdlId) { _ ⇒
             val mdl = NCModelManager.getModel(mdlId).getOrElse(throw new 
NCE(s"Model not found: '$mdlId'")).model
 
             val res = NCIntentScanner.scanIntentsSamples(mdl.proxy)
@@ -62,6 +63,6 @@ object NCInspectorIntents extends NCService with NCInspector {
                         warns += s"Sample: '$s' doesn't contain synonyms"
                 }
 
-            NCInspection(errors = None, warnings = if (warns.isEmpty) None 
else Some(warns), suggestions = None, data = None)
+            NCInspection(errors = None, warnings = if (warns.isEmpty) None 
else Some(warns), suggestions = None)
         }
 }
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorMacros.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorMacros.scala
index 589abda..ba2c8bc 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorMacros.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorMacros.scala
@@ -24,9 +24,10 @@ import org.apache.nlpcraft.probe.mgrs.model.NCModelManager
 
 import scala.collection.JavaConverters._
 
+// TODO:
 object NCInspectorMacros extends NCService with NCInspector {
     override def inspect(mdlId: String, prevLayerInspection: 
Option[NCInspection], parent: Span = null): NCInspection =
-        startScopedSpan("inspect", parent) { _ ⇒
+        startScopedSpan("inspect", parent, "modelId" → mdlId) { _ ⇒
             val mdl = NCModelManager.getModel(mdlId).getOrElse(throw new 
NCE(s"Model not found: '$mdlId'")).model
 
             val syns = mdl.getElements.asScala.flatMap(_.getSynonyms.asScala)
@@ -37,6 +38,6 @@ object NCInspectorMacros extends NCService with NCInspector {
                 flatMap(m ⇒ if (syns.exists(_.contains(m))) None else 
Some(s"Macro is not used: $m")).
                 toSeq
 
-            NCInspection(errors = None, warnings = if (warns.isEmpty) None 
else Some(warns), suggestions = None, data = None)
+            NCInspection(errors = None, warnings = if (warns.isEmpty) None 
else Some(warns), suggestions = None)
         }
 }
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorSynonyms.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorSynonyms.scala
index f8ba649..bee9648 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorSynonyms.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorSynonyms.scala
@@ -26,11 +26,12 @@ import org.apache.nlpcraft.probe.mgrs.model.NCModelManager
 import scala.collection.JavaConverters._
 import scala.collection.mutable
 
+// TODO:
 object NCInspectorSynonyms extends NCService with NCInspector {
     private final val TOO_MANY_SYNS = 10000
 
     override def inspect(mdlId: String, prevLayerInspection: 
Option[NCInspection], parent: Span = null): NCInspection =
-        startScopedSpan("inspect", parent) { _ ⇒
+        startScopedSpan("inspect", parent, "modelId" → mdlId) { _ ⇒
             val mdl = NCModelManager.getModel(mdlId).getOrElse(throw new 
NCE(s"Model not found: '$mdlId'")).model
 
             val warns = mutable.ArrayBuffer.empty[String]
@@ -58,6 +59,6 @@ object NCInspectorSynonyms extends NCService with NCInspector 
{
                     warns += s"Element: '$elemId' has same synonyms with 
'$intersects'"
             }
 
-            NCInspection(errors = None, warnings = if (warns.isEmpty) None 
else Some(warns), suggestions = None, data = None)
+            NCInspection(errors = None, warnings = if (warns.isEmpty) None 
else Some(warns), suggestions = None)
         }
 }
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorSynonymsSuggestions.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorSynonymsSuggestions.scala
index 15c6512..76bddb4 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorSynonymsSuggestions.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections/inspectors/NCInspectorSynonymsSuggestions.scala
@@ -27,9 +27,10 @@ import org.apache.nlpcraft.probe.mgrs.model.NCModelManager
 
 import scala.collection.JavaConverters._
 
+// TODO:
 object NCInspectorSynonymsSuggestions extends NCService with NCInspector {
     override def inspect(mdlId: String, prevLayerInspection: 
Option[NCInspection], parent: Span = null): NCInspection =
-        startScopedSpan("inspect", parent) { _ ⇒
+        startScopedSpan("inspect", parent, "modelId" → mdlId) { _ ⇒
             val mdl = NCModelManager.getModel(mdlId).getOrElse(throw new 
NCE(s"Model not found: '$mdlId'")).model
 
             val data = new util.HashMap[String, Any]()
@@ -38,6 +39,6 @@ object NCInspectorSynonymsSuggestions extends NCService with 
NCInspector {
             data.put("elementsSynonyms", mdl.getElements.asScala.map(p ⇒ 
p.getId → p.getSynonyms).toMap.asJava)
             data.put("intentsSamples", 
NCIntentScanner.scanIntentsSamples(mdl.proxy).samples.map(p ⇒ p._1 → 
p._2.asJava).asJava)
 
-            NCInspection(errors = None, warnings = None, suggestions = None, 
data = Some(data))
+            NCInspection(data = data)
         }
 }
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/inspections/NCServerInspectorManager.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/inspections/NCServerInspectorManager.scala
index 8d42c7e..4761039 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/inspections/NCServerInspectorManager.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/inspections/NCServerInspectorManager.scala
@@ -24,14 +24,14 @@ import org.apache.nlpcraft.common.{NCE, NCService}
 import org.apache.nlpcraft.server.inspections.inspectors._
 import org.apache.nlpcraft.server.probe.NCProbeManager
 
-import scala.collection.JavaConverters.asScalaBufferConverter
+import scala.collection.JavaConverters._
 import scala.collection._
 import scala.concurrent.ExecutionContext.Implicits.global
 import scala.concurrent.{Future, Promise}
 import scala.util.{Failure, Success}
 
 /**
-  * TODO: check all texts
+  * TODO:  + check all texts
   */
 object NCServerInspectorManager extends NCService {
     private final val INSPECTORS =
@@ -77,12 +77,11 @@ object NCServerInspectorManager extends NCService {
                                 if (seq.isEmpty) None else Some(seq)
                             }
 
+                            // Data  - we don't need pass it on last step.
                             typ → NCInspection(
                                 errors = union(inspectionProbe.errors, 
inspectionSrv.errors),
                                 warnings = union(inspectionProbe.warnings, 
inspectionSrv.warnings),
                                 suggestions = 
union(inspectionProbe.suggestions, inspectionSrv.suggestions),
-                                // Don't need pass this data on last step.
-                                data = None
                             )
                         }
 
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/inspections/inspectors/NCInspectorSynonymsSuggestions.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/inspections/inspectors/NCInspectorSynonymsSuggestions.scala
index 3c45d3c..f210186 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/inspections/inspectors/NCInspectorSynonymsSuggestions.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/inspections/inspectors/NCInspectorSynonymsSuggestions.scala
@@ -42,6 +42,7 @@ import scala.collection.JavaConverters._
 import scala.collection.{Seq, mutable}
 import scala.concurrent.ExecutionContext.Implicits.global
 
+// TODO:
 object NCInspectorSynonymsSuggestions extends NCService with NCInspector {
     // For context word server requests.
     private final val MAX_LIMIT: Int = 10000
@@ -134,7 +135,7 @@ object NCInspectorSynonymsSuggestions extends NCService 
with NCInspector {
     }
 
     override def inspect(mdlId: String, prevLayerInspection: 
Option[NCInspection], parent: Span = null): NCInspection =
-        startScopedSpan("inspect", parent) { _ ⇒
+        startScopedSpan("inspect", parent, "modelId" → mdlId) { _ ⇒
             val m: util.Map[String, AnyRef] =
                 prevLayerInspection.
                     getOrElse(throw new NCE(s"Missed previous inspection data 
for model: $mdlId")).
@@ -397,7 +398,7 @@ object NCInspectorSynonymsSuggestions extends NCService 
with NCInspector {
                         }
                     })
 
-                    val resJs: util.Map[String, JList[util.HashMap[String, 
Any]]] =
+                    val resJ: util.Map[String, JList[util.HashMap[String, 
Any]]] =
                         res.map { case (id, data) ⇒
                             id → data.map(d ⇒ {
                                 val m = new util.HashMap[String, Any]()
@@ -411,7 +412,7 @@ object NCInspectorSynonymsSuggestions extends NCService 
with NCInspector {
                         }.asJava
 
                     NCInspection(
-                        errors = None, warnings = if (warns.isEmpty) None else 
Some(warns), suggestions = Some(Seq(resJs))
+                        errors = None, warnings = if (warns.isEmpty) None else 
Some(warns), suggestions = Some(Seq(resJ))
                     )
                 }
             }
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala
index b9c4d8c..0f99b5b 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala
@@ -14,22 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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.
- */
 
 package org.apache.nlpcraft.server.probe
 
@@ -73,7 +57,7 @@ import scala.util.{Failure, Success}
   */
 object NCProbeManager extends NCService {
     private final val GSON = new Gson()
-    private val TYPE_INSPECTION_RESP = new TypeToken[util.Map[String, 
NCInspection]]() {}.getType
+    private final val TYPE_INSPECTION_RESP = new TypeToken[util.Map[String, 
NCInspection]]() {}.getType
 
     // Type safe and eager configuration container.
     private[probe] object Config extends NCConfigurable {
@@ -1002,7 +986,7 @@ object NCProbeManager extends NCService {
                     sendToProbe(probe.probeKey, msg, parent)
 
                     promise.future
-                case None ⇒ throw new NCE(s"Probe not found for model: $mdlId")
+                case None ⇒ throw new NCE(s"Probe not found for model: 
'$mdlId''")
             }
         }
 }
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
index 84256be..96bdaa4 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
@@ -48,8 +48,6 @@ import scala.concurrent.Future
 import akka.http.scaladsl.coding.Coders
 import org.apache.nlpcraft.common.inspections.NCInspectionType
 
-import scala.concurrent.duration.DurationInt
-
 /**
   * REST API default implementation.
   */
@@ -1772,7 +1770,6 @@ class NCBasicRestApi extends NCRestApi with LazyLogging 
with NCOpenCensusTrace w
                     } ~
                     post {
                         encodeResponseWith(Coders.NoCoding, Coders.Gzip) {
-                            withRequestTimeout(600.seconds) {
                             withRequestTimeoutResponse(_ ⇒ timeoutResp) {
                                 path(API / "signin") { 
withLatency(M_SIGNIN_LATENCY_MS, signin$) } ~
                                 path(API / "signout") { 
withLatency(M_SIGNOUT_LATENCY_MS, signout$) } ~ {
@@ -1816,7 +1813,7 @@ class NCBasicRestApi extends NCRestApi with LazyLogging 
with NCOpenCensusTrace w
                                         }
                                 }}
                             }
-                        }}
+                        }
                     }
                 )
             }

Reply via email to