This document describes the current method for running/testing BD Box Flask application.
Step-by-step guide
Getting read and write access tokens for a Box file
Download the PEM file for the host (bd-box) that is responding to the skills invocations from LastPass Browndog shared folder
Save the PEM file in your
~/.ssh
directory and set file permissions to 600SSH into the bd-box host by running
ssh -i ~/.ssh/bd-box.pem ubuntu@www.bdbox.ndslabs.org
Run
tail -f nohup.out
in the ubuntu user’s home dir and you can see a log message that is produced on the skills invocation.- Upload a file to DES shared Box folder https://uofi.app.box.com/folder/51605357386
From running the
tail
command inbd-box
host, get the file ID and the read and write access keys which will be used for submitting a POST request
Simulating a Box Skills invocation and running bd-box flask application to receive the invocation.
Run the flask app bd-box after setting up the virtual environment and installing required packages from requirements.txt. You also need to create a
conf.cfg
from the template provided in the source code. Set the environment variableCONFIG
toconf.cfg
. Optionally you can also set the environment variableLOG_CFG
to a logging configuration json document. The default one is provided in the source code.- Setting up
conf.cfg
: You can get the CLIENT_ID and CLIENT_SECRET from61647055_6hw17xyv_config.json
in the bd-box host home directory. Scratch directory path can be set to any path in the your machine and the file from Box will be downloaded to this path.
- Setting up
Send a POST request with the following JSON payload to
http://0.0.0.0/skills/<extractor>
. Here<extractor>
should be replaced by an extractor name and the read and write access tokens and the file ID obtained from running thetail
command on bd-box host{ "token":{ "write":{ "access_token":"<READ-WRITE TOKEN>" }, "read":{ "access_token":"<READ-ONLY TOKEN>" } }, "source":{ "id":"<FILE ID>" } }
This should successfully simulate the skills invocation from Box.
Running Extractor
To run the extractor from www.bdbox.ndslabs.org:
Login to the machine:
ssh -i ~/.ssh/bd-box.pem ubuntu@www.bdbox.ndslabs.org
- Check if extractor is already running:
ps aux | grep extractor.py
Kill the running extractor if needed
kill <PID>
- Start the extractor:
cd /opt/rank_galaxies/im_rank
env PYTHONPATH=/home/ubuntu/pyclowder2 python3 extractor.py
Optionally you can use nohup to run the extractor without interruption.
nohup env PYTHONPATH=/home/ubuntu/pyclowder2 python3 extractor.py
Check log file:
tail -f nohup.out