You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2020/08/30 01:25:40 UTC
[incubator-nlpcraft] branch NLPCRAFT-41-1 updated: Inspection
design proposal.
This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-41-1
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-41-1 by this push:
new 6c64680 Inspection design proposal.
6c64680 is described below
commit 6c64680bd0e93e0f19dfa6763da644b7df392647
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Sat Aug 29 18:25:28 2020 -0700
Inspection design proposal.
---
.../org/apache/nlpcraft/common/NCService.scala | 7 +--
.../common/inspections2/NCInspection.scala | 65 ++++++++++++++++++++
.../inspections2/NCInspectionParameter.scala | 59 ++++++++++++++++++
.../common/inspections2/NCInspectionResult.scala | 69 ++++++++++++++++++++++
.../org/apache/nlpcraft/common/util/NCUtils.scala | 4 --
.../mgrs/inspections2/NCInspectionManager.scala | 50 ++++++++++++++++
.../server/inspections2/NCInspectionManager.scala | 57 ++++++++++++++++++
7 files changed, 303 insertions(+), 8 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/NCService.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/NCService.scala
index 365a98f..3d9211b 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/NCService.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/NCService.scala
@@ -28,7 +28,7 @@ import scala.compat.Platform._
* extend this class are typically called 'managers'.
*/
abstract class NCService extends LazyLogging with NCOpenCensusTrace {
- private val startMsec = currentTime
+ private val startMs = currentTime
@volatile private var started = false
@@ -50,13 +50,12 @@ abstract class NCService extends LazyLogging with NCOpenCensusTrace {
started = true
- val dur = s"[${currentTime - startMsec}ms]"
+ val dur = s"[${currentTime - startMs}ms]"
logger.info(s"$clsName started $dur")
addTags(currentSpan(),
- "startDurationMs" → (currentTime - startMsec),
- "state" → started
+ "startDurationMs" → (currentTime - startMs), "state" → started
)
this
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections2/NCInspection.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections2/NCInspection.scala
new file mode 100644
index 0000000..74bd02a
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections2/NCInspection.scala
@@ -0,0 +1,65 @@
+/*
+ * 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.common.inspections2
+
+import io.opencensus.trace.Span
+
+/**
+ * Inspection descriptor.
+ */
+trait NCInspection {
+ /**
+ * Globally unique, internal inspection ID.
+ *
+ * @return
+ */
+ def id(): String
+
+ /**
+ * User-visible name of the inspection.
+ *
+ * @return
+ */
+ def name(): String
+
+ /**
+ * Short, one-line, description.
+ *
+ * @return
+ */
+ def synopsis(): String
+
+ /**
+ *
+ * @return
+ */
+ def parameters(): Seq[NCInspectionParameter]
+
+ /**
+ * Full description of this inspection additionally to the synopsis.
+ *
+ * @return
+ */
+ def description(): Option[String]
+
+ /**
+ *
+ * @return
+ */
+ def isServerSide: Boolean
+}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections2/NCInspectionParameter.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections2/NCInspectionParameter.scala
new file mode 100644
index 0000000..9eea5ec
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections2/NCInspectionParameter.scala
@@ -0,0 +1,59 @@
+/*
+ * 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.common.inspections2
+
+/**
+ * Parameter descriptor for the inspection.
+ */
+trait NCInspectionParameter {
+ /**
+ *
+ * @return
+ */
+ def id(): String
+
+ /**
+ *
+ * @return
+ */
+ def name(): String
+
+ /**
+ *
+ * @return
+ */
+ def value(): Option[String]
+
+ /**
+ *
+ * @return
+ */
+ def valueType(): Option[String]
+
+ /**
+ *
+ * @return
+ */
+ def synopsis(): String
+
+ /**
+ *
+ * @return
+ */
+ def description(): Option[String]
+}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections2/NCInspectionResult.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections2/NCInspectionResult.scala
new file mode 100644
index 0000000..086345b
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/inspections2/NCInspectionResult.scala
@@ -0,0 +1,69 @@
+/*
+ * 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.common.inspections2
+
+/**
+ *
+ */
+trait NCInspectionResult {
+ /**
+ *
+ */
+ def inspectionId();
+
+ /**
+ *
+ */
+ def modelId();
+
+ /**
+ *
+ * @return
+ */
+ def inspectionArguments(): String
+
+ /**
+ *
+ * @return
+ */
+ def durationMs(): Long
+
+ /**
+ *
+ * @return
+ */
+ def timestamp(): Long
+
+ /**
+ *
+ * @return
+ */
+ def errors(): java.util.List[String]
+
+ /**
+ *
+ * @return
+ */
+ def warnings(): java.util.List[String]
+
+ /**
+ *
+ * @return
+ */
+ def suggestions(): java.util.List[String]
+}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
index e43c00a..e915111 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
@@ -1150,8 +1150,6 @@ object NCUtils extends LazyLogging {
def DAYS: Int = v * 1000 * 60 * 60 * 24
- def msecs: Int = MSECS
-
def ms: Int = MS
def secs: Int = SECS
@@ -1181,8 +1179,6 @@ object NCUtils extends LazyLogging {
def DAYS: Long = v * 1000 * 60 * 60 * 24
- def msecs: Long = MSECS
-
def ms: Long = MS
def secs: Long = SECS
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections2/NCInspectionManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections2/NCInspectionManager.scala
new file mode 100644
index 0000000..8f8ff7a
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/inspections2/NCInspectionManager.scala
@@ -0,0 +1,50 @@
+/*
+ * 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.probe.mgrs.inspections2
+
+import org.apache.nlpcraft.common.NCService
+import org.apache.nlpcraft.model.opencensus.stats.NCOpenCensusModelStats
+import io.opencensus.trace.Span
+import org.apache.nlpcraft.common.inspections2.NCInspectionResult
+
+/**
+ *
+ */
+object NCInspectionManager extends NCService with NCOpenCensusModelStats {
+ override def start(parent: Span): NCService = startScopedSpan("start", parent) { _ ⇒
+ // TODO
+
+ super.start(parent)
+ }
+
+ override def stop(parent: Span): Unit = startScopedSpan("stop", parent) { _ ⇒
+ super.stop()
+
+ // TODO
+ }
+
+ /**
+ *
+ * @param mdlId Model ID.
+ * @param inspId Inspection ID.
+ * @param inspArgs Inspection arguments as JSON string.
+ * @param parent Optional parent trace span.
+ * @return
+ */
+ def inspect(mdlId: String, inspId: String, inspArgs: String, parent: Span = null): NCInspectionResult = ???
+}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/inspections2/NCInspectionManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/inspections2/NCInspectionManager.scala
new file mode 100644
index 0000000..d81bfe1
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/inspections2/NCInspectionManager.scala
@@ -0,0 +1,57 @@
+/*
+ * 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.inspections2
+
+import org.apache.nlpcraft.common.NCService
+import io.opencensus.trace.Span
+import org.apache.nlpcraft.common.inspections2.{NCInspection, NCInspectionResult}
+
+/**
+ *
+ */
+object NCInspectionManager extends NCService {
+ override def start(parent: Span): NCService = startScopedSpan("start", parent) { _ ⇒
+ // TODO
+
+ super.start(parent)
+ }
+
+ override def stop(parent: Span): Unit = startScopedSpan("stop", parent) { _ ⇒
+ super.stop()
+
+ // TODO
+ }
+
+ /**
+ *
+ * @param mdlId Model ID.
+ * @param inspId Inspection ID.
+ * @param inspArgs Inspection arguments as JSON string.
+ * @param parent Optional parent trace span.
+ * @return
+ */
+ def inspect(mdlId: String, inspId: String, inspArgs: String, parent: Span = null): NCInspectionResult = ???
+
+ /**
+ * Gets all supported server and probe inspections.
+ *
+ * @param parent
+ * @return
+ */
+ def getInspections(parent: Span = null): List[NCInspection] = ???
+}