Useful settings (location domino/settings/base.py)
- IMAGE_CONTENT_TYPES - acceptable image content types
- IMAGE_COLOR_PERSIST_MODE - whether hex or color name should be taken into consideration when constructing color set
- IMAGE_EXTRACTION_MODE - whether color extraction should run in 'sync' or 'async' mode
- Useful linux packages
$ sudo apt-get install build-essential python-dev python-virtualenv python-dev g++ python-software-properties curl libjpeg62 libjpeg62-dev
- Clone project
$ git clone git@github.com:jnosal/domino.git .
- Install virtualenv
$ virtualenv venv/ && source venv/bin/activate
- Install requirements
$ pip install -r requirements.txt
- If You'll be using async mode install rabbitmq
$ sudo apt-get install rabbitmq-server
$ sudo service rabbitmq-server start
- Create database (it creates sqlite3 database && applies migrations)
$ python manage.py recreate_db
- Run tests
$ ./scripts/runtests.sh
- Run project (by default sync extraction mode and name persist mode)
$ python manage.py runserver
- Post couple of files
$ curl -X POST -F "image1=@data/cobra.jpg" -F "image2=@data/onlywhite.jpg" http://localhost:8000/api/v1/imagefile
- Explore
$ curl -X GET http://localhost:8000/api/v1/imagefile/search\?format\=json
- Search for color
$ curl -X GET http://localhost:8000/api/v1/imagefile/search\?format\=json\&color\=crimson
- Search for hex
$ curl -X GET http://localhost:8000/api/v1/imagefile/search\?format\=json\&hex\=fcfcfc
- Run in assync mode
- edit domino/settings/base.py and replace IMAGE_EXTRACTION_MODE = 'sync' with IMAGE_EXTRACTION_MODE = 'async'
- this assumes that rabbitmq is installed & running
Stop & start application again (after editing settings)
$ python manage.py runserver
In other terminbal start Celery worker
$ venv/bin/celery -A domino worker --loglevel=INFO
Image handling should be significantly faster:
$ curl -X POST -F "image1=@data/cobra.jpg" -F "image2=@data/onlywhite.jpg" http://localhost:8000/api/v1/imagefile
What can be than to improve overall project:
- adding authentication / authorization policies
- serving application via uwsgi / gunicorn and static files using nginx
- running in async mode with multiple celery workers
- replacing sqlite with postgresql or mysql
- considering storing image files on S3