From 810cfc13db666ecb2da8d9e66b06ff6d2524c764 Mon Sep 17 00:00:00 2001 From: ofekisr <35701650+ofekisr@users.noreply.github.com> Date: Wed, 19 Jan 2022 20:16:15 +0200 Subject: [PATCH] fix can't use examples helpers on non app context based environment (#18086) --- superset/cli.py | 2 +- superset/examples/__init__.py | 18 --------------- superset/examples/data_loading.py | 35 +++++++++++++++++++++++++++++ tests/integration_tests/conftest.py | 4 ++-- 4 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 superset/examples/data_loading.py diff --git a/superset/cli.py b/superset/cli.py index 8b55a8140908..f319316af5b8 100755 --- a/superset/cli.py +++ b/superset/cli.py @@ -124,7 +124,7 @@ def load_examples_run( print(f"Loading examples metadata and related data into {examples_db}") # pylint: disable=import-outside-toplevel - from superset import examples + import superset.examples.data_loading as examples examples.load_css_templates() diff --git a/superset/examples/__init__.py b/superset/examples/__init__.py index a7742b0ef7df..13a83393a912 100644 --- a/superset/examples/__init__.py +++ b/superset/examples/__init__.py @@ -14,21 +14,3 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from .bart_lines import load_bart_lines -from .big_data import load_big_data -from .birth_names import load_birth_names -from .country_map import load_country_map_data -from .css_templates import load_css_templates -from .deck import load_deck_dash -from .energy import load_energy -from .flights import load_flights -from .long_lat import load_long_lat_data -from .misc_dashboard import load_misc_dashboard -from .multi_line import load_multi_line -from .multiformat_time_series import load_multiformat_time_series -from .paris import load_paris_iris_geojson -from .random_time_series import load_random_time_series_data -from .sf_population_polygons import load_sf_population_polygons -from .tabbed_dashboard import load_tabbed_dashboard -from .utils import load_examples_from_configs -from .world_bank import load_world_bank_health_n_pop diff --git a/superset/examples/data_loading.py b/superset/examples/data_loading.py new file mode 100644 index 000000000000..6eae82a79976 --- /dev/null +++ b/superset/examples/data_loading.py @@ -0,0 +1,35 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# pylint: disable=unused-import +from .bart_lines import load_bart_lines +from .big_data import load_big_data +from .birth_names import load_birth_names +from .country_map import load_country_map_data +from .css_templates import load_css_templates +from .deck import load_deck_dash +from .energy import load_energy +from .flights import load_flights +from .long_lat import load_long_lat_data +from .misc_dashboard import load_misc_dashboard +from .multi_line import load_multi_line +from .multiformat_time_series import load_multiformat_time_series +from .paris import load_paris_iris_geojson +from .random_time_series import load_random_time_series_data +from .sf_population_polygons import load_sf_population_polygons +from .tabbed_dashboard import load_tabbed_dashboard +from .utils import load_examples_from_configs +from .world_bank import load_world_bank_health_n_pop diff --git a/tests/integration_tests/conftest.py b/tests/integration_tests/conftest.py index 2765a1d90937..d143f9412a44 100644 --- a/tests/integration_tests/conftest.py +++ b/tests/integration_tests/conftest.py @@ -54,9 +54,9 @@ def setup_sample_data() -> Any: load_test_users_run() - from superset import examples + from superset.examples.css_templates import load_css_templates - examples.load_css_templates() + load_css_templates() yield