Rasa: Error in 'Building a Simple Bot' - rasa-core

I am following the tutorial: https://core.rasa.com/tutorial_basics.html#tutorial-basics
and I am in the step:
Let’s run
python -m rasa_nlu.train -c nlu_model_config.json --fixed_model_name current
And I am having this error:
usage: train.py [-h] [-o PATH] (-d DATA | -u URL) -c CONFIG [-t NUM_THREADS]
[--project PROJECT] [--fixed_model_name FIXED_MODEL_NAME]
[--storage STORAGE] [--debug] [-v]
train.py: error: one of the arguments -d/--data -u/--url is required
I've try the obvious and run:
python -m rasa_nlu.train -c nlu_model_config.json --fixed_model_name current -d
But then it gives me the error:
train.py: error: argument -d/--data: expected one argument
I am really confused, since I am still running the tutorial and I don't understand what this arguments are.

You must supply a path to the dataset after the -d flag, like this for instance
python -m rasa_nlu.train -c nlu_model_config.json --fixed_model_name current -d data/nlu_data.md

Related

Docker Run executing shell command can't access PATH environment variable

I'm using an official image from Microsoft which contains SQL tools used to interact with Microsoft SQL Servers. If I run the container interactively, I can run sqlcmd at the command line without any issue, because it is in the PATH variable:
$ docker run --rm -it -v $(pwd):/var/update/ -w /var/update mcr.microsoft.com/mssql-tools:latest
root#df20bd19b982:/var/update# sqlcmd
Microsoft (R) SQL Server Command Line Tool
Version 13.1.0007.0 Linux
Copyright (c) 2012 Microsoft. All rights reserved.
usage: sqlcmd [-U login id] [-P password]
[-S server or Dsn if -D is provided]
[-H hostname] [-E trusted connection]
[-N Encrypt Connection][-C Trust Server Certificate]
[-d use database name] [-l login timeout] [-t query timeout]
[-h headers] [-s colseparator] [-w screen width]
[-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
[-c cmdend]
[-q "cmdline query"] [-Q "cmdline query" and exit]
[-m errorlevel] [-V severitylevel] [-W remove trailing spaces]
[-u unicode output] [-r[0|1] msgs to stderr]
[-i inputfile] [-o outputfile]
[-k[1|2] remove[replace] control characters]
[-y variable length type display width]
[-Y fixed length type display width]
[-p[1] print statistics[colon format]]
[-R use client regional setting]
[-K application intent]
[-M multisubnet failover]
[-b On error batch abort]
[-D Dsn flag, indicate -S is Dsn]
[-X[1] disable commands, startup script, environment variables [and exit]]
[-x disable variable substitution]
[-? show syntax summary]
root#b33a916d4230:/var/update# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/mssql-tools/bin
root#b33a916d4230:/var/update#
sqlcmd is present in /opt/mssql-tools/bin/ folder which is part of the PATH env. variable.
but If I try to execute the sqlcmd command at the docker run... bash -c 'sqlcmd', it won't find it. I echoed PATH environment variable at the same command line and found that its path i.e /opt/mssql-tools/bin is already in the PATH.
$ docker run --rm -it -v $(pwd):/var/update/ -w /var/update mcr.microsoft.com/mssql-tools:latest bash -c "sqlcmd"
bash: sqlcmd: command not found
And to see the PATH env. variable, I did the following:
$docker run --rm -it -v $(pwd):/var/update/ -w /var/update mcr.microsoft.com/mssql-tools:latest bash -c 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Question 1: Why Path Variable is different in case we use bash -c 'commands'?
Question 2: If bash -c or sh -c creates a new shell, how to execute shell commands with the container's environment variables especially the PATH environment variable.
When you run an interactive shell as root, it runs the commands from /root/.bashrc, which (in this particular image) include
export PATH="$PATH:/opt/mssql-tools/bin"
A better Docker image would have that setting in the Dockerfile itself, which exports it to all users of the image. You can build an image like that yourself easily.
FROM mcr.microsoft.com/mssql-tools:latest
ENV PATH="$PATH:/opt/mssql-tools/bin"
(Also, the export is superfluous; the variable is already exported by the shell.)
If you don't want to mess with the image, try
docker run --rm -it -v $(pwd):/var/update/ -w /var/update \
mcr.microsoft.com/mssql-tools:latest \
bash -c 'PATH=$PATH:/opt/mssql/bin sqlcmd'

Bash Script fails with error: OCI runtime exec failed

I am running the below script and getting error.
#!/bin/bash
webproxy=$(sudo docker ps -a --format "{{.Names}}"|grep webproxy)
webproxycheck="curl -k -s https://localhost:\${nginx_https_port}/HealthCheckService"
if [ -n "$webproxy" ] ; then
sudo docker exec $webproxy sh -c "$webproxycheck"
fi
Here is my docker ps -a output
$sudo docker ps -a --format "{{.Names}}"|grep webproxy
webproxy-dev-01
webproxy-dev2-01
when i run the command individually it works. For Example:
$sudo docker exec webproxy-dev-01 sh -c 'curl -k -s https://localhost:${nginx_https_port}/HealthCheckService'
HEALTHCHECK_OK
$sudo docker exec webproxy-dev2-01 sh -c 'curl -k -s https://localhost:${nginx_https_port}/HealthCheckService'
HEALTHCHECK_OK
Here is the error i get.
$ sh healthcheck.sh
OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: \"webproxy-dev-01\": executable file not found in $PATH": unknown
Could someone please help me with the error. Any help will be greatly appreciated.
Because the variable contains two tokens (on two separate lines) that's what the variable expands to. You are running
sudo docker exec webproxy-dev-01 webproxy-dev2-01 ...
which of course is an error.
It's not clear what you actually expect to happen, but if you want to loop over those values, that's
for host in $webproxy; do
sudo docker exec "$host" sh -c "$webproxycheck"
done
which will conveniently loop zero times if the variable is empty.
If you just want one value, maybe add head -n 1 to the pipe, or pass a more specific regular expression to grep so it only matches one container. (If you have control over these containers, probably run them with --name so you can unambiguously identify them.)
Based on your given script, you are trying to "exec" the following
sudo docker exec webproxy-dev2-01
webproxy-dev-01 sh -c "curl -k -s https://localhost:${nginx_https_port}/HealthCheckService"
As you see, here is your error.
sudo docker exec webproxy-dev2-01
webproxy-dev-01 [...]
The problem is this line:
webproxy=$(sudo docker ps -a --format "{{.Names}}"|grep webproxy)
which results in the following (you also posted this):
webproxy-dev2-01
webproxy-dev-01
Now, the issue is, that your docker exec command now takes both images names (coming from the variable assignment $webproxy), interpreting the second entry (which is webproxy-dev-01 and sepetrated by \n) as the exec command. This is now intperreted as the given command which is not valid and cannot been found: That's what the error tells you.
A workaround would be the following:
webproxy=$(sudo docker ps -a --format "{{.Names}}"| grep webproxy | head -n 1)
It only graps the first entry of your output. You can of course adapt this to do this in a loop.
A small snippet:
#!/bin/bash
webproxy=$(sudo docker ps -a --format "{{.Names}}"| grep webproxy )
echo ${webproxy}
webproxycheck="curl -k -s https://localhost:\${nginx_https_port}/HealthCheckService"
while IFS= read -r line; do
if [ -n "$line" ] ; then
echo "sudo docker exec ${line} sh -c \"${webproxycheck}\""
fi
done <<< "$webproxy"

Pass a path to the "." source in a makefile

In a directory I have a config file with my db variables.
This file (db/database.ini) looks like this:
[PostgreSQL]
host=localhost
database=...
user=postgres
password=...
I have another file (db/create_stmts.sql) where I have all my raw create table statements, and i am trying to experiment the use of a Makefile to have a command like this:
make create-db from_file=db/create_stmts.sql
In order not to repeat myself, I thought of tailing the variables of db/database.ini to a file which I would then source, creating shell variables to pass to psql in the make file.
Here's my plan:
make-db:
# from_file: path to .sql file with all create statements to create the database where to insert
# how to run: make create-db from_file={insert path to sql file}
file_path=$(PWD)/file.sh
tail -n4 db/database.ini > file.sh && . $(file_path)
# -U: --user
# -d: --database
# -q: --quiet
# -f: --file
psql -U $(user) -d $(database) -q -f $(from_file) && rm file.sh
Which I run by: make create-db from_file=db/create_stmts.sql
Which gives me this message - from which i kindof understand that the sourcing just did not work.
#from_file: path to .sql file with all create statements to create the database where to insert
# how to run: make create-db from_file={insert path to sql file}
file_path=/home/gabriele/Desktop/TIUK/companies-house/file.sh
tail -n4 db/database.ini > file.sh && .
# -U: --user
# -d: --database
# -q: --quiet
# -f: --file
psql -U -d -q -f db/schema_tables.sql && rm file.sh
psql: FATAL: Peer authentication failed for user "-d"
Makefile:3: recipe for target 'create-db' failed
make: *** [create-db] Error 2
Any help?
Another solution, perhaps simpler to understand:
make-db:
file_path=$$PWD/file.sh; \
tail -n4 db/database.ini > file.sh && . $$file_path; \
psql -U $$user -d $$database -q -f $$from_file && rm file.sh
Note using ; and \ to convince make to run all commands in a single shell, and using $$ to escape the $ and use shell variable references.
The error is in the text, namely
psql -U -d -q -f db/schema_tables.sql && rm file.sh
This happens because the variables $(user) and $(database) aren't set. Every line within a target is executed in a sub shell. There is now way to use source like you would in a regular script.
You could create a file named database.mk in which you define these variables and use include database.mk at the top of your makefile to include them:
Makefile
CONFILE ?= database
include $(CONFILE).mk
test:
#echo $(user)
#echo $(database)
database.mk
user := user
database := data
If you want to parse the ini file you could do that as such
CONFILE := db/database.ini
make-db: _setup_con
echo $(user) $(database)
# your target
_setup_con:
$(eval user=$(shell grep "user=" $(CONFILE) | grep -Eo "[^=]*$$"))
$(eval database=$(shell grep "database=" $(CONFILE) | grep -Eo "[^=]*$$"))
# and so forward
I would make it more Make-way by using feature of automatic Makefile generation. Given that a configuration file is a simple properties file, its syntax is easily parseable by Make, it's sufficient to just get the lines with variables, i.e.:
include database.mk
database.mk: db/database.ini
grep -E '^\w+=\w+$$' $< > $#
.PHONY: create-db
create-db: $(from_file)
psql -U $(user) -d $(database) -q -f $<
Some additional notes:
create-db should be made .PHONY to avoid situation when nothing is done due to somebody creating (accidentally or not) a file named create-db,
by making create-db depending on from_file one can get a clean and readable error from make that a file does not exist instead of possibly cryptic error later.

Running `docker run` from bash script fails. Command does not fail on Command Line

If I run the following from the command line.
docker run -t repo:tag ls -l
the command succeeds just fine. However, if I invoke the same from within a bash script I get the following ERROR:
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:348: starting container process caused "exec: \"ls
-l\": executable file not found in $PATH": unknown.
What about the bash script causes this error?
"exec: \"ls -l\": executable file not found in $PATH"
From the error I can tell that when you invoke docker, you somehow invoke with ls -l including space as one argument. Something like,
docker run -t repo:tag "ls -l" # wrong
or perhaps
cmd="ls -l"
docker run -t repo:tag "$cmd" # wrong
The shell to parse the docker command must see ls and -l as separate parameters so that the argument -l is distinguished from the ls executable name.
cmd="ls -l"
docker run -t repo:tag $cmd #works

mosquitto_pub Error: '-l' mode not available threading support has not been compiled in

When trying to publish a message to a topic using the mosquitto_pub -l flag, I get the error:
Error: '-l' mode not available, threading support has not been compiled in.
How can I correct this?
For reference mosquitto_pub is version 1.5.3, running on libmosquitto 1.5.3., and the command I am trying to run is:
mosquitto_pub -h <hostname> -p <port> -t "<topic>" --cafile /usr/local/etc/openssl/cert.pem -d -P "$(cat mqtt-token-pub.txt)" -u <username> -l
Note: it works if I use -m "blah" instead of -l

Resources