Skip to content

Tasks manager of our parliamentary monitoring platform

License

Notifications You must be signed in to change notification settings

politicalwatch/tipi-tasks

Repository files navigation

TIPI TASKS

A list of tasks for celery to manage tasks from users

Setup

This project uses pipenv, you should install pipenv to configure and run this project.

$ pipenv install

You can find a requirements.txt file too, so if you don't want to install pipenv you can install all dependencies using normal pip:

$ pip install -r requirements.txt

Run

$ celery -A tipi_tasks worker -B -l info

If you're using pipenv environment you should run with the pipenv run command

$ pipenv run celery -A tipi_tasks worker -B -l info

Docker

There's a docker-compose for development that deploys a mongodb a redis and the python app with all deps.

To run this you should edit the .env file in: dockerdev/.env and set your path in the APP_PATH variable.

To run all services:

$ cd dockerdev
$ docker-compose up -d

You'll have three containers running:

  • tipi_tasks
  • tipi_db
  • tipi_redis

You should be able to enter in any of this containers with the docker exec, like:

# to get a shell
$ docker exec -ti tipi_tasks sh
# to get a python shell
$ docker exec -ti tipi_tasks pipenv run ipython
# to run the test script
$ docker exec -ti tipi_tasks pipenv run ./test-task.py
$ docker exec -ti tipi_redis sh
$ docker exec -ti tipi_db bash

Load test data in mongo db

$ docker cp testdb.js tipi_db:/tmp/
$ docker exec -ti tipi_db mongo /tmp/testdb.js

Launching a task

To launch a task you should import the task from the tipi_tasks module and then call with the delay, for example:

from tipi_tasks import test
task = test.test_task.apply_async((3,