From d2cf04391051425c75b347e8f8e87fb8383d6e3e Mon Sep 17 00:00:00 2001 From: Elon Gliksberg Date: Mon, 31 Jul 2023 11:30:00 +0300 Subject: [PATCH 1/2] Running 'dbt deps' earlier in edr's logic. --- elementary/monitor/data_monitoring/data_monitoring.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/elementary/monitor/data_monitoring/data_monitoring.py b/elementary/monitor/data_monitoring/data_monitoring.py index 5755e0b43..12173337b 100644 --- a/elementary/monitor/data_monitoring/data_monitoring.py +++ b/elementary/monitor/data_monitoring/data_monitoring.py @@ -30,12 +30,12 @@ def __init__( disable_samples: bool = False, filter: Optional[str] = None, ): + self.execution_properties: Dict[str, Any] = {} self.config = config self.tracking = tracking self.internal_dbt_runner = self._init_internal_dbt_runner() self.user_dbt_runner = self._init_user_dbt_runner() - - self.execution_properties: Dict[str, Any] = {} + self._download_dbt_package_if_needed(force_update_dbt_package) latest_invocation = self.get_latest_invocation() self.project_name = latest_invocation.get("project_name") dbt_pkg_version = latest_invocation.get("elementary_version") @@ -59,7 +59,6 @@ def __init__( self.slack_client = SlackClient.create_client( self.config, tracking=self.tracking ) - self._download_dbt_package_if_needed(force_update_dbt_package) self.elementary_database_and_schema = self.get_elementary_database_and_schema() self.success = True self.disable_samples = disable_samples From bee928221eedc04bbbb8826a7f2968b22ad2c617 Mon Sep 17 00:00:00 2001 From: Elon Gliksberg Date: Mon, 31 Jul 2023 11:35:59 +0300 Subject: [PATCH 2/2] Using an existing DbtRunner. --- .../monitor/data_monitoring/data_monitoring.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/elementary/monitor/data_monitoring/data_monitoring.py b/elementary/monitor/data_monitoring/data_monitoring.py index 12173337b..d23bebb9f 100644 --- a/elementary/monitor/data_monitoring/data_monitoring.py +++ b/elementary/monitor/data_monitoring/data_monitoring.py @@ -174,17 +174,11 @@ def _check_dbt_package_compatibility(dbt_pkg_ver_str: str) -> None: ) def _get_warehouse_info(self, hash_id: bool = False) -> Optional[WarehouseInfo]: - dbt_runner = DbtRunner( - dbt_project_utils.PATH, - self.config.profiles_dir, - self.config.profile_target, - env_vars=self.config.env_vars, - ) try: warehouse_type, warehouse_unique_id = json.loads( - dbt_runner.run_operation("get_adapter_type_and_unique_id", quiet=True)[ - 0 - ] + self.internal_dbt_runner.run_operation( + "get_adapter_type_and_unique_id", quiet=True + )[0] ) return WarehouseInfo( id=warehouse_unique_id if not hash_id else hash(warehouse_unique_id),