Carrot MapperDeveloper GuideQuickstart

Developer Quickstart

This page will guide you through getting Carrot running locally.

Start by cloning the Carrot Mapper repository

Prerequisites

Getting Started

Below are steps to make Carrot up and running locally.

OMOP schema and vocabs setting

You need a pre-seeded OMOP CDM database inside the database of Carrot.

To do this, add a folder named vocabs in the root directory of Carrot, then place there vocabulary files downloaded from Athena.

Thanks to OMOP Lite container, OMOP schema will be created and vocabularies will be loaded to Carrot’s database, when the app’s stack is running.

Authentication setup for Azure functions

For local development, an authentication will be required when api container sends requests to workers container,.

To set this up, at the app/workers directory, add a folder named Secrets. Inside this folder, add a new file named rulestrigger.json with the following content:

{
  "keys": [
    {
      "name": "default",
      "value": "rules_key",
      "encrypted": false
    }
  ]
}

Warm up

At the root directory, run to command below to start the application stack using Docker compose.

docker compose up -d

This runs the database (db), Azurite emulator (Azurite), Azure functions (workers) and will build Carrot’s backend (api) and frontend (frontend). This process will be on the background and take some time, but you can always check it through Docker Desktop app. When all of containers, except omop-lite, are up and running successfully, Carrot’s frontend and backend can be accessed through http://localhost:3000/ and http://localhost:8000/admin/ respectively. However, please complete the remaining steps, while containers are running, to make sure Carrot running correctly.

More details about Docker compose’s configuration can be found here

The omop-lite container, whose task is creating omop schema on db and install vocabularies there, will be shut down automatically after successfully done its jobs.

Docker will mount the app/api and app/next-client-app directories to its environment, so any changes in the code of the backend or frontend will be reflected in the running application.

Initial data preparation

You need to seed the Carrot app database with the OMOP table and field names.

This can be done by either using your terminal and access the api container on Docker or using Docker Desktop.

At the root directory, open terminal and run

docker exec -it carrot-mapper-dev-api-1 bash

Then run

python manage.py loaddata mapping filetypes

After that, add a new admin user (Django superuser) by running:

python manage.py createsuperuser

First instances creation

Create some first instances in Carrot app by logging to Django Admin panel http://localhost:8000/admin/ (using the credentials in the last step). Following this order, fill out the required information to create new Data Partner, Dataset and Project.

Azure local storage setup

You need to set up an Azurite local storage for local development of Carrot

To do this, with the workers container in Docker Desktop is running, open MS Azure Storage Explorer, and create the following queues (under the tab Storage Accounts - Emulator - Queues) and blob containers (under the tab Storage Accounts - Emulator - Blob Containers).

rules-local
rules-exports-local
uploadreports-local

Check-in

You should now be able to access Carrot by logging in at http://localhost:3000/ using your admin credentials created at step 4.

After log in, you will be presented with Projects page.

Try using Carrot by steps in the user quickstart to see if Carrot is running correctly. If you can successfully upload a new scan report, create mapping rules, and finally can export the Mapping rules JSON. That’s a sign that you have successfully install and run Carrot locally.

🎉
Congratulations on your first Carrot running!

Since now on, to run Carrot locally, you can just run

docker compose up -d

and access http://localhost:3000/.

What next? Explore and try using Carrot with user quickstart.