Over a million developers have joined DZone.

Simply Superb: SuperSet

DZone 's Guide to

Simply Superb: SuperSet

A look at SuperSet, a tool by the Airbnb development team, that allows devs visualize their data using the Python language.

· Big Data Zone ·
Free Resource

Introduction to the Project

This article is about installing and configuring the super cool and admirable D3 charts rendered out of the box from your database directly, without the need for any special APIs. The tools is called SuperSet and it's from the team at Airbnb.

There are two sections in this article. One explains the Docker approach of installing and another is about installation SuperSet on your local machine using Python.

Below are the common action items needed to be done for both the sections. 

Using Docker

Make sure the below settings are in place.

Get the latest code:

git clone https://github.com/apache/incubator-superset/

Move to the incubator-superset/contrib/docker file and run the below command:

docker-compose up

If you find the below error

ERROR: Get https://registry-1.docker.io/v2/: Proxy Authentication Required

then it's time to set your proxy. Choose Manual proxy configuration and enter your organization's proxy settings. Usually, it should be http://USER:PASSWORD@PROXY.ABC.COM:PORT/

Running the below list commands will bring get SuperSet up and running:

$ docker-compose up -d$ docker-compose exec superset bash$ bash docker-init.sh

Note that, if you can’t download the dependencies from your Docker image, your firewalls or proxy settings are blocking them.

Installing Using Python

You must have Python 3 and pip 3 installed on your machine. 

  • Install Brew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Edit your bash_profile.
vi ~/.bash_profile

  • Point the older versions of python to new. Add the below lines into your bash_profile
alias pip='pip3'alias python='python3'
  • Let's make sure Python setuptools and pip are up to date, which lets Python know about its module definitions.
$ pip install --upgrade setuptools pip
  • Take a look at the current module definitions for your comparison.
$ pip freeze > req.txt$ cat req.txt
  • If you want to start fresh, uninstall the existing libraries to avoid mismatches.
pip uninstall -r req.txt -y
  • Install the latest version of SuperSet/ If you are behind a proxy, turn on your proxy as listed in the hardest section of the installation.
$ pip install superset==0.29.0rc7
  • The above command will result in the below-collected Python packages being installed.
Installing collected packages: sqlalchemy, geographiclib, geopy, click, 
MarkupSafe, Jinja2, itsdangerous, Werkzeug, flask, six, python-dateutil, 
colorama, WTForms, flask-wtf, defusedxml, python3-openid, Flask-OpenID, 
Flask-SQLAlchemy, Flask-Login, pytz, babel, Flask-Babel, flask-appbuilder, 
markdown, pyyaml, humanize, flask-compress, unicodecsv, flask-caching, thrift, 
sasl, thrift-sasl, polyline, numpy, pandas, pathlib2, gunicorn, sqlalchemy-utils, 
simplejson, python-editor, Mako, alembic, flask-migrate, future, parsedatetime,
jmespath, docutils, botocore, unidecode, contextlib2, python-geohash, 
webencodings, bleach, idna, chardet, urllib3, certifi, requests, jsonschema, 
et-xmlfile, jdcal, openpyxl, jsonlines, linear-tsv, xlrd, ijson, cchardet, 
tabulator, isodate, rfc3986, tableschema, pydruid, sqlparse, pyhive, billiard, 
vine, amqp, kombu, celery, asn1crypto, pycparser, cffi, cryptography, s3transfer, 
boto3, tornado, flower, supersetSuccessfully installed Flask-Babel-0.12.2 
Flask-Login-0.4.1 Flask-OpenID-1.2.5 Flask-SQLAlchemy-2.3.2 Jinja2-2.10 
  Mako-1.0.7 MarkupSafe-1.1.0 WTForms-2.2.1 Werkzeug-0.14.1 alembic-1.0.5 
amqp-2.3.2 asn1crypto-0.24.0 babel-2.6.0 billiard- bleach-3.1.0 
  boto3-1.9.75 botocore-1.7.48 cchardet-2.1.4 celery-4.2.1 certifi-2018.11.29 
  cffi-1.11.5 chardet-3.0.4 click-6.7 colorama-0.4.1 contextlib2-0.5.5 
  cryptography-2.4.2 defusedxml-0.5.0 docutils-0.14 et-xmlfile-1.0.1 flask-1.0.2 
  flask-appbuilder-1.12.2 flask-caching-1.4.0 flask-compress-1.4.0 
  flask-migrate-2.3.1 flask-wtf-0.14.2 flower-0.9.2 future-0.17.1 
  geographiclib-1.49 geopy-1.18.1 gunicorn-19.9.0 humanize-0.5.1 
  idna-2.8 ijson-2.3 isodate-0.6.0 itsdangerous-1.1.0 jdcal-1.4 
  jmespath-0.9.3 jsonlines-1.2.0 jsonschema-2.6.0 kombu-4.2.2.post1 
linear-tsv-1.1.0 markdown-3.0.1 numpy-1.15.4 openpyxl-2.4.11 pandas-0.23.4 
  parsedatetime-2.4 pathlib2-2.3.3 polyline-1.3.2 pycparser-2.19 pydruid-0.5.0 
  pyhive-0.6.1 python-dateutil-2.7.5 python-editor-1.0.3 python-geohash-0.8.5 
  python3-openid-3.1.0 pytz-2018.9 pyyaml-3.13 requests-2.21.0 rfc3986-1.2.0 
  s3transfer-0.1.13 sasl-0.2.1 simplejson-3.16.0 six-1.12.0 sqlalchemy-1.2.15 
  sqlalchemy-utils-0.33.10 sqlparse-0.2.4 superset-0.29.0rc7 tableschema-1.3.0 
  tabulator-1.19.0 thrift-0.11.0 thrift-sasl-0.3.0 tornado-5.1.1 
  unicodecsv-0.14.1 unidecode-1.0.23 urllib3-1.24.1 vine-1.2.0 
  webencodings-0.5.1 xlrd-1.2.0

You may have noticed the UI libraries as well, like Babel and Webpack, are installed.

  • Create a user. Remember your username and password. We will use these to login into the application later.
$ fabmanager create-admin --app superset

Username [admin]: gopiUser 
first name [admin]: gopiUser 
last name [user]: gopi
Email [admin@fab.org]: gopi@allibilli.com
Password: gopi
Repeat for confirmation: gopi
Recognized Database Authentications.
  Admin User gopi created.

If you want to remove all the users, remove the db file from the below directory:

  • Initialize the database:
$ superset db upgrade  

......INFO  [alembic.runtime.migration] Running upgrade 46ba6aaaac97, 
ec1f88a35cc6 -> c18bd4186f15, empty message
INFO  [alembic.runtime.migration] Running upgrade c18bd4186f15 -> 7fcdcde0761c, Reduce position_json size by remove extra space and component id prefix
INFO  [alembic.runtime.migration] Running upgrade 7fcdcde0761c -> 0c5070e96b57, \add user attributes table
INFO  [alembic.runtime.migration] Running upgrade 0c5070e96b57 -> 1a1d627ebd8e, position_json
INFO  [alembic.runtime.migration] Running upgrade 1a1d627ebd8e -> 55e910a74826, add_metadata_column_to_annotation_model.py
  • Load the example dataset:
$ superset load_examples

......Creating the dashboardLoading DECK.gl demoLoading deck.gl dashboardCreating Scatterplot slice
Creating Screen Grid slice
Creating Hex slice
Creating Grid slice
Creating Polygon slice
Creating Arc slice
Creating Path slice
Creating a dashboard
  • Create default roles and permissions
$ superset init

2019-01-09 15:05:44,825:INFO:root:Creating database reference
2019-01-09 15:05:44,832:INFO:root:Syncing role definition
2019-01-09 15:05:44,863:INFO:root:Syncing Admin perms
2019-01-09 15:05:44,927:INFO:root:Syncing Alpha perms
2019-01-09 15:05:45,144:INFO:root:Syncing Gamma perms
2019-01-09 15:05:45,361:INFO:root:Syncing granter perms
2019-01-09 15:05:45,592:INFO:root:Syncing sql_lab perms
2019-01-09 15:05:45,804:INFO:root:Fetching a set of all perms to lookup which ones are missing
2019-01-09 15:05:45,854:INFO:root:Creating missing datasource permissions.
  2019-01-09 15:05:45,860:INFO:root:Creating missing database permissions.
2019-01-09 15:05:45,872:INFO:root:Creating missing metrics permissions
2019-01-09 15:05:45,888:INFO:root:Cleaning faulty perms
  • Start the SuperSet using Gunicorn. Make sure Port 8125 is not in use by any other application or use your own port as listed in the below command.
$ gunicorn -b superset:app
  • Open your browser and type: http://localhost:8125.
Enter the credentials used while creating the user in one of the above steps.

Awesome! You can now see a dashboard as listed below.

Click on one of the example “Worldbank’s Data” to see its data visualization.

Customizing the datasources and generating the visualizations directly from your databases are pretty easy and stay tuned for the upcoming article on this.
bi tools ,big data ,data visualization ,python tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}