From 2bb6043ded3e26bfaf1074d3f812559c51e3a6cc Mon Sep 17 00:00:00 2001 From: Pankaj Koti Date: Fri, 20 Dec 2024 13:05:33 +0530 Subject: [PATCH] Address review comments on PR 1347 regarding profile_config for ExecutionMode.Docker (#1413) This PR addresses the open review comments on PR #1347 which adds profile_config to Docker execution mode. related: #1346 related: #1347 --------- Co-authored-by: Andrew Lui --- cosmos/operators/docker.py | 8 ++++++++ docs/getting_started/docker.rst | 12 ++++++++++++ tests/operators/test_docker.py | 27 +++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/cosmos/operators/docker.py b/cosmos/operators/docker.py index 81b7196b3..8dc614cfc 100644 --- a/cosmos/operators/docker.py +++ b/cosmos/operators/docker.py @@ -5,6 +5,7 @@ from airflow.utils.context import Context from cosmos.config import ProfileConfig +from cosmos.exceptions import CosmosValueError from cosmos.operators.base import ( AbstractDbtBaseOperator, DbtBuildMixin, @@ -47,6 +48,13 @@ def __init__( **kwargs: Any, ) -> None: self.profile_config = profile_config + if self.profile_config and not self.profile_config.profiles_yml_filepath: + raise CosmosValueError( + "For ExecutionMode.DOCKER, specifying ProfileConfig only works with profiles_yml_filepath method and " + "it must be specified. ProfileConfig with ProfileMapping method is not supported as the underlying " + "Airflow connections are not available in the Docker container for the mapping to work." + ) + super().__init__(image=image, **kwargs) def build_and_run_cmd(self, context: Context, cmd_flags: list[str] | None = None) -> Any: diff --git a/docs/getting_started/docker.rst b/docs/getting_started/docker.rst index ead5a3d32..000591488 100644 --- a/docs/getting_started/docker.rst +++ b/docs/getting_started/docker.rst @@ -97,3 +97,15 @@ Enable and trigger a run of the `jaffle_shop_docker