Backend for running calculations using bioinformatics tools in separate Docker containers. It consists of the API, which serves as an entry point, and the worker, which runs the calculations inside the Docker containers.
There are two entry points to the app - the API (app.py) and the worker (worker.py). The API is responsible for handling user requests, and the worker runs programs utilizing Docker. By running docker compose up, you start the app together with the database, RabbitMQ message broker, and the storage. The worker needs to be run separately.
Firstly, you need to understand that this backend will be used mostly by front-end applications. They have their own worker deployed, and they utilize pipelines. A basic user who just wants to run their independent calculation doesn't need to create any pipeline. At this point, you are ready to upload your first file. You can do so by using a POST files endpoint. Then, you are ready to trigger a calculation run by sending a POST request to any of the available tool endpoints. After that, a message is sent to a queue, from which the worker consumes it. After the calculation ends, you can access the result from the GET calculation endpoint. Finally, to download the result files, you can use the GET files endpoint.
NOTE: Since the worker doesn't run inside a container, it needs to be run locally within a poetry virtual environment. Therefore, you need to be inside a shell (
poetry shell) or always use the prefixpoetry runwhen starting the worker. This also applies to thealembicmigration utility if you run it from the outside of the chemtools_api container.
- Copy
template.envto.envand adjust environment variables as needed - Run
poetry installto install the project locally for the worker (Poetry >=2.0 is required!) - Run
docker compose up --buildto build the api along with needed services and start them - Run
poetry run alembic upgrade headto migrate database - Set up MinIO locally at
http://127.0.0.1:9001/access-keysby creating an access key and updating the.envfile accordingly. You can skip this step if you store your data in filesystem (usingFilesystemStorageService) - Build images that will be run by the worker.
- Run
docker compose upto start the API, postgres, rabbitmq, and minio - Run
poetry run python src/worker.pyto start the worker
Follow these steps to add a new tool support:
- Build the tool image
- Create a new directory in
src/tools/directory next to the other tools, containing three files:endpoints.py- Definition of endpointsschema.py- Definition of input data schematool.py- Implementation of the specific tool class inheriting fromBaseDockerizedTool
- When you make changes in database models, you need to create a new alembic migration. Run
poetry run alembic revision --autogenerate -m <rev_name> - To update changes, use
poetry run alembic upgrade head