Apache Superset CLI guide
Hey everyone, In this blog we will be knowing more about Superset CLI. The Apache Superset CLI (Command Line Interface) is a tool that enhances the management, configuration, and usage of Superset, eliminating the need for direct web interface interaction. This guide provides a detailed overview of how to leverage the Superset CLI effectively.
Installation
To start using the CLI, first install Superset via pip:
pip install apache-superset
Database Initialization
After installation, initialize the database with the following command:
superset db upgrade
Creating an Admin User
Set up an admin user by configuring the FLASK_APP
environment variable and running the create-admin command:
export FLASK_APP=superset superset fab create-admin
Loading Examples
To load sample data into Superset:
superset load_examples
Initializing Superset
Initialize Superset to set up roles and permissions:
superset init
Starting the Server
Launch the server on a custom port with development features enabled:
superset run -p 8088 --with-threads --reload --debugger
Upgrading Superset
To upgrade Superset to a newer version, use the following commands:
pip install apache-superset --upgrade superset db upgrade superset init
Custom Configuration
For production environments, ensure you set a SECRET_KEY
in your configuration, as specified in the official documentation.
Additional Commands
The Superset CLI supports various other commands for tasks such as importing/exporting dashboards, managing security, and more. Refer to the official documentation for a complete list of commands and their detailed usage.
By mastering the Apache Superset CLI, you can efficiently manage and configure your Superset instance, streamlining the process of creating and maintaining data visualizations.
Installing Apache Superset via Command Line Interface (CLI)
logging
To install Apache Superset using the command line interface (CLI), adhere to the following steps:
Install apache-superset:
pip install apache-superset
Initialize the database:
superset db upgrade
Ensure that you have a SECRET_KEY set in your configuration for production instances.
Create an admin user:
export FLASK_APP=superset superset fab create-admin
Load example data:
superset load_examples
Create default roles and permissions:
superset init
Build frontend assets: Go to the superset-frontend directory and execute:
npm ci npm run build
Start the development server:
superset run -p 8088 --with-threads --reload --debugger
Access Superset by visiting http://localhost:8088 and logging in with the credentials you created.
Initializing the Superset Database
To set up the Apache Superset database, follow these guidelines:
Install Apache Superset: Utilize pip, the Python package manager, to install Superset.
pip install apache-superset
Database Initialization: Execute the following command to upgrade the database to the latest version.
superset db upgrade
Admin User Creation: Define the FLASK_APP environment variable and create an admin user.
export FLASK_APP=superset superset fab create-admin
Load Examples: If desired, load example data using the following command:
superset load_examples
Initialize Superset: Establish default roles and permissions with the superset init command.
Build Assets: Navigate to the superset-frontend directory, install dependencies, and build the frontend assets.
cd superset-frontend npm ci npm run build cd ..
Run Development Server: Start the development server on port 8088 or any preferred port.
superset run -p 8088 --with-threads --reload --debugger
Following these steps ensures Superset's database is set up correctly. Access Superset by visiting http://localhost:8088 in your browser and logging in with the credentials you created.
Creating an Admin User via Superset CLI
To create an admin user in Apache Superset using the command line interface (CLI), follow these steps after you have Superset installed:
Set the
FLASK_APP
environment variable to superset:export FLASK_APP=superset
Use the superset fab create-admin command to start the process:
superset fab create-admin
You will be prompted to enter the admin's username, first and last name, email, and password.
After creating the admin user, you should initialize the database with the default roles and permissions by running:
superset init
This process registers the admin user in the metadata database, allowing them to log in to the Superset instance. Remember to follow best practices for securing your admin credentials.
Loading Example Data with Superset CLI
Apache Superset offers a convenient command-line interface (CLI) for loading example data, aiding users in familiarizing themselves with the platform's capabilities. Below are the steps to load CSV data and example datasets using the Superset CLI:
Load CSV Data:
Download the CSV dataset from the provided GitHub link.
In Superset, navigate to Data ‣ Upload a CSV.
Specify the Table Name as "tutorial_flights" and select the downloaded CSV file.
Enter "Travel Date" in the Parse Dates field.
Keep other options as default and click Save.
Load Example Data and Dashboards:
Create a file named "my_values.yaml".
Deploy the configuration as instructed in the Configure your setting overrides section.
Log in to Superset:
Access your local Superset instance at http://localhost:8088.
Log in using the default credentials:
Username: admin
Password: admin
Add the following configuration to enable loading examples:
init: load
Examples: true
Following these steps allows users to efficiently import data into Superset and begin exploring its features. The CLI commands simplify the setup process, facilitating a smoother start to data analysis.
Configuring Superset with the CLI
Apache Superset's command-line interface (CLI) provides an efficient way to configure the platform, preparing it for seamless data exploration. Follow these steps to configure Superset using the CLI:
Accessing Superset:
- Navigate to http://localhost:8088 and log in with the admin credentials you created.
Configuration File:
Customize your Superset instance by creating a
superset_config.py
file.Set the
SECRET_KEY
and any other desired configurations.Refer to the official documentation for a comprehensive list of available settings.
Security:
Ensure that the
SECRET_KEY
is set to a secure, randomly generated value, especially for production environments.Follow additional security measures outlined in the official documentation for enhanced security posture.
Start the development server:
superset run -p 8088 --with-threads --reload --debugger
Build the frontend assets:
cd superset-frontend npm ci npm run build cd ..
Initialize Superset:
superset init
Optionally, load example data:
superset load_examples
Create an admin user:
export FLASK_APP=superset superset fab create-admin
Upgrade the database:
superset db upgrade
Install the apache-superset package:
pip install apache-superset
Running the Superset Web Server Using the CLI
To initiate the Apache Superset web server via the command-line interface (CLI), follow these steps post the installation and initialization of Superset:
Set the
FLASK_APP
environment variable:export FLASK_APP=superset
Create an admin user:
superset fab create-admin
Optionally, load example data:
superset load_examples
Initialize Superset with default roles and permissions:
superset init
If frontend assets have been built, navigate to the superset-frontend directory and execute:
npm ci npm run build
To launch the development server on port 8088 (or an alternative port using the -p option):
superset run -p 8088 --with-threads --reload --debugger
Access Superset by opening http://localhost:8088 in your web browser. Log in using the admin credentials established earlier. For production environments, ensure the SECRET_KEY is properly configured following official guidelines.
Cloning the Superset Repository via Command Line
To clone the Apache Superset repository using the command line, follow these steps:
Open your terminal application.
Navigate to the directory where you want to clone the repository using the cd command:
cd /path/to/parent/directory
Execute the following command to clone the repository:
git clone https://github.com/apache/superset.git
Wait for the cloning process to finish. Once completed, you will find a new directory named "superset" in your current working directory, containing the cloned repository.
Ensure that Git is installed on your system before running the clone command. You should also be familiar with basic command-line operations to navigate directories and execute commands.
Thanks for reading ❤️
Thank you so much for reading and do check out the Elestio resources and Official Superset documentation to learn more about Superset. You can click the button below to create your service on Elestio. See you in the next one👋
Subscribe to my newsletter
Read articles from Kaiwalya Koparkar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Kaiwalya Koparkar
Kaiwalya Koparkar
I am Kaiwalya Koparkar, founder of Geek Around Community, a GitHub Campus Expert, MLH Coach, Open-Source Advocate & DevRel. I work as a Program Manager/ Community Manager in several communities. I love to speak at sessions, workshops, meetups, and conferences. In the past year, I have won over 10+ hackathons and mentored/judged/participated in over 35+ global hackathons.