From 09cd1c27e5079bdcde1a56aa93058f7e44e3f608 Mon Sep 17 00:00:00 2001 From: Jacek Date: Tue, 5 Dec 2023 13:18:03 +0100 Subject: [PATCH] Log warning if import of snowplow_tracker fails Closes issue #8256 It may be a temporary woraround - it may be removed once https://github.com/dbt-labs/dbt-core/pull/8680 is merged. --- src/meltano/core/tracking/tracker.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/meltano/core/tracking/tracker.py b/src/meltano/core/tracking/tracker.py index 133aa6154d..9acad0984b 100644 --- a/src/meltano/core/tracking/tracker.py +++ b/src/meltano/core/tracking/tracker.py @@ -20,8 +20,6 @@ import structlog import tzlocal from psutil import Process -from snowplow_tracker import Emitter, SelfDescribing, SelfDescribingJson -from snowplow_tracker import Tracker as SnowplowTracker from meltano.core.project import Project from meltano.core.tracking.schemas import ( @@ -49,6 +47,18 @@ logger = structlog.get_logger(__name__) +# Supress these imports from snowplow_tracker if tracking is disabled +# It helps to resolve issues related to import conflicts - +# snowplow-tracker vs. minimal-snowplow tracker +try: + from snowplow_tracker import Emitter, SelfDescribing, SelfDescribingJson + from snowplow_tracker import Tracker as SnowplowTracker +except Exception as e: + logger.warning( + "Import of snowplow_tracker failed. " + f"Disable tracking to fix it. Reason: {str(e)}", + ) + class BlockEvents(Enum): """Events describing a block state."""