From 6f9faf3fa011e1e171aa88c56a5d309e9c626da0 Mon Sep 17 00:00:00 2001 From: Jacek Date: Thu, 12 Oct 2023 19:57:27 +0200 Subject: [PATCH] TRIVIAL: gooddata-dbt - allow skipping tests of specific insights give users time to fix it --- gooddata-dbt/gooddata_dbt/dbt_plugin.py | 22 ++++++++++++-------- gooddata-dbt/gooddata_dbt/gooddata/config.py | 1 + gooddata-dbt/gooddata_example.yml | 3 +++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gooddata-dbt/gooddata_dbt/dbt_plugin.py b/gooddata-dbt/gooddata_dbt/dbt_plugin.py index 1eb5d8bd7..46b7b1a4c 100644 --- a/gooddata-dbt/gooddata_dbt/dbt_plugin.py +++ b/gooddata-dbt/gooddata_dbt/dbt_plugin.py @@ -149,18 +149,22 @@ def store_analytics( ) -def test_insights(logger: logging.Logger, sdk: GoodDataSdk, workspace_id: str) -> None: +def test_insights(logger: logging.Logger, sdk: GoodDataSdk, workspace_id: str, skip_tests: Optional[List[str]]) -> None: logger.info(f"Test insights {workspace_id=}") insights = sdk.insights.get_insights(workspace_id) for insight in insights: - try: - start = time() - sdk.tables.for_insight(workspace_id, insight) - duration = int((time() - start) * 1000) - logger.info(f'Test successful insight="{insight.title}" duration={duration}(ms) ...') - except RuntimeError: - sys.exit() + logger.info(f"Executing insight {insight.id=} {insight.title=} ...") + if skip_tests is not None and insight.id in skip_tests: + logger.info(f"Skip test insight={insight.title} (requested in gooddata.yaml)") + else: + try: + start = time() + sdk.tables.for_insight(workspace_id, insight) + duration = int((time() - start) * 1000) + logger.info(f"Test successful {insight.id=} {insight.title=} duration={duration}(ms)") + except RuntimeError: + sys.exit() def create_localized_workspaces(data_product: GoodDataConfigProduct, sdk: GoodDataSdk, workspace_id: str) -> None: @@ -328,7 +332,7 @@ def process_organization( elif args.method == "deploy_analytics": deploy_analytics(logger, sdk_wrapper, workspace_id, data_product) elif args.method == "test_insights": - test_insights(logger, sdk_wrapper.sdk, workspace_id) + test_insights(logger, sdk_wrapper.sdk, workspace_id, data_product.skip_tests) else: raise Exception(f"Unsupported method requested in args: {args.method}") diff --git a/gooddata-dbt/gooddata_dbt/gooddata/config.py b/gooddata-dbt/gooddata_dbt/gooddata/config.py index c8a7e8935..7f70001de 100644 --- a/gooddata-dbt/gooddata_dbt/gooddata/config.py +++ b/gooddata-dbt/gooddata_dbt/gooddata/config.py @@ -38,6 +38,7 @@ class GoodDataConfigProduct(Base): environment_setup_id: str model_ids: List[str] = attr.field(default=list) localization: Optional[GoodDataConfigLocalization] = None + skip_tests: Optional[List[str]] = None @attrs.define(auto_attribs=True, kw_only=True) diff --git a/gooddata-dbt/gooddata_example.yml b/gooddata-dbt/gooddata_example.yml index 0ebe0dc44..a1c888de9 100644 --- a/gooddata-dbt/gooddata_example.yml +++ b/gooddata-dbt/gooddata_example.yml @@ -33,6 +33,9 @@ data_products: environment_setup_id: default model_ids: - hubspot + # If execution of an insight fails, and you need some time to fix it + skip_tests: + - "" # You can deliver data products to multiple organizations. Each organization can contain different (sub)set of products organizations: