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-7/

Dashboard Export Tool

Build a command-line tool that exports Superset dashboards with all their dependencies to a portable ZIP archive format.

Problem Description

Your tool should accept a dashboard ID and export the complete dashboard including all its dependencies (charts, datasets, and database connections) to a ZIP file. The export should use YAML format for metadata and preserve dependency relationships.

Requirements

Input

  • Accept a dashboard ID as a command-line argument
  • Accept an output file path for the ZIP archive

Export Process

  1. Retrieve the dashboard metadata by ID
  2. Identify and collect all dependencies:
    • Charts used in the dashboard
    • Datasets used by those charts
    • Database connections used by those datasets
  3. Export each resource to YAML format
  4. Package all YAML files into a ZIP archive
  5. Ensure proper dependency ordering in the export

Output Format

  • Create a ZIP file containing:
    • dashboard.yaml - Dashboard metadata
    • charts/*.yaml - One file per chart
    • datasets/*.yaml - One file per dataset
    • databases/*.yaml - One file per database connection
    • metadata.yaml - Export metadata including version and timestamp

Error Handling

  • Handle missing or invalid dashboard IDs gracefully
  • Validate that all dependencies can be retrieved
  • Provide clear error messages for any failures

Implementation

@generates

API

def export_dashboard(dashboard_id: int, output_path: str) -> None:
    """
    Export a dashboard with all its dependencies to a ZIP archive.

    Args:
        dashboard_id: The ID of the dashboard to export
        output_path: Path where the ZIP file should be created

    Raises:
        ValueError: If dashboard_id is invalid or dashboard doesn't exist
        IOError: If output_path cannot be written to
    """
    pass

def get_dashboard_dependencies(dashboard_id: int) -> dict:
    """
    Retrieve all dependencies for a given dashboard.

    Args:
        dashboard_id: The ID of the dashboard

    Returns:
        A dictionary containing:
        - 'charts': List of chart IDs
        - 'datasets': List of dataset IDs
        - 'databases': List of database IDs

    Raises:
        ValueError: If dashboard_id is invalid or dashboard doesn't exist
    """
    pass

Test Cases

Basic Export Test { @test }

  • Given a valid dashboard ID (e.g., 1), when export_dashboard is called, then a ZIP file is created at the specified output path @test

Dependency Resolution Test { @test }

  • Given a dashboard with 2 charts, 2 datasets, and 1 database, when get_dashboard_dependencies is called, then it returns all dependency IDs correctly @test

Invalid Dashboard Test { @test }

  • Given an invalid dashboard ID (e.g., 99999), when export_dashboard is called, then it raises a ValueError with a clear error message @test

ZIP Structure Test { @test }

  • Given a successful export, when the ZIP file is opened, then it contains the correct directory structure with dashboard.yaml, charts/, datasets/, databases/, and metadata.yaml @test

Dependencies { .dependencies }

apache-superset { .dependency }

Provides the data models, export commands, and APIs for dashboard management.

Install with Tessl CLI

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

tile.json