diff --git a/superset/cli.py b/superset/cli.py index 557cc9d0efd4a..e1b46ee3dea97 100755 --- a/superset/cli.py +++ b/superset/cli.py @@ -130,6 +130,9 @@ def load_examples_run( print("Loading [Birth names]") examples.load_birth_names(only_metadata, force) + print("Loading [Tabbed dashboard]") + examples.load_tabbed_dashboard(only_metadata) + if not load_test_data: print("Loading [Random time series data]") examples.load_random_time_series_data(only_metadata, force) @@ -164,11 +167,8 @@ def load_examples_run( print("Loading DECK.gl demo") examples.load_deck_dash() - print("Loading [Tabbed dashboard]") - examples.load_tabbed_dashboard(only_metadata) - # load examples that are stored as YAML config files - examples.load_from_configs(force) + examples.load_from_configs(force, load_test_data) @with_appcontext diff --git a/superset/examples/configs/charts/Unicode_Cloud.yaml b/superset/examples/configs/charts/Unicode_Cloud.test.yaml similarity index 100% rename from superset/examples/configs/charts/Unicode_Cloud.yaml rename to superset/examples/configs/charts/Unicode_Cloud.test.yaml diff --git a/superset/examples/configs/dashboards/Unicode_Test.yaml b/superset/examples/configs/dashboards/Unicode_Test.test.yaml similarity index 100% rename from superset/examples/configs/dashboards/Unicode_Test.yaml rename to superset/examples/configs/dashboards/Unicode_Test.test.yaml diff --git a/superset/examples/configs/datasets/examples/unicode_test.yaml b/superset/examples/configs/datasets/examples/unicode_test.test.yaml similarity index 100% rename from superset/examples/configs/datasets/examples/unicode_test.yaml rename to superset/examples/configs/datasets/examples/unicode_test.test.yaml diff --git a/superset/examples/utils.py b/superset/examples/utils.py index 951b741b28d69..66ca811df2d35 100644 --- a/superset/examples/utils.py +++ b/superset/examples/utils.py @@ -14,6 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +import re from pathlib import Path from typing import Any, Dict @@ -24,13 +25,13 @@ YAML_EXTENSIONS = {".yaml", ".yml"} -def load_from_configs(force_data: bool = False) -> None: - contents = load_contents() +def load_from_configs(force_data: bool = False, load_test_data: bool = False) -> None: + contents = load_contents(load_test_data) command = ImportExamplesCommand(contents, overwrite=True, force_data=force_data) command.run() -def load_contents() -> Dict[str, Any]: +def load_contents(load_test_data: bool = False) -> Dict[str, Any]: """Traverse configs directory and load contents""" root = Path("examples/configs") resource_names = resource_listdir("superset", str(root)) @@ -39,6 +40,7 @@ def load_contents() -> Dict[str, Any]: contents: Dict[Path, str] = {} while queue: path_name = queue.pop() + test_re = re.compile(r"\.test\.|metadata\.yaml$") if resource_isdir("superset", str(path_name)): queue.extend( @@ -46,6 +48,8 @@ def load_contents() -> Dict[str, Any]: for child_name in resource_listdir("superset", str(path_name)) ) elif path_name.suffix.lower() in YAML_EXTENSIONS: + if load_test_data and test_re.search(str(path_name)) is None: + continue contents[path_name] = ( resource_stream("superset", str(path_name)).read().decode("utf-8") )