diff --git a/Dockerfile b/Dockerfile index 6d6b31d4e..21284930a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,6 @@ RUN apt-get update && \ libpq-dev \ libssl-dev libffi-dev \ python3.9 python3.9-dev python3.9-venv libpython3.9-dev libpython3.9 \ - python3.9-distutils \ unixodbc-dev git lsb-release \ alien odbcinst diff --git a/Dockerfile-dev b/Dockerfile-dev index e66a97483..1a11c17ce 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -19,7 +19,6 @@ RUN apt-get update && \ libsasl2-dev \ libssl-dev libffi-dev \ python3.9 python3.9-dev python3.9-venv libpython3.9-dev libpython3.9 \ - python3.9-distutils \ unixodbc-dev git && \ apt-get clean -qq -y && \ apt-get autoclean -qq -y && \ diff --git a/soda/core/soda/common/env_helper.py b/soda/core/soda/common/env_helper.py index f68638537..b73dd9dd8 100644 --- a/soda/core/soda/common/env_helper.py +++ b/soda/core/soda/common/env_helper.py @@ -1,12 +1,24 @@ from __future__ import annotations import os -from distutils.util import strtobool from dotenv import load_dotenv from soda.common.logs import Logs +def strtobool(val: str) -> bool: + if not isinstance(val, str): + raise ValueError(f"Invalid type for truth value: {type(val).__name__}. Expected str, got {val!r}") + if val.lower() in ("yes", "y", "true", "t", "on", "1"): + return True + elif val.lower() in ("no", "n", "false", "f", "off", "0"): + return False + else: + raise ValueError( + f"Invalid truth value: {val!r}. Expected one of: yes, y, true, t, on, 1, no, n, false, f, off, 0" + ) + + class EnvHelper: __instance = None diff --git a/soda/core/soda/telemetry/soda_telemetry.py b/soda/core/soda/telemetry/soda_telemetry.py index e1ad927b4..5347d7660 100644 --- a/soda/core/soda/telemetry/soda_telemetry.py +++ b/soda/core/soda/telemetry/soda_telemetry.py @@ -1,7 +1,6 @@ import logging import os import platform -from distutils.util import strtobool from typing import Dict from opentelemetry import trace @@ -11,6 +10,7 @@ from opentelemetry.semconv.resource import ResourceAttributes from soda.__version__ import SODA_CORE_VERSION from soda.common.config_helper import ConfigHelper +from soda.common.env_helper import strtobool # from soda.execution.data_source import DataSource from soda.telemetry.memory_span_exporter import MemorySpanExporter @@ -85,8 +85,8 @@ def __init__(self, test_mode: bool): def __setup(self): """Set up Open Telemetry processors and exporters for normal use.""" - local_debug_mode = self.soda_config.get_value("telemetry_local_debug_mode") or bool( - strtobool(os.getenv("telemetry_local_debug_mode", "false")) + local_debug_mode = self.soda_config.get_value("telemetry_local_debug_mode") or strtobool( + os.getenv("telemetry_local_debug_mode", "false") ) if local_debug_mode or logger.getEffectiveLevel() == logging.DEBUG: