clemenshelm / chillbill-recognizer

0 stars 0 forks source link

ChillBill recognizer

To start recognition, you'll have to launch 2 processes:

  1. The dispatcher daemon which will take care of starting workers for each incoming bill and communicating back the recoginition result
  2. The Sidekiq worker process which will do the heavy lifting of bill recognition.

Starting the dispatcher daemon:

bundle exec ruby ./daemon.rb

Starting the Sidekiq worker process:

bundle exec sidekiq -r ./sidekiq.rb

Local Set-Up

  1. Installations
  2. AWS Set-Up
  3. Docker Set-Up
  4. Running it locally
  5. Testing

Installations

To start things off, you will need Git on your machine and this repository cloned locally:

git clone https://github.com/clemenshelm/chillbill-recognizer.git

MacOS

  1. Install Docker. The installation will also include docker-compose, which you will need, so for now, you are done with set up!

Ubuntu

  1. Install Docker. Remember to get the Community Edition (CE)!
  2. Install Docker Compose, here’s a very good guide.

AWS Set-Up

You will need AWS permissions and credentials. Have a memory stick ready and ask either @Althaire or @clemenshelm to create your user and give you your credentials

You will need to have AWS Command Line Interface installed. Here's a guide on how to install it. You will need pip installed. Either sudo apt get it or use homebrew.

Once it is installed, run the command aws configure. When prompted enter the credentials given to you, enter eu-central-1 for region and just hit the enter/return key on the last prompt.

Now that your credentials are configured you can get your login:

MacOS

aws ecr get-login |

Ubuntu

aws ecr get-login --no-include-email --region eu-central-1 |

The output of that command should be put right back into the terminal and executed, which should set up the permissions for everything to run smoothly! You can verify if it's set up properly by running:

cat ~/.docker/config.json

If there's something like this, then you're good to go:

{
  "auths" : {
    "<lots of numbers.dkr.ecr.eu-central-1.amazonaws.com>" : {

    }
  },
  "credsStore" : "<usually the output from the previous command or something about your keychain>"
}%

Docker Set-Up

REMEMBER: If using Ubuntu, all docker commands AND docker compose commands need to be run with sudo!

Make sure Docker is running with docker info:

docker info

First we need to build the image that we will make our containers from. To do this, run

docker build -t recognizer-repo .

This will create an image called recognizer repo built from the Dockerfile in our repository. This will take a while. Now sounds like a good time for some coffee... ☕️

Once this is done we can make sure our gems are all up to date. To do this we will start one service and make it run bundle install:

docker-compose run sidekiq bundle

You’re done with installations and set up and should now be able to run, test and work on the recognizer!

Running it locally

You'll need two terminal windows open simultaneously to run the processor service and sidekiq service at the same time.

Run one of these in each window:

docker-compose run sidekiq
docker-compose run processor

Testing

When running tests will be running the tests service from our Docker Compose file. To run our whole test suite use:

docker-compose run tests rspec ./spec/

Modify the path in the command to choose specific spec files.

Generating data for machine learning

sudo docker-compose run ml rake machine_learning:import_bill_data
sudo docker-compose run ml rake machine_learning:add_prices
sudo docker-compose run ml rake machine_learning:list_bills

At least on ubuntu, you have to change the ownership of the files the edit them (now the owner is root). After changing the ownership, you have to correct the yml files.

sudo docker-compose run ml rake machine_learning:add_dimensions
sudo docker-compose run ml rake machine_learning:generate_csvs