From 893b28aae536d4fe5e38cc5e7238c119cbbe65e5 Mon Sep 17 00:00:00 2001 From: "Ching Yi, Chan" Date: Thu, 5 Oct 2023 15:40:00 +0800 Subject: [PATCH] Fix dbt-core breaking our task runner (#895) Signed-off-by: Ching Yi, Chan --- piperider_cli/dbt/list_task.py | 12 ++++++------ tests/test_dbt_integeration.py | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/piperider_cli/dbt/list_task.py b/piperider_cli/dbt/list_task.py index b2b877a44..6ef83e70a 100644 --- a/piperider_cli/dbt/list_task.py +++ b/piperider_cli/dbt/list_task.py @@ -350,16 +350,16 @@ def __init__(self): "dependencies": None, } - if dbt_version >= '1.6.2': - # Since dbt-core v1.6.2 'dbt_cloud' is required in RuntimeConfig + def has_field(field_name): + return field_name in {f.name for f in fields(RuntimeConfig)} + + if has_field('dbt_cloud'): data['dbt_cloud'] = None - found_restrict_access = any(field.name == 'restrict_access' for field in fields(RuntimeConfig)) - found_packages_specified_path = any(field.name == 'packages_specified_path' for field in fields(RuntimeConfig)) - if found_restrict_access: + if has_field('restrict_access'): data['restrict_access'] = False - if found_packages_specified_path: + if has_field('packages_specified_path'): data['packages_specified_path'] = "packages.yml" super().__init__(args=None, **data) diff --git a/tests/test_dbt_integeration.py b/tests/test_dbt_integeration.py index d26eb6efa..3c65a7d48 100644 --- a/tests/test_dbt_integeration.py +++ b/tests/test_dbt_integeration.py @@ -150,6 +150,7 @@ def test_list_all_resources_16(self): "seed.jaffle_shop.raw_customers", "seed.jaffle_shop.raw_orders", "seed.jaffle_shop.raw_payments", + "semantic_model.jaffle_shop.orders", "test.jaffle_shop.accepted_values_int_order_payments_pivoted_status__placed__shipped__completed__return_pending__returned.0ccdff53e8", "test.jaffle_shop.accepted_values_orders_status__placed__shipped__completed__return_pending__returned.be6b5b5ec3", "test.jaffle_shop.accepted_values_stg_orders_status__placed__shipped__completed__return_pending__returned.080fb20aad",