diff --git a/dbt_invoke/internal/_utils.py b/dbt_invoke/internal/_utils.py index 3138a31..28d5599 100644 --- a/dbt_invoke/internal/_utils.py +++ b/dbt_invoke/internal/_utils.py @@ -5,6 +5,17 @@ import platform import re from dbt.task.base import get_nearest_project_dir + +try: + from importlib.metadata import version + + DBT_VERSION = version('dbt-core') + +except ImportError: + import pkg_resources + + DBT_VERSION = pkg_resources.get_distribution('dbt-core').version + from ruamel.yaml import YAML, YAMLError MACROS = { @@ -107,7 +118,10 @@ def get_project_info(ctx, project_dir=None): :return: None """ project = Project(project_dir) - project_path = get_nearest_project_dir(project) + if DBT_VERSION < '1.5.0': + project_path = get_nearest_project_dir(project) + else: + project_path = get_nearest_project_dir(project.project_dir) project_yml_path = Path(project_path, 'dbt_project.yml') # Get project configuration values from dbt_project.yml # (or use dbt defaults) diff --git a/dbt_invoke/internal/_version.py b/dbt_invoke/internal/_version.py index fc79d63..020ed73 100644 --- a/dbt_invoke/internal/_version.py +++ b/dbt_invoke/internal/_version.py @@ -1 +1 @@ -__version__ = '0.2.1' +__version__ = '0.2.2'