diff --git a/dbt_invoke/internal/_utils.py b/dbt_invoke/internal/_utils.py index 90709d4..a3278b5 100644 --- a/dbt_invoke/internal/_utils.py +++ b/dbt_invoke/internal/_utils.py @@ -128,7 +128,7 @@ def dbt_ls( ctx, supported_resource_types=None, hide=True, - output='path', + output='json', logger=None, **kwargs, ): diff --git a/dbt_invoke/properties.py b/dbt_invoke/properties.py index fe1e3f3..4200438 100644 --- a/dbt_invoke/properties.py +++ b/dbt_invoke/properties.py @@ -265,6 +265,7 @@ def _transform_ls_results(ctx, **kwargs): output='json', **kwargs, ) + potential_result_paths = None results = dict() for i, potential_result in enumerate(potential_results): if 'original_file_path' in potential_result: @@ -274,16 +275,17 @@ def _transform_ls_results(ctx, **kwargs): # versions of dbt, we need to run "dbt ls" with the # "--output path" argument in order to retrieve paths else: - potential_result_paths = _utils.dbt_ls( - ctx, - supported_resource_types=_SUPPORTED_RESOURCE_TYPES, - logger=_LOGGER, - output='path', - **kwargs, - ) - assert len(potential_result_paths) == len( - potential_results - ), 'Length of results differs from length of result details' + if potential_result_paths is None: + potential_result_paths = _utils.dbt_ls( + ctx, + supported_resource_types=_SUPPORTED_RESOURCE_TYPES, + logger=_LOGGER, + output='path', + **kwargs, + ) + assert len(potential_result_paths) == len( + potential_results + ), 'Length of results differs from length of result details' potential_result_path = potential_result_paths[i] if Path(ctx.config['project_path'], potential_result_path).exists(): results[potential_result_path] = potential_result diff --git a/tests/test_utils.py b/tests/test_utils.py index 41bffeb..b7a491a 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -42,6 +42,7 @@ def test_dbt_ls(self): project_dir=self.project_dir, profiles_dir=self.profiles_dir, supported_resource_types=SUPPORTED_RESOURCE_TYPES, + output='path', logger=self.logger, **dbt_ls_kwargs, )