From 88ae193478d215a269d1fa16f48a37391eaa20f5 Mon Sep 17 00:00:00 2001 From: TMVKasiViswanath Date: Fri, 21 Feb 2025 23:30:05 +0530 Subject: [PATCH 1/2] Resolved issue #225 --- prometheus_api_client/__init__.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/prometheus_api_client/__init__.py b/prometheus_api_client/__init__.py index 47176ab..839a400 100644 --- a/prometheus_api_client/__init__.py +++ b/prometheus_api_client/__init__.py @@ -1,10 +1,23 @@ + """A collection of tools to collect and manipulate prometheus metrics.""" __title__ = "prometheus-connect" __version__ = "0.5.7" -from .prometheus_connect import * # noqa F403 -from .metric import Metric # noqa F401 -from .metrics_list import MetricsList # noqa F401 -from .metric_snapshot_df import MetricSnapshotDataFrame # noqa F401 -from .metric_range_df import MetricRangeDataFrame # noqa F401 +def __getattr__(name): + if name == "PrometheusConnect": + from .prometheus_connect import PrometheusConnect + return PrometheusConnect + elif name == "Metric": + from .metric import Metric + return Metric + elif name == "MetricsList": + from .metrics_list import MetricsList + return MetricsList + elif name == "MetricSnapshotDataFrame": + from .metric_snapshot_df import MetricSnapshotDataFrame + return MetricSnapshotDataFrame + elif name == "MetricRangeDataFrame": + from .metric_range_df import MetricRangeDataFrame + return MetricRangeDataFrame + raise AttributeError(f"module {__name__} has no attribute {name}") \ No newline at end of file From 4fdea050db5aff1e9485232c290d4daf0452674c Mon Sep 17 00:00:00 2001 From: TMVKasiViswanath Date: Sat, 22 Feb 2025 02:00:33 +0530 Subject: [PATCH 2/2] Refactored __init__.py to improve imports and maintainability --- prometheus_api_client/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prometheus_api_client/__init__.py b/prometheus_api_client/__init__.py index 839a400..c19cd43 100644 --- a/prometheus_api_client/__init__.py +++ b/prometheus_api_client/__init__.py @@ -1,9 +1,9 @@ - """A collection of tools to collect and manipulate prometheus metrics.""" __title__ = "prometheus-connect" __version__ = "0.5.7" +from .exceptions import PrometheusApiClientException, MetricValueConversionError def __getattr__(name): if name == "PrometheusConnect": from .prometheus_connect import PrometheusConnect @@ -20,4 +20,4 @@ def __getattr__(name): elif name == "MetricRangeDataFrame": from .metric_range_df import MetricRangeDataFrame return MetricRangeDataFrame - raise AttributeError(f"module {__name__} has no attribute {name}") \ No newline at end of file + raise AttributeError(f"module {__name__} has no attribute {name}")