This is part two of using Riskquant - for the original article click here
Setting up Riskquant with Docker
For those who are more technically minded and want to have a crack themselves - here's a quick tutorial I've together based on my own instance of the tool.
Startup the Vultr Instance
- Fire up a brand new Ubuntu 18.04 VPS from the provider of your choice or deploy it locally on your device and login, I'm using a $6 VPS based in Australia from Vultr (Affiliate) which is more than enough to test the functionality out as long as you add swap space.
2. Before starting ensure the VPS is up to date by running the following commands:
sudo apt-get update sudo apt-get upgrade
3. [optional] This part is optional. If you are running with less than 1gb of Ram I would suggest adding some swap to your VPS to assist docker during the container build process as tensor flow is a rather large download / file extraction.
Create a /swapfile, 1GB in size, I would adjust the size to fit your needs but 1GB should be fine.
sudo fallocate -l 1G /swapfile
Ensure the /swapfile is only accessible by root to avoid any security implications:
sudo chmod 600 /swapfile
Mark the /swapfile to be used as the system as swap space
sudo mkswap /swapfile
After making the file we need to allow the system to use it
sudo swapon /swapfile
Finally ensure that the swap file is permanent by editing /etc/fstab and adding the following line at the bottom of the file
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Ensure that the swap space (Swp) is showing on your system via top or htop
For full reference of the swap space setup follow this tutorial
4. Install docker, we're using the version included in ubuntu 18.04 so this may not be the most up-to-date version but works fine with Riskquant.
sudo apt install docker.io
5. In order to build the docker image we need to clone the Github riskquant repository to our server with a simple git clone command using a sub user on the VPS.
git clone https://github.com/Netflix-Skunkworks/riskquant
6. Once downloaded enter the folder we just cloned with the below command
7. In order for the tool to run in docker we first need to build the image locally that we just cloned.
docker build -t riskquant .
8. Once built, we need to create a data sub-directory within the Riskquant master directory which is used to house both the the csv file we parse to the tool and the tool's csv output.
9. let's create a csv file for the tool to read from
Ctrl-O + enter when done.
when defining the risks you want to parse into the csv you'll need to use the following format:
- Identifier: An identifying label, which need not be unique - but is intended to provide a way of identifying the scenario.
- Name: The name of the scenario, which should be more descriptive than the identifier.
- Probability (Frequency): The number of times that the loss will occur over a period of time
- Low loss magnitude: A dollar value of the best-case scenario, given that the loss did occur.
- High loss magnitude: A dollar value of the worst-cases scenario. Our detection systems didn't work, and the problem persisted for a long time.
10. As we're running the tool in a docker container, we need to link the data folder we just created when we run the container so it can read the risks we've defined in the input.csv contained within the data folder for it to make it's analysis.
docker container run --rm -it -v "/root/riskquant/data/":/data/ riskquant --file /data/input.csv
11. When the tool runs it should create a new risk priortised.csv which you can pull calculations from
Have a crack with your own risks. I'd love to hear about anyone using some of the more advance methods that the tool supports and any interesting observations.
If you run into any issues or are keen to share your ideas and outputs please comment below and I'll do my best to help out - enjoy!