diff --git a/cosmos/dbt/graph.py b/cosmos/dbt/graph.py index 0d26a32644..d25f0d44a7 100644 --- a/cosmos/dbt/graph.py +++ b/cosmos/dbt/graph.py @@ -8,6 +8,7 @@ import os import platform import tempfile +import warnings import zlib from dataclasses import dataclass, field from functools import cached_property @@ -836,6 +837,11 @@ def load_via_custom_parser(self) -> None: * self.filtered_nodes """ self.load_method = LoadMode.CUSTOM + warnings.warn( + "Using `load_method` = `LoadMode.CUSTOM` is deprecated in current version and will" + " be removed in Cosmos 2.0", + DeprecationWarning, + ) logger.info("Trying to parse the dbt project `%s` using a custom Cosmos method...", self.project.project_name) if self.render_config.selector: diff --git a/tests/dbt/test_graph.py b/tests/dbt/test_graph.py index 8b0522ea10..4b125bf471 100644 --- a/tests/dbt/test_graph.py +++ b/tests/dbt/test_graph.py @@ -1041,6 +1041,31 @@ def test_load_via_load_via_custom_parser(project_name, nodes_count): assert len(dbt_graph.nodes) == nodes_count +@pytest.mark.parametrize("project_name", [("altered_jaffle_shop"), ("jaffle_shop_python")]) +def test_validate_load_via_load_via_custom_parser_deprecated(project_name): + """Deprecating warnings should be raised when using load_mode CUSTOM.""" + project_config = ProjectConfig(dbt_project_path=DBT_PROJECTS_ROOT_DIR / project_name) + execution_config = ExecutionConfig(dbt_project_path=DBT_PROJECTS_ROOT_DIR / project_name) + render_config = RenderConfig( + dbt_project_path=DBT_PROJECTS_ROOT_DIR / project_name, + source_rendering_behavior=SOURCE_RENDERING_BEHAVIOR, + ) + profile_config = ProfileConfig( + profile_name="test", + target_name="test", + profiles_yml_filepath=DBT_PROJECTS_ROOT_DIR / project_name / "profiles.yml", + ) + dbt_graph = DbtGraph( + project=project_config, + profile_config=profile_config, + render_config=render_config, + execution_config=execution_config, + ) + + with pytest.deprecated_call(): + dbt_graph.load_via_custom_parser() + + def test_load_via_load_via_custom_parser_select_rendering_config(): project_config = ProjectConfig(dbt_project_path=DBT_PROJECTS_ROOT_DIR / "jaffle_shop") execution_config = ExecutionConfig(dbt_project_path=DBT_PROJECTS_ROOT_DIR / DBT_PROJECT_NAME)