-
Notifications
You must be signed in to change notification settings - Fork 957
Set up local environment
-
Ensure you are using Python Python 3.8 (We recommend using pyenv to handle different Python versions.)
-
Ensure you have the dependency management tool Poetry installed by this guide. The easiest is to do
pip install poetry
-
Ensure you have the dependency tool tesseract installed, following the instructions in this guide.
-
From the root folder, install the dependencies in a virtual environment:
poetry install -E parsers
You can now run a few different commands:
poetry run lint # linting
poetry run test # run unit tests
poetry run check # run both linting and tests
You might need to have zlib
and libjpeg
installed on your machine.
First up, make sure you're using Python 3.8
. Also, see Troubleshooting for fixes to common issues.
If it's still not working, please create an issue where you include the output from poetry debug
so that we can help debug it.
-
Ensure you have nodejs 14.15 or higher installed.
-
Run:
npm install --global yarn
-
In the web folder run:
yarn install
There are two ways to run the frontend map the quickest and easiest way is to use snowpack and the second way is to use the docker container.
-
Run the following command in the web folder:
yarn run develop
-
Go to http://localhost:8080/ and you should see the map!
-
Color the map by opening a new terminal in the web folder and starting the mockserver with the following command:
yarn run mockserver
-
Install docker
-
First, you need to compile the frontend. Open a terminal in the root directory and run:
docker-compose build
-
Start the application by running:
docker-compose up
This will watch over source file changes, run nonstop and watch changes you make in the code to recompile the frontend if needed.
-
Go to http://localhost:8000/ and you should now see the map!
-
You can run the mockserver to color the map by running:
yarn run mockserver
Notes:
- The backend handles the calculation of carbon emissions. The map data from the mock server provides dummy data from the state file.
See Troubleshooting for common issues and fixes when building the map locally.
Your code contributions can't be merged with the codebase unless they respect the electricityMap contrib code formatting.
To check whether you code respects the formatting, you can run the following commands:
poetry run check
If you see that your code fails the formatting check, you can autoformat it by running:
poetry run format
npx prettier --check .
And if the check fails you can run the following command to fix it:
npx prettier --write .
Do you have a question or an idea for improvements? Open a new discussion here