diff --git a/.github/workflows/superset-cli.yml b/.github/workflows/superset-cli.yml new file mode 100644 index 0000000000000..369447e1509c5 --- /dev/null +++ b/.github/workflows/superset-cli.yml @@ -0,0 +1,76 @@ +name: Superset CLI tests + +on: + push: + branches-ignore: + - "dependabot/npm_and_yarn/**" + pull_request: + types: [synchronize, opened, reopened, ready_for_review] + +jobs: + test-load-examples: + if: github.event.pull_request.draft == false + runs-on: ubuntu-20.04 + strategy: + matrix: + python-version: [3.9] + env: + PYTHONPATH: ${{ github.workspace }} + SUPERSET_CONFIG: tests.integration_tests.superset_test_config + REDIS_PORT: 16379 + SUPERSET__SQLALCHEMY_DATABASE_URI: postgresql+psycopg2://superset:superset@127.0.0.1:15432/superset + services: + postgres: + image: postgres:14-alpine + env: + POSTGRES_USER: superset + POSTGRES_PASSWORD: superset + ports: + # Use custom ports for services to avoid accidentally connecting to + # GitHub action runner's default installations + - 15432:5432 + redis: + image: redis:5-alpine + ports: + - 16379:6379 + steps: + - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" + uses: actions/checkout@v2 + with: + persist-credentials: false + submodules: recursive + - name: Check if python changes are present + id: check + env: + GITHUB_REPO: ${{ github.repository }} + PR_NUMBER: ${{ github.event.pull_request.number }} + continue-on-error: true + run: ./scripts/ci_check_no_file_changes.sh python + - name: Setup Python + if: steps.check.outcome == 'failure' + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: 'requirements/testing.txt' + - name: Install dependencies + if: steps.check.outcome == 'failure' + uses: ./.github/actions/cached-dependencies + with: + run: | + apt-get-install + pip-upgrade + pip install wheel + pip install -r requirements/testing.txt + setup-postgres + - name: superset init + if: steps.check.outcome == 'failure' + run: | + pip install -e . + superset db upgrade + superset load_test_users + - name: superset load_examples + if: steps.check.outcome == 'failure' + run: | + # load examples without test data + superset load_examples --load-big-data diff --git a/superset/cli/examples.py b/superset/cli/examples.py index 26ed9451f0765..cad87da9d3d25 100755 --- a/superset/cli/examples.py +++ b/superset/cli/examples.py @@ -54,8 +54,7 @@ def load_examples_run( if load_test_data: print("Loading [Tabbed dashboard]") examples.load_tabbed_dashboard(only_metadata) - - if not load_test_data: + else: print("Loading [Random long/lat data]") examples.load_long_lat_data(only_metadata, force) @@ -105,8 +104,8 @@ def load_examples_run( help="Force load data even if table already exists", ) def load_examples( - load_test_data: bool, - load_big_data: bool, + load_test_data: bool = False, + load_big_data: bool = False, only_metadata: bool = False, force: bool = False, ) -> None: diff --git a/superset/examples/deck.py b/superset/examples/deck.py index 021935e4d3966..f6c7a8c6996cf 100644 --- a/superset/examples/deck.py +++ b/superset/examples/deck.py @@ -33,6 +33,7 @@ "CHART-3afd9d70": { "meta": { "chartId": 66, + "sliceName": "Deck.gl Scatterplot", "width": 6, "height": 50 }, @@ -43,6 +44,7 @@ "CHART-2ee7fa5e": { "meta": { "chartId": 67, + "sliceName": "Deck.gl Screen grid", "width": 6, "height": 50 }, @@ -53,6 +55,7 @@ "CHART-201f7715": { "meta": { "chartId": 68, + "sliceName": "Deck.gl Hexagons", "width": 6, "height": 50 }, @@ -63,6 +66,7 @@ "CHART-d02f6c40": { "meta": { "chartId": 69, + "sliceName": "Deck.gl Grid", "width": 6, "height": 50 }, @@ -73,6 +77,7 @@ "CHART-2673431d": { "meta": { "chartId": 70, + "sliceName": "Deck.gl Polygons", "width": 6, "height": 50 }, @@ -83,6 +88,7 @@ "CHART-85265a60": { "meta": { "chartId": 71, + "sliceName": "Deck.gl Arcs", "width": 6, "height": 50 }, @@ -93,6 +99,7 @@ "CHART-2b87513c": { "meta": { "chartId": 72, + "sliceName": "Deck.gl Path", "width": 6, "height": 50 }, @@ -204,7 +211,7 @@ def load_deck_dash() -> None: # pylint: disable=too-many-statements print("Creating Scatterplot slice") slc = Slice( - slice_name="Scatterplot", + slice_name="Deck.gl Scatterplot", viz_type="deck_scatter", datasource_type="table", datasource_id=tbl.id, @@ -239,7 +246,7 @@ def load_deck_dash() -> None: # pylint: disable=too-many-statements } print("Creating Screen Grid slice") slc = Slice( - slice_name="Screen grid", + slice_name="Deck.gl Screen grid", viz_type="deck_screengrid", datasource_type="table", datasource_id=tbl.id, @@ -275,7 +282,7 @@ def load_deck_dash() -> None: # pylint: disable=too-many-statements } print("Creating Hex slice") slc = Slice( - slice_name="Hexagons", + slice_name="Deck.gl Hexagons", viz_type="deck_hex", datasource_type="table", datasource_id=tbl.id, @@ -312,7 +319,7 @@ def load_deck_dash() -> None: # pylint: disable=too-many-statements } print("Creating Grid slice") slc = Slice( - slice_name="Grid", + slice_name="Deck.gl Grid", viz_type="deck_grid", datasource_type="table", datasource_id=tbl.id, @@ -401,7 +408,7 @@ def load_deck_dash() -> None: # pylint: disable=too-many-statements print("Creating Polygon slice") slc = Slice( - slice_name="Polygons", + slice_name="Deck.gl Polygons", viz_type="deck_polygon", datasource_type="table", datasource_id=polygon_tbl.id, @@ -451,7 +458,7 @@ def load_deck_dash() -> None: # pylint: disable=too-many-statements print("Creating Arc slice") slc = Slice( - slice_name="Arcs", + slice_name="Deck.gl Arcs", viz_type="deck_arc", datasource_type="table", datasource_id=db.session.query(table) @@ -503,7 +510,7 @@ def load_deck_dash() -> None: # pylint: disable=too-many-statements print("Creating Path slice") slc = Slice( - slice_name="Path", + slice_name="Deck.gl Path", viz_type="deck_path", datasource_type="table", datasource_id=db.session.query(table) diff --git a/superset/examples/helpers.py b/superset/examples/helpers.py index 151daeeea9188..9d17e73773299 100644 --- a/superset/examples/helpers.py +++ b/superset/examples/helpers.py @@ -46,12 +46,11 @@ def update_slice_ids(pos: Dict[Any, Any]) -> List[Slice]: for component in pos.values() if isinstance(component, dict) and component.get("type") == "CHART" ] - slices = { - name: db.session.query(Slice).filter_by(slice_name=name).first() - for name in set( - component["meta"]["sliceName"] for component in slice_components - ) - } + slices = {} + for name in set(component["meta"]["sliceName"] for component in slice_components): + slc = db.session.query(Slice).filter_by(slice_name=name).first() + if slc: + slices[name] = slc for component in slice_components: slc = slices.get(component["meta"]["sliceName"]) if slc: diff --git a/superset/examples/misc_dashboard.py b/superset/examples/misc_dashboard.py index a29411a6690bb..4146ea1bd38f0 100644 --- a/superset/examples/misc_dashboard.py +++ b/superset/examples/misc_dashboard.py @@ -210,7 +210,7 @@ def load_misc_dashboard() -> None: """ ) pos = json.loads(js) - pos, slices = update_slice_ids(pos) + slices = update_slice_ids(pos) dash.dashboard_title = "Misc Charts" dash.position_json = json.dumps(pos, indent=4) dash.slug = DASH_SLUG