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 2021/07/01 20:49:11 UTC
[incubator-nlpcraft] branch NLPCRAFT-353 updated: WIP NLPCRAFT-353.
This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-353
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-353 by this push:
new 0b015a8 WIP NLPCRAFT-353.
0b015a8 is described below
commit 0b015a82b305824e8d59e388324e78b3902486ea
Author: Aaron Radzinzski <ar...@datalingvo.com>
AuthorDate: Thu Jul 1 13:48:56 2021 -0700
WIP NLPCRAFT-353.
---
.../nlpcraft/model/tools/cmdline/NCCli.scala | 36 ++++++++++++++++------
.../model/tools/cmdline/NCCliCommands.scala | 18 +++++++++++
2 files changed, 44 insertions(+), 10 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
index 5836985..346c210 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
@@ -112,7 +112,8 @@ object NCCli extends NCCliBase {
var userEmail: Option[String] = None, // Email of the user with 'accessToken'.
var serverLog: Option[File] = None,
var probeLog: Option[File] = None,
- var probes: List[Probe] = Nil // List of connected probes.
+ var probes: List[Probe] = Nil, // List of connected probes.
+ var lastArgs: Option[Seq[Argument]] = None
) {
/**
* Resets server sub-state.
@@ -145,10 +146,6 @@ object NCCli extends NCCliBase {
private final val CALL_CMD = CMDS.find(_.name == "call").get
private final val ASK_CMD = CMDS.find(_.name == "ask").get
private final val SUGSYN_CMD = CMDS.find(_.name == "sugsyn").get
- private final val STOP_SRV_CMD = CMDS.find(_.name == "stop-server").get
- private final val SRV_INFO_CMD = CMDS.find(_.name == "info-server").get
- private final val PRB_INFO_CMD = CMDS.find(_.name == "info-probe").get
- private final val STOP_PRB_CMD = CMDS.find(_.name == "stop-probe").get
/**
* @param cmd
@@ -629,6 +626,22 @@ object NCCli extends NCCliBase {
* @param args Arguments, if any, for this command.
* @param repl Whether or not running from REPL.
*/
+ private [cmdline] def cmdRestartProbe(cmd: Command, args: Seq[Argument], repl: Boolean): Unit = {
+ if (!repl)
+ error(s"This command only works in REPL mode - use ${c("'stop-probe'")} and ${c("'start-probe'")} commands instead.")
+ else if (state.lastArgs.isEmpty)
+ error(s"Probe has not been previously started - see ${c("'start-probe'")} command.")
+ else {
+ cmdStopProbe(CMDS.find(_.name == "stop-probe").get, Seq.empty[Argument], repl)
+ cmdStartProbe(CMDS.find(_.name == "start-probe").get, state.lastArgs.get, repl)
+ }
+ }
+
+ /**
+ * @param cmd Command descriptor.
+ * @param args Arguments, if any, for this command.
+ * @param repl Whether or not running from REPL.
+ */
private [cmdline] def cmdStartProbe(cmd: Command, args: Seq[Argument], repl: Boolean): Unit = {
// Ensure that there is a local server running since probe
// cannot finish its start unless there's a server to connect to.
@@ -816,6 +829,9 @@ object NCCli extends NCCliBase {
// Log all connected probes (including this one).
logConnectedProbes()
+ // Capture this probe start arguments (used in restart command).
+ state.lastArgs = Some(args)
+
showTip()
}
}
@@ -1141,8 +1157,8 @@ object NCCli extends NCCliBase {
* @param repl Whether or not executing from REPL.
*/
private [cmdline] def cmdStop(cmd: Command, args: Seq[Argument], repl: Boolean): Unit = {
- doCommand(Seq(STOP_SRV_CMD.name), repl)
- doCommand(Seq(STOP_PRB_CMD.name), repl)
+ cmdStopServer(CMDS.find(_.name == "stop-server").get, Seq.empty[Argument], repl)
+ cmdStopProbe(CMDS.find(_.name == "stop-probe").get, Seq.empty[Argument], repl)
}
/**
@@ -1503,8 +1519,8 @@ object NCCli extends NCCliBase {
* @param repl Whether or not executing from REPL.
*/
private [cmdline] def cmdInfo(cmd: Command, args: Seq[Argument], repl: Boolean): Unit = {
- doCommand(Seq(SRV_INFO_CMD.name), repl)
- doCommand(Seq(PRB_INFO_CMD.name), repl)
+ cmdInfoServer(CMDS.find(_.name == "info-server").get, Seq.empty[Argument], repl)
+ cmdInfoProbe(CMDS.find(_.name == "info-probe").get, Seq.empty[Argument], repl)
}
/**
@@ -2573,7 +2589,7 @@ object NCCli extends NCCliBase {
)
logln()
- logln(s"${y("Tip:")} Hit ${rv(bo(" Tab "))} for commands, parameters and paths suggestions and completion.")
+ logln(s"${y("Tip:")} Hit ${rv(bo(" Tab "))} for commands, parameters and paths completion.")
logln(s" Type '${c("help")}' to get help and ${rv(bo(" ↑ "))} or ${rv(bo(" ↓ "))} to scroll through history.")
logln(s" Type '${c("quit")}' to exit.")
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala
index cc39426..b465ab5 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala
@@ -814,6 +814,24 @@ private [cmdline] object NCCliCommands {
)
),
Command(
+ name = "restart-probe",
+ group = "1. Server & Probe Commands",
+ synopsis = s"Restarts local probe (REPL mode only).",
+ desc = Some(
+ s"Restart local probe with same parameters as the last start. Works only in REPL mode and only if local " +
+ s"probe was previously started using ${c("'start-probe")} command. This command provides a " +
+ s"convenient way to quickly restart the probe to reload the model during model development and testing."
+ ),
+ body = NCCli.cmdRestartProbe,
+ params = Seq(),
+ examples = Seq(
+ Example(
+ usage = Seq(s"> restart-probe"),
+ desc = "Restarts local probe with the same parameters as the previous start."
+ )
+ )
+ ),
+ Command(
name = "test-model",
group = "3. Miscellaneous",
synopsis = s"Runs ${y("'NCTestAutoModelValidator'")} model auto-validator.",