Skip to content

Getting set up for development with Sema

Milo edited this page Jan 28, 2022 · 12 revisions

If you want to contribute and/or run Sema locally you are in the right place. If you have any trouble with these instructions, please follow the contributing guidelines and open an issue.

Dependencies

Sema requires the following dependencies to be installed:

  • Chrome browser or any Chromium-based browser (e.g. Brave, Microsoft Edge, Opera)
  • Node.js active LTS version (currently v14.4.0). To switch between node versions, you can use nvm.
  • NPM cli OR Yarn

Connecting to a Supabase backend

In order to run, Sema must connect with an api key to a Supabase backend.

Once you have set up a project either locally or online you need to copy your api keys into a .env file in the root directory of your sema folder.

SUPABASE_URL="https://YOUR PROJECT URL.supabase.co"
SUPABASE_ANON_KEY="YOUR SUPABASE ANON KEY"

Your project url can be found via the supabase dashboard by going to

  • Settings -> API
    • Copy your project anon key from the Project API Keys section.
    • Copy your project URL from the Config section.

Replicating the database

The next step is to replicate the database structure that we use for storing playgrounds, profiles etc. We provide an SQL script for this here. Copy, and run this using the supabase dashboard by creating a new sql query.

How to build and run the Sema playground on your machine

If you decide to use npm to build sema, you can follow this list of commands:

$ cd sema
$ npm install
$ npm run build
$ npm run dev

Once you have sema running as a node application, you can load it on your browser on the following ports

Working with the Sema and the Sema engine

By default when running npm install, we install the sema-engine package from npm. This is the most recent stable version of the engine. However, if you wish to develop with a local copy of the engine you need to follow the following steps.

  • Clone the sema-engine repo git clone https://github.com/mimic-sussex/sema-engine

  • If you plan on making your own changes, install the prerequisites.

  • Install and build the engine. Follow the instructions here.

  • Change directory to your sema install. cd path/to/sema

  • Optional step: git checkout develop. This changes to the development branch, if you want to work with the most recent updates this is for you.

  • Run npm link /path/to/sema-engine

This will tell sema to use your local copy of the engine. If you make any changes make sure to rebuild the engine (see sema-engine README.md for details).

Keep in mind, if you run npm install` on sema again, it will remove all locally linked modules. You will have to run npm link /path/to/sema-engine``` again.

Troubleshooting

Uncaught Error: supabaseUrl is required.
  • This error means that you are missing a correct URL to your back-end in your .env file. Follow the instructions above on how to set up a supabase backend to get this set up.