Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRIVIAL: gooddata-dbt - allow skipping tests of specific insights #388

Merged
1 commit merged into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions gooddata-dbt/gooddata_dbt/dbt_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}")

Expand Down
1 change: 1 addition & 0 deletions gooddata-dbt/gooddata_dbt/gooddata/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions gooddata-dbt/gooddata_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
- "<insight_id>"

# You can deliver data products to multiple organizations. Each organization can contain different (sub)set of products
organizations:
Expand Down