From 4b0b147753877d48ad14bcc32809d21204b136b4 Mon Sep 17 00:00:00 2001 From: Justin Bandoro <79104794+jbandoro@users.noreply.github.com> Date: Thu, 14 Dec 2023 23:28:17 -0800 Subject: [PATCH] Support disabling event tracking when using Cosmos profile mapping (#768) Since dbt by default tracks events by sending anonymous statistic usage when dbt is invoked, users who currently use Cosmos profile mapping can only opt-out by setting environment variables as described in https://github.com/astronomer/astronomer-cosmos/issues/724#issuecomment-1839538680 This PR adds a new arg to the profile mapping so that the [dbt recommended config block](https://docs.getdbt.com/reference/global-configs/usage-stats) can be added in the generated `profiles.yml` file: ```yaml config: send_anonymous_usage_stats: False ``` Closes: #724 --- cosmos/profiles/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cosmos/profiles/base.py b/cosmos/profiles/base.py index 3fb026174..f10ad596b 100644 --- a/cosmos/profiles/base.py +++ b/cosmos/profiles/base.py @@ -41,10 +41,11 @@ class BaseProfileMapping(ABC): _conn: Connection | None = None - def __init__(self, conn_id: str, profile_args: dict[str, Any] | None = None): + def __init__(self, conn_id: str, profile_args: dict[str, Any] | None = None, disable_event_tracking: bool = False): self.conn_id = conn_id self.profile_args = profile_args or {} self._validate_profile_args() + self.disable_event_tracking = disable_event_tracking def _validate_profile_args(self) -> None: """ @@ -161,7 +162,7 @@ def get_profile_file_contents( profile_name: str, target_name: str = "cosmos_target", use_mock_values: bool = False, - dbt_config_vars: dict[str, Any] | None = None + dbt_config_vars: dict[str, Any] | None = None, ) -> str: """ Translates the profile into a string that can be written to a profiles.yml file.