diff --git a/src/splunk_ao/__init__.py b/src/splunk_ao/__init__.py index 977afc6e..655ac9af 100644 --- a/src/splunk_ao/__init__.py +++ b/src/splunk_ao/__init__.py @@ -57,7 +57,7 @@ from splunk_ao.protect import ainvoke_protect, invoke_protect from splunk_ao.provider import AnthropicProvider, AzureProvider, BedrockProvider, OpenAIProvider, Provider from splunk_ao.schema.message import Message -from splunk_ao.schema.metrics import GalileoScorers, SplunkAOMetrics +from splunk_ao.schema.metrics import SplunkAOMetrics from splunk_ao.shared.base import SyncState from splunk_ao.shared.exceptions import ( APIError, @@ -107,7 +107,6 @@ "ExecutionStatus", "Experiment", "ForbiddenError", - "GalileoScorers", "Integration", "LlmMetric", "LlmSpan", diff --git a/src/splunk_ao/schema/metrics.py b/src/splunk_ao/schema/metrics.py index b9fb0c64..27e25025 100644 --- a/src/splunk_ao/schema/metrics.py +++ b/src/splunk_ao/schema/metrics.py @@ -1,5 +1,4 @@ -import warnings -from collections.abc import Callable, Iterator +from collections.abc import Callable from enum import Enum from typing import Any, Generic, TypeVar @@ -10,7 +9,6 @@ from galileo_core.schemas.logging.step import STEP_TYPES_WITH_CHILD_SPANS, StepType from galileo_core.schemas.logging.trace import Trace from galileo_core.schemas.shared.metric import MetricValueType -from galileo_core.schemas.shared.scorers.scorer_name import ScorerName class SplunkAOMetrics(str, Enum): @@ -71,55 +69,6 @@ class SplunkAOMetrics(str, Enum): user_intent_change = "User Intent Change" -class _SplunkAOScorersProxyMeta(type): - """Metaclass that makes GalileoScorers a deprecated proxy for ScorerName.""" - - _DEPRECATION_MSG = ( - "GalileoScorers is deprecated and will be removed in a future release. Use galileo_core ScorerName instead." - ) - - def __getattribute__(cls, name: str) -> Any: - if name.startswith("_") or name in ("__class__", "__mro__", "__dict__", "__bases__"): - return type.__getattribute__(cls, name) - warnings.warn(cls._DEPRECATION_MSG, DeprecationWarning, stacklevel=2) - return getattr(ScorerName, name) - - def __getitem__(cls, name: str) -> ScorerName: - warnings.warn(cls._DEPRECATION_MSG, DeprecationWarning, stacklevel=2) - return ScorerName[name] - - def __instancecheck__(cls, instance: Any) -> bool: - return isinstance(instance, ScorerName) - - def __subclasscheck__(cls, subclass: type) -> bool: - return issubclass(subclass, ScorerName) - - def __iter__(cls) -> Iterator[ScorerName]: - warnings.warn(cls._DEPRECATION_MSG, DeprecationWarning, stacklevel=2) - return iter(ScorerName) - - def __contains__(cls, item: Any) -> bool: - warnings.warn(cls._DEPRECATION_MSG, DeprecationWarning, stacklevel=2) - return item in ScorerName - - def __dir__(cls) -> list[str]: - return [m.name for m in ScorerName] - - def __repr__(cls) -> str: - return "" - - -class _SplunkAOScorersProxy(metaclass=_SplunkAOScorersProxyMeta): - """Deprecated proxy that forwards to ScorerName.""" - - def __new__(cls, value: Any) -> ScorerName: - warnings.warn(_SplunkAOScorersProxyMeta._DEPRECATION_MSG, DeprecationWarning, stacklevel=2) - return ScorerName(value) - - -GalileoScorers = _SplunkAOScorersProxy - - MetricType = TypeVar("MetricType", bound=MetricValueType) diff --git a/tests/test_deprecations.py b/tests/test_deprecations.py deleted file mode 100644 index 6183d37c..00000000 --- a/tests/test_deprecations.py +++ /dev/null @@ -1,78 +0,0 @@ -import warnings - -import pytest - -from galileo_core.schemas.shared.scorers.scorer_name import ScorerName - -# ================================ -# GalileoScorers deprecation tests -# ================================ - - -def test_galileo_scorers_attribute_access_emits_deprecation_warning(): - """Accessing GalileoScorers. should emit a DeprecationWarning.""" - with pytest.warns(DeprecationWarning, match="GalileoScorers is deprecated"): - from splunk_ao.schema.metrics import GalileoScorers - - _ = GalileoScorers.correctness - - -def test_galileo_metrics_attribute_access_does_not_warn(): - """Accessing SplunkAOMetrics. should NOT emit a DeprecationWarning.""" - from splunk_ao.schema.metrics import SplunkAOMetrics - - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - _ = SplunkAOMetrics.correctness - assert not any(isinstance(x.message, DeprecationWarning) for x in w) - - -def test_top_level_imported_galileo_scorers_emits_deprecation_on_access(): - """Importing GalileoScorers from the top-level package and accessing attribute should warn.""" - with pytest.warns(DeprecationWarning, match="GalileoScorers is deprecated"): - from splunk_ao import GalileoScorers - - _ = GalileoScorers.correctness - - -def test_galileo_scorers_callable_and_lookup_delegate(): - """GalileoScorers('correctness') and GalileoScorers['correctness'] should work and warn.""" - from splunk_ao.schema.metrics import GalileoScorers - - # Value-based lookup uses the ScorerName value (internal name) - with pytest.warns(DeprecationWarning, match="GalileoScorers is deprecated"): - member = GalileoScorers("correctness") - assert member is ScorerName.correctness - - # Name-based lookup uses the member name - with pytest.warns(DeprecationWarning, match="GalileoScorers is deprecated"): - member2 = GalileoScorers["correctness"] - assert member2 is ScorerName.correctness - - with pytest.warns(DeprecationWarning, match="GalileoScorers is deprecated"): - assert ScorerName.correctness in GalileoScorers - - -def test_galileo_scorers_isinstance_check(): - """isinstance checks with GalileoScorers should work — delegates to ScorerName.""" - from splunk_ao.schema.metrics import GalileoScorers - - assert isinstance(ScorerName.correctness, GalileoScorers) - assert not isinstance("not a scorer", GalileoScorers) - - -def test_galileo_scorers_issubclass_check(): - """issubclass checks with GalileoScorers should work — delegates to ScorerName.""" - from splunk_ao.schema.metrics import GalileoScorers - - assert issubclass(type(ScorerName.correctness), GalileoScorers) - - -def test_galileo_scorers_returns_scorer_name_members(): - """GalileoScorers attribute access should return ScorerName enum members.""" - from splunk_ao.schema.metrics import GalileoScorers - - with pytest.warns(DeprecationWarning, match="GalileoScorers is deprecated"): - scorer = GalileoScorers.correctness - assert scorer is ScorerName.correctness - assert scorer.value == "correctness"