Skip to content

Commit

Permalink
Add a github workflow for load_examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud committed May 11, 2022
1 parent c4adf17 commit cea3fac
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 18 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/superset-cli.yml
Original file line number Diff line number Diff line change
@@ -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:[email protected]: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
7 changes: 3 additions & 4 deletions superset/cli/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
21 changes: 14 additions & 7 deletions superset/examples/deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"CHART-3afd9d70": {
"meta": {
"chartId": 66,
"sliceName": "Deck.gl Scatterplot",
"width": 6,
"height": 50
},
Expand All @@ -43,6 +44,7 @@
"CHART-2ee7fa5e": {
"meta": {
"chartId": 67,
"sliceName": "Deck.gl Screen grid",
"width": 6,
"height": 50
},
Expand All @@ -53,6 +55,7 @@
"CHART-201f7715": {
"meta": {
"chartId": 68,
"sliceName": "Deck.gl Hexagons",
"width": 6,
"height": 50
},
Expand All @@ -63,6 +66,7 @@
"CHART-d02f6c40": {
"meta": {
"chartId": 69,
"sliceName": "Deck.gl Grid",
"width": 6,
"height": 50
},
Expand All @@ -73,6 +77,7 @@
"CHART-2673431d": {
"meta": {
"chartId": 70,
"sliceName": "Deck.gl Polygons",
"width": 6,
"height": 50
},
Expand All @@ -83,6 +88,7 @@
"CHART-85265a60": {
"meta": {
"chartId": 71,
"sliceName": "Deck.gl Arcs",
"width": 6,
"height": 50
},
Expand All @@ -93,6 +99,7 @@
"CHART-2b87513c": {
"meta": {
"chartId": 72,
"sliceName": "Deck.gl Path",
"width": 6,
"height": 50
},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions superset/examples/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion superset/examples/misc_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cea3fac

Please sign in to comment.