Skip to content

Commit fe25b55

Browse files
committed
Superset: Implement suggestions by CodeRabbit
1 parent eb7886f commit fe25b55

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

docs/integrate/superset/sandbox.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Set up an Apache Superset development sandbox with CrateDB
33

44
## Introduction
5-
This is a little walkthrough about how to quickly spawn a development sandbox with Apache Superset, in order to work on the CrateDB Python driver with live code reloading.
5+
This is a little walkthrough about how to quickly spawn a development sandbox with Apache Superset, in order to work on the CrateDB SQLAlchemy dialect with live code reloading.
66

77
## Prerequisites
88
You will need Bash, Docker, Git, and Python to be installed on your workstation. All other prerequisites will be installed into your working tree.
@@ -12,12 +12,12 @@ You will need Bash, Docker, Git, and Python to be installed on your workstation.
1212
### CrateDB
1313

1414
Start CrateDB using Docker.
15-
```console
15+
```shell
1616
docker run --rm --publish=4200:4200 --publish=5432:5432 --name=cratedb --env CRATE_HEAP_SIZE=1g crate:latest -Cdiscovery.type=single-node
1717
```
1818

1919
Create an example table and insert a single record.
20-
```console
20+
```shell
2121
docker run --interactive --rm --network=host crate:latest crash <<EOF
2222
CREATE TABLE IF NOT EXISTS testdrive (
2323
ts TIMESTAMP,
@@ -38,7 +38,7 @@ If you need more data to explore, follow [how to load 2.6M records from the NYC
3838

3939
#### Install Apache Superset from source
4040
You can copy this whole section verbatim into your terminal.
41-
```console
41+
```shell
4242
# Acquire sources.
4343
git clone https://github.com/apache/superset --depth=1
4444
cd superset
@@ -49,8 +49,8 @@ source .venv/bin/activate
4949
pip install -r requirements/local.txt
5050

5151
# Setup Node.js 16 with NPM 7.
52-
export NODEJS_VERSION=16.15.1
53-
export NPM_VERSION=7
52+
export NODEJS_VERSION=20.19.5
53+
export NPM_VERSION=10
5454
source /dev/stdin <<<"$(curl -s https://raw.githubusercontent.com/cicerops/supernode/main/supernode)"
5555

5656
# Run provisioning steps for Apache Superset.
@@ -61,21 +61,21 @@ superset init
6161

6262
#### Link the SQLAlchemy dialect for CrateDB
6363
In order to link the filesystem location of the Python driver into the sandbox environment, install the package in ["editable" mode](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs).
64-
```console
64+
```shell
6565
pip install --editable=/path/to/sqlalchemy-cratedb
6666
```
6767
If you don't have the sources yet, you can obtain them from the Git repository using `git clone https://github.com/crate/sqlalchemy-cratedb`.
6868

6969
#### Start backend
7070
By using the `--reload` option, changes on the Python code will be automatically picked up.
71-
```console
71+
```shell
7272
# Invoke development web server with code reload machinery.
7373
FLASK_ENV=development superset run -p 8088 --with-threads --reload --debugger
7474
```
7575

7676
#### Build and start frontend
7777
In another console, but also within the same virtualenv, you will need to build the frontend and run its development web server.
78-
```console
78+
```shell
7979
source .venv/bin/activate
8080
cd superset-frontend
8181
npm install
@@ -89,11 +89,11 @@ npm run dev-server
8989
You should be ready to go. Now,
9090

9191
- navigate to `http://localhost:4200/#!/console` for exploring the CrateDB Admin UI.
92-
- navigate to `http://localhost:9000/superset/sqllab/` for exploring your data in Apache Superset, log in with admin/admin.
92+
- navigate to `http://localhost:8088/superset/sqllab/` for exploring your data in Apache Superset, log in with admin/admin.
9393

9494
### Create a database connection
9595
For creating a database connection to CrateDB in Apache Superset, you can either use the user interface, or the HTTP API. Those steps will create the connection using the HTTP API, saving a few clicks and keystrokes.
96-
```console
96+
```shell
9797
# Authenticate and acquire a JWT token.
9898
AUTH_TOKEN=$(http --session=superset http://localhost:8088/api/v1/security/login username=admin password=admin provider=db | jq -r .access_token)
9999

docs/integrate/superset/usage.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You will need Bash, Docker, and Python to be installed on your workstation. All
1212
## Install
1313

1414
Set up a Python environment, and install and configure Apache Superset. You can locate the installation within an arbitrary folder on your workstation, for example `~/dev/cratedb-superset`.
15-
```console
15+
```shell
1616
# Create and activate Python virtualenv.
1717
python3 -m venv .venv
1818
source .venv/bin/activate
@@ -22,12 +22,12 @@ pip install apache-superset sqlalchemy-cratedb httpie
2222
```
2323

2424
You need to create a `superset_config.py` file, to configure an individual `SECRET_KEY` for your application.
25-
```console
25+
```shell
2626
echo "SECRET_KEY = '$(docker run --rm alpine/openssl rand -base64 42)'" > superset_config.py
2727
```
2828

2929
This sequence of commands initializes the metadata database at `~/.superset/superset.db`, and provisions a superuser account.
30-
```console
30+
```shell
3131
# Configure and initialize Apache Superset.
3232
export FLASK_APP=superset
3333
export SUPERSET_CONFIG_PATH=superset_config.py
@@ -39,7 +39,7 @@ superset init
3939
## Start services
4040

4141
Start CrateDB using Docker.
42-
```console
42+
```shell
4343
docker run --interactive --rm --pull=always \
4444
--publish=4200:4200 --publish=5432:5432 \
4545
--name=cratedb \
@@ -48,7 +48,7 @@ docker run --interactive --rm --pull=always \
4848
```
4949

5050
Run Superset server.
51-
```console
51+
```shell
5252
superset run --port=9000 --with-threads
5353
```
5454

@@ -57,7 +57,7 @@ superset run --port=9000 --with-threads
5757
Import six million records worth of data from the venerable NYC Yellowcab taxi ride dataset. Depending on the speed of the internet connection between the location of your database instance, and AWS S3, where data is loaded from, it may take about one minute of time.
5858

5959
This is a one-shot command using the [crash](https://cratedb.com/docs/crate/crash/) database shell running in a Docker container, which includes a relevant SQL DDL statement to create the database table schema, and a `COPY FROM` statement to import data from a compressed JSON file located on AWS S3.
60-
```console
60+
```shell
6161
docker run --interactive --rm --network=host crate:latest crash <<EOF
6262
DROP TABLE IF EXISTS yellowcab;
6363
CREATE TABLE yellowcab (
@@ -112,7 +112,7 @@ In order to work with data in Apache Superset, before being able to create dashb
112112
Using [Apache Superset's HTTP API](https://superset.apache.org/docs/api), you can automate the provisioning process. The commands outlined below are using [HTTPie](https://httpie.io/docs/cli) for that purpose, saving a few clicks and keystrokes.
113113

114114
**Connect a database instance**
115-
```console
115+
```shell
116116
# Authenticate and acquire a JWT token.
117117
AUTH_TOKEN=$(http --session=superset http://localhost:9000/api/v1/security/login username=admin password=admin provider=db | jq -r .access_token)
118118

@@ -128,7 +128,7 @@ http --session=superset http://localhost:9000/api/v1/database/ \
128128
```
129129

130130
**Register a database table**
131-
```console
131+
```shell
132132
# Register database table as dataset.
133133
http --session=superset http://localhost:9000/api/v1/dataset/ \
134134
Authorization:"Bearer ${AUTH_TOKEN}" \
@@ -140,6 +140,11 @@ Now, you can navigate to the Superset Web UI for exploring your newly created da
140140

141141
- `http://localhost:9000/explore/?datasource_type=table&datasource_id=1`
142142

143+
:::{note}
144+
The command assumes `database=1`, which implies this is the first database
145+
connection created. If you have already created other databases in your
146+
Superset instance, this ID might be incorrect.
147+
:::
143148

144149
## Clean up
145150
1. The development web server of Apache Superset can be terminated by hitting `CTRL+C`.

0 commit comments

Comments
 (0)