diff --git a/opendbt/__init__.py b/opendbt/__init__.py index 1d507a8..eed2d4f 100644 --- a/opendbt/__init__.py +++ b/opendbt/__init__.py @@ -56,7 +56,7 @@ def run(args: list) -> dbtRunnerResult: rer: RunResult _exception = result.exception if result.exception else None - if (_exception is None and result.result and result.result.results and + if (_exception is None and hasattr(result.result, 'results') and result.result.results and len(result.result.results) > 0 and result.result.results[0].message ): _exception = DbtRuntimeError(result.result.results[0].message) diff --git a/opendbt/dbt/__init__.py b/opendbt/dbt/__init__.py index 892b2f1..3dc9ca5 100644 --- a/opendbt/dbt/__init__.py +++ b/opendbt/dbt/__init__.py @@ -4,15 +4,21 @@ def patch_dbt(): # ================================================================================================================ - # Monkey Patching! Override dbt lib AdapterContainer.register_adapter method with new one above + # Monkey Patching! Override dbt lib code with new one # ================================================================================================================ - if Version(dbt.version.get_installed_version().to_version_string(skip_matcher=True)) < Version("1.8.0"): + dbt_version = Version(dbt.version.get_installed_version().to_version_string(skip_matcher=True)) + if dbt_version >= Version("1.7.0") and dbt_version < Version("1.8.0"): from opendbt.dbt.v17.task.docs.generate import OpenDbtGenerateTask from opendbt.dbt.v17.adapters.factory import OpenDbtAdapterContainer dbt.task.generate.GenerateTask = OpenDbtGenerateTask dbt.adapters.factory.FACTORY = OpenDbtAdapterContainer() - else: + elif dbt_version >= Version("1.8.0") and dbt_version < Version("1.9.0"): from opendbt.dbt.v18.task.docs.generate import OpenDbtGenerateTask from opendbt.dbt.v18.adapters.factory import OpenDbtAdapterContainer dbt.task.docs.generate.GenerateTask = OpenDbtGenerateTask dbt.adapters.factory.FACTORY = OpenDbtAdapterContainer() + else: + raise Exception( + f"Unsupported dbt version {dbt_version}, please make sure dbt version is supported/integrated by opendbt") + + # shared code patches