From 4ab4efe0f3647686fd1600e0190621416e78e102 Mon Sep 17 00:00:00 2001 From: dwreeves Date: Sat, 2 Mar 2024 18:22:30 -0500 Subject: [PATCH 1/3] add project dir flag to local DAG --- cosmos/operators/local.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cosmos/operators/local.py b/cosmos/operators/local.py index e6a09748f..caeee1c1c 100644 --- a/cosmos/operators/local.py +++ b/cosmos/operators/local.py @@ -298,6 +298,8 @@ def run_command( env.update(env_vars) flags = [ + "--project-dir", + str(tmp_project_dir), "--profiles-dir", str(profile_path.parent), "--profile", From 3884b4c1fa15898564f3c29984986d28ecbd7828 Mon Sep 17 00:00:00 2001 From: dwreeves Date: Mon, 4 Mar 2024 23:46:27 -0500 Subject: [PATCH 2/3] fix tests --- tests/operators/test_local.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/operators/test_local.py b/tests/operators/test_local.py index c054cf4d1..292b6c6e0 100644 --- a/tests/operators/test_local.py +++ b/tests/operators/test_local.py @@ -703,18 +703,26 @@ def test_dbt_docs_gcs_local_operator(): @patch("cosmos.config.ProfileConfig.ensure_profile") @patch("cosmos.operators.local.DbtLocalBaseOperator.run_subprocess") @patch("cosmos.operators.local.DbtLocalBaseOperator.run_dbt_runner") +@patch("cosmos.operators.local.tempfile.TemporaryDirectory") @pytest.mark.parametrize("invocation_mode", [InvocationMode.SUBPROCESS, InvocationMode.DBT_RUNNER]) def test_operator_execute_deps_parameters( + mock_temporary_directory, mock_dbt_runner, mock_subprocess, mock_ensure_profile, mock_exception_handling, mock_store_compiled_sql, invocation_mode, + tmp_path ): + project_dir = tmp_path / "mock_project_tmp_dir" + project_dir.mkdir() + expected_call_kwargs = [ "/usr/local/bin/dbt", "deps", + "--project-dir", + project_dir.as_posix(), "--profiles-dir", "/path/to", "--profile", @@ -732,6 +740,7 @@ def test_operator_execute_deps_parameters( invocation_mode=invocation_mode, ) mock_ensure_profile.return_value.__enter__.return_value = (Path("/path/to/profile"), {"ENV_VAR": "value"}) + mock_temporary_directory.return_value.__enter__.return_value = project_dir.as_posix() task.execute(context={"task_instance": MagicMock()}) if invocation_mode == InvocationMode.SUBPROCESS: assert mock_subprocess.call_args_list[0].kwargs["command"] == expected_call_kwargs From 64f2d4e4f4e5cadf42e9389e4dc2ca9b3e0a3884 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 04:46:42 +0000 Subject: [PATCH 3/3] =?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 --- tests/operators/test_local.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/operators/test_local.py b/tests/operators/test_local.py index 292b6c6e0..6e1a6f6a9 100644 --- a/tests/operators/test_local.py +++ b/tests/operators/test_local.py @@ -713,7 +713,7 @@ def test_operator_execute_deps_parameters( mock_exception_handling, mock_store_compiled_sql, invocation_mode, - tmp_path + tmp_path, ): project_dir = tmp_path / "mock_project_tmp_dir" project_dir.mkdir()