From 25f68d0ca5cc37943e3652fc1774d014dd84f9c3 Mon Sep 17 00:00:00 2001 From: duongphannamhung Date: Tue, 22 Jul 2025 18:48:15 +0700 Subject: [PATCH 1/2] [Enhancement] Deprecated Parser with LoadMode Custom --- cosmos/dbt/graph.py | 6 ++++++ tests/dbt/test_graph.py | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/cosmos/dbt/graph.py b/cosmos/dbt/graph.py index 0d26a32644..3c8582bd61 100644 --- a/cosmos/dbt/graph.py +++ b/cosmos/dbt/graph.py @@ -14,6 +14,7 @@ from pathlib import Path from subprocess import PIPE, Popen from typing import TYPE_CHECKING, Any, Dict, Optional +import warnings from airflow.models import Variable @@ -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..b41f639645 100644 --- a/tests/dbt/test_graph.py +++ b/tests/dbt/test_graph.py @@ -1039,7 +1039,30 @@ def test_load_via_load_via_custom_parser(project_name, nodes_count): assert dbt_graph.nodes == dbt_graph.filtered_nodes 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") From acf1e0784bc1f974301df7383ff4692942959d0a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 11:52:17 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8E=A8=20[pre-commit.ci]=20Auto=20for?= =?UTF-8?q?mat=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cosmos/dbt/graph.py | 2 +- tests/dbt/test_graph.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cosmos/dbt/graph.py b/cosmos/dbt/graph.py index 3c8582bd61..d25f0d44a7 100644 --- a/cosmos/dbt/graph.py +++ b/cosmos/dbt/graph.py @@ -8,13 +8,13 @@ import os import platform import tempfile +import warnings import zlib from dataclasses import dataclass, field from functools import cached_property from pathlib import Path from subprocess import PIPE, Popen from typing import TYPE_CHECKING, Any, Dict, Optional -import warnings from airflow.models import Variable diff --git a/tests/dbt/test_graph.py b/tests/dbt/test_graph.py index b41f639645..4b125bf471 100644 --- a/tests/dbt/test_graph.py +++ b/tests/dbt/test_graph.py @@ -1039,7 +1039,8 @@ def test_load_via_load_via_custom_parser(project_name, nodes_count): assert dbt_graph.nodes == dbt_graph.filtered_nodes 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.""" @@ -1064,6 +1065,7 @@ def test_validate_load_via_load_via_custom_parser_deprecated(project_name): 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)