I want to export the results of a Prodigy tagging session through the command db-out. Prodigy is installed in a Google Compute Engine VM, however I am not the owner of it and for that reason, what I am attempting, looks like this:
# Assume `test1` exists
DB_NAME="test1"
# `super_user` is Prodigy owner's home directory.
sudo runuser -l super_user -c 'python3 -m prodigy db-out "$DB_NAME" > ./"$DB_NAME".jsonl'
The previous commands should generate a test1.jsonl
file, which should be found at super_user
home directory; however, no test1.jsonl
is generated. BTW, when those lines are run, no warning or error is displayed.
Nevertheless, when I directly run the following command:
sudo runuser -l super_user -c 'python3 -m prodigy db-out test1 > ./test1.jsonl'
test1.jsonl
file is correctly generated, as expected and explained before. Why?
Additional notes / updates:
- There is no need into explaining what that runuser or db-out commands are doing. I think the error is more related with a (possibly?) wrong variable sustitution from my side, that I am not seeing right now.
CodePudding user response:
The variable your are trying to replace by its value is actually replaced by the content of DB_NAME on the machine where your execute
sudo runuser -l super_user -c ...
In other words, in your machine.
- If this is what you want, then it means that the variable
DB_NAME
is empty on your machine. - If what you want is to use the
DB_NAME
variable that is declared on the remote host, then to make sure that it will not be replaced byDB_NAME
of your local host, you have to replace double quotes by simple quotes.
Just like this:
sudo runuser -l super_user -c 'python3 -m prodigy db-out \'$DB_NAME\' > ./\'$DB_NAME\'.jsonl'
By doing this, the command "python xxx...
" Would be sent on the remote host, exactly as it is written here. And once executed there, the variable DB_NAME
will be replaced by its remote value.
Here I used "" before the simple quotes to not interfere with the simple quotes of the whole python command.
Bguess
CodePudding user response:
After addressing my attention to this post (which was kindly suggested by Gordon Davidson, and whose revision is highly suggested), I managed to solve my original issue. The corrected code looks like follows:
DB_NAME="test1"
sudo runuser -l super_user -c "python3 -m prodigy db-out $DB_NAME > ./$DB_NAME.jsonl"
Just to make changes clear, they are:
- The single quotation marks were replaced by double ones.
- The inner double quotation marks were discarded.
Afterwards, the script works as it is supposed to be. If I understand this post correctly, there could be some other valid answers; however this one works for now.
Thank you.