Local Development Setup

Let’s run a local Jupyter Notebook with CARTOFrames, CARTO VL and Airship for local development.

Jupyter Notebook

  1. Install Python

MacOS:

brew install python3
brew postinstall python3

Linux:

sudo apt-get install python3.6
  1. Install Pipenv

MacOS:

brew install pipenv

Linux:

pip install pipenv
  1. Create directory and clone CARTOFrames repository
Note: This is a recommendation to set up your workspace.
mkdir jupyter-cartoframes
cd jupyter-cartoframes
git clone git@github.com:CartoDB/cartoframes.git
  1. Create virtualenv
python3 -m virtualenv <your env name>

or

pipenv --three
  1. Install jupyter
pipenv install jupyter
  1. Install cartoframes package in dev mode using pipenv
pipenv install -e cartoframes
  1. Launch virtual environment
pipenv shell
  1. Launch Jupyter notebook
jupyter notebook

CARTO VL

We’re going to clone the repository. We can do it in the jupyter-cartoframes directory we’ve created to set up our local workspace.

cd jupyter-cartoframes
git clone git@github.com:CartoDB/carto-vl.git
cd carto-vl

The local installation of CARTO VL is explained in this guide

Airship

Let’s clone the Airship repository as well.

cd jupyter-cartoframes
git clone git@github.com:CartoDB/airship.git
cd airship

The local installation of Airship is explained in this guide

Run all the projects

We’ve to serve now all the projects as follows:

+---------------------------+---------------------------+
|/carto-vl                  |/carto-vl                  |
|$ npm run build:watch      | $ npm run serve           |
|                           |                           |
|                           |                           |
|                           |                           |
+---------------------------+---------------------------+
|/airship                   |/airship                   |
|$ npm run dev              | $ npm run serve           |
|                           |                           |
|                           |                           |
|                           |                           |
+---------------------------+---------------------------+
|/cartoframes               |                           |
|(env)$ jupyter notebook    |                           |
|                           |                           |
|                           |                           |
|                           |                           |
+---------------------------+---------------------------+

Load JavaScript libraries locally

In order to get Airship and CARTO VL libraries we’re serving locally in CARTOFrames, we need to instantiate the map indicating the paths:

from cartoframes.auth import set_default_context
from cartoframes.viz import Map, Layer

set_default_context(
    base_url='https://cartoframes.carto.com/', # or https://cartovl.carto.com/
    api_key='default_public'
)

Map(
    Layer('dataset_name'),
    _carto_vl_path='http://localhost:8080',
    _airship_path='http://localhost:5000'
)

We’ve a lot of public datasets in both cartoframes and cartovl accounts that we use for the examples, but I’ve you’ve a personal CARTO account you can use your credentials.

Reload changes

When making changes in CARTOFrames library, in the notebook, click on kernel > Restart and Run all. When making changes in CARTO VL or Airship, click on run (the page doesn’t need to be reloaded)