Skip to content

Commit bd02d0c

Browse files
authored
Fix Apache Superset Pipeline (#1891)
* Add rich to dependencies * Update superset and python matrix to test recent versions * fix pipeline * Adapt tests for newer superset version
1 parent 7b76ba7 commit bd02d0c

4 files changed

Lines changed: 34 additions & 17 deletions

File tree

.github/workflows/application-apache-superset.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,19 @@ jobs:
5454
# https://github.com/apache/superset/issues/35942
5555
# - '5.*'
5656

57-
# Superset 6.x will work without much ado.
58-
- '6.0.0rc2'
57+
# Superset 6.x stable releases.
58+
- '6.0.0'
59+
- '6.1.0'
5960
python-version:
60-
- '3.9'
61+
- '3.10'
6162
- '3.11'
63+
- '3.12'
6264
cratedb-version:
6365
- 'nightly'
6466

6567
exclude:
66-
# Apache Superset 6.x no longer supports Python 3.9.
67-
- superset-version: "6.0.0rc2"
68-
python-version: "3.9"
69-
70-
include:
71-
# Apache Superset 6.x supports Python 3.12.
72-
- os: "ubuntu-latest"
73-
cratedb-version: "nightly"
74-
superset-version: "6.0.0rc2"
68+
# Apache Superset 4.x does not support Python 3.12.
69+
- superset-version: "4.*"
7570
python-version: "3.12"
7671

7772

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
apache-superset
22
flask-jwt-extended>=4.7.1
3-
sqlalchemy-cratedb>=0.42.0.dev2
3+
sqlalchemy-cratedb>=0.43.1
4+
rich
5+
cachetools

application/apache-superset/superset_config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,14 @@
4141

4242
# Set this API key to enable Mapbox visualizations
4343
MAPBOX_API_KEY = ''
44+
45+
# Superset 6.1+ ships a SQL Lab bundle that calls `eval()` during startup,
46+
# which the default Content-Security-Policy blocks (missing 'unsafe-eval'),
47+
# leaving the UI stuck on the loading spinner.
48+
# https://github.com/apache/superset/blob/6.1.0/superset/config.py
49+
import copy
50+
51+
from superset.config import TALISMAN_CONFIG as _TALISMAN_CONFIG
52+
53+
TALISMAN_CONFIG = copy.deepcopy(_TALISMAN_CONFIG)
54+
TALISMAN_CONFIG["content_security_policy"]["script-src"].append("'unsafe-eval'")

application/apache-superset/test.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import requests
2+
from playwright.sync_api import TimeoutError as PlaywrightTimeoutError
23
from playwright.sync_api import expect, sync_playwright
34

45
from util import get_auth_headers
@@ -62,22 +63,30 @@ def test_ui():
6263
# Navigate to Apache Superset.
6364
page = browser.new_page()
6465
page.goto(uri_home)
65-
page.wait_for_url("**/login/")
66+
page.wait_for_url("**/login/**")
6667

6768
# Run the login procedure.
6869
page.type("input#username", "admin")
6970
page.type("input#password", "admin")
7071
page.click("[type=submit]")
7172
page.wait_for_load_state()
7273

73-
# Navigate to SQL Lab.
74+
# Navigate to SQL Lab. Older Superset versions open a query editor tab
75+
# automatically; newer ones (6.1+) start empty and require creating one.
7476
page.goto(uri_sqllab)
7577
page.wait_for_load_state()
78+
try:
79+
page.wait_for_selector(".ace_editor", timeout=5000)
80+
except PlaywrightTimeoutError:
81+
page.click('[data-test="add-tab-icon"]')
7682

7783
# Invoke query on SQL Lab.
84+
# The ace editor's DOM id is randomly generated per tab instance, so
85+
# look it up by its `ace_editor` class instead of a fixed element id.
7886
sql = "SELECT region, mountain, height FROM sys.summits LIMIT 42;"
79-
page.wait_for_selector("#ace-editor")
80-
page.evaluate(f"ace.edit('ace-editor').setValue('{sql}')")
87+
page.wait_for_selector(".ace_editor")
88+
editor_id = page.eval_on_selector(".ace_editor", "el => el.id")
89+
page.evaluate(f"ace.edit('{editor_id}').setValue('{sql}')")
8190
page.get_by_role("button", name="Run").click()
8291
page.wait_for_load_state()
8392

0 commit comments

Comments
 (0)