CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-superset-ui--generator-superset

Yeoman generator that scaffolds Superset visualization plugins and packages with proper structure and boilerplate code

63

1.21x
Overview
Eval results
Files

task.mdevals/scenario-5/

Geospatial Event Dashboard Creator

Build a Python script that programmatically creates geospatial visualizations in Apache Superset using its REST API.

Requirements

Your task is to create a Python application that:

  1. Connects to a Superset instance and authenticates via the REST API
  2. Creates a dataset from an existing database table containing event data with latitude/longitude coordinates
  3. Creates geospatial visualizations including at least:
    • A deck.gl scatter plot showing individual event locations
    • A deck.gl hexagon layer showing event density through hexagonal binning
  4. Assembles a dashboard combining these visualizations with appropriate layout and filters

Dataset Schema

The source table events contains:

  • id (integer): Unique event identifier
  • latitude (float): Event latitude coordinate
  • longitude (float): Event longitude coordinate
  • event_type (string): Category/type of event
  • event_time (timestamp): When the event occurred
  • magnitude (integer): Event intensity/magnitude

Visualization Requirements

Scatter Visualization:

  • Display all events as points on a map
  • Color points by event_type
  • Size points by magnitude
  • Include tooltip with event details

Hexagon Visualization:

  • Aggregate events into hexagonal bins
  • Show density through color intensity
  • Include appropriate elevation based on event count
  • Support filtering by event_type and time range

Test Cases

  • The script successfully authenticates with Superset using provided credentials @test
  • A dataset is created from the events table with all required columns configured @test
  • A deck.gl scatter visualization is created with latitude/longitude mapping and event_type coloring @test
  • A deck.gl hexagon visualization is created with proper aggregation settings @test
  • A dashboard is created containing both visualizations with a shared filter on event_type @test

Implementation

@generates

API

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
        """
        pass

Dependencies { .dependencies }

apache-superset { .dependency }

Provides the REST API for programmatically creating datasets, charts, and dashboards with advanced geospatial visualization capabilities including deck.gl integration.

requests { .dependency }

HTTP library for making REST API calls to the Superset instance.

Install with Tessl CLI

npx tessl i tessl/npm-superset-ui--generator-superset

tile.json