Yeoman generator that scaffolds Superset visualization plugins and packages with proper structure and boilerplate code
63
Build a Python script that programmatically creates geospatial visualizations in Apache Superset using its REST API.
Your task is to create a Python application that:
The source table events contains:
id (integer): Unique event identifierlatitude (float): Event latitude coordinatelongitude (float): Event longitude coordinateevent_type (string): Category/type of eventevent_time (timestamp): When the event occurredmagnitude (integer): Event intensity/magnitudeScatter Visualization:
Hexagon Visualization:
@generates
class SupersetGeoDashboard:
"""Creates geospatial visualizations and dashboards in Apache Superset."""
def __init__(self, base_url: str, username: str, password: str):
"""
Initialize connection to Superset instance.
Args:
base_url: Base URL of Superset instance (e.g., 'http://localhost:8088')
username: Superset username
password: Superset password
"""
pass
def authenticate(self) -> str:
"""
Authenticate with Superset and obtain access token.
Returns:
Access token for subsequent API calls
"""
pass
def create_dataset(self, database_id: int, table_name: str,
dataset_name: str) -> int:
"""
Create a Superset dataset from an existing database table.
Args:
database_id: ID of the database connection in Superset
table_name: Name of the source table
dataset_name: Display name for the dataset
Returns:
ID of the created dataset
"""
pass
def create_scatter_chart(self, dataset_id: int, chart_name: str,
lat_col: str, lon_col: str,
color_col: str, size_col: str) -> int:
"""
Create a deck.gl scatter plot visualization.
Args:
dataset_id: ID of the dataset to visualize
chart_name: Name for the chart
lat_col: Column name containing latitude values
lon_col: Column name containing longitude values
color_col: Column to use for point coloring
size_col: Column to use for point sizing
Returns:
ID of the created chart
"""
pass
def create_hexagon_chart(self, dataset_id: int, chart_name: str,
lat_col: str, lon_col: str) -> int:
"""
Create a deck.gl hexagon layer visualization for density mapping.
Args:
dataset_id: ID of the dataset to visualize
chart_name: Name for the chart
lat_col: Column name containing latitude values
lon_col: Column name containing longitude values
Returns:
ID of the created chart
"""
pass
def create_dashboard(self, dashboard_name: str,
chart_ids: list[int],
filter_columns: list[str] = None) -> int:
"""
Create a dashboard with specified charts and filters.
Args:
dashboard_name: Name for the dashboard
chart_ids: List of chart IDs to include
filter_columns: Optional list of column names to add as dashboard filters
Returns:
ID of the created dashboard
"""
passProvides the REST API for programmatically creating datasets, charts, and dashboards with advanced geospatial visualization capabilities including deck.gl integration.
HTTP library for making REST API calls to the Superset instance.
Install with Tessl CLI
npx tessl i tessl/npm-superset-ui--generator-supersetdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10