Let's run a local Jupyter Notebook with CARTOFrames, CARTO VL and Airship for local development.
- Install Python
MacOS:
brew install python3
brew postinstall python3
Linux:
sudo apt-get install python3.6
- Install Pipenv
MacOS:
brew install pipenv
Linux:
pip install pipenv
- 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
- Create virtualenv
python3 -m virtualenv <your env name>
or
pipenv --three
- Install jupyter
pipenv install jupyter
- Install cartoframes package in dev mode using pipenv
pipenv install -e cartoframes
- Launch virtual environment
pipenv shell
- Launch Jupyter notebook
jupyter notebook
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
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
The JavaScript code is generated using Rollup, a module bundler. In order to save changes in the all the .js files, we need to bundle the code:
Watch changes:
cd cartoframes npm run dev
Build:
cd cartoframes npm run build
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 |/cartoframes | |(env)$ jupyter notebook |$ npm run dev | | | | | | | | | | +---------------------------+---------------------------+
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_credentials
from cartoframes.viz import Map, Layer
set_default_credentials(
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.
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)