fix: metric inheritance patterns: separate factory-created metrics from class-instantiated metrics #2316
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Primary Motivation: This PR fixes a fundamental inheritance pattern issue in the metrics system where factory-created metrics (via
@discrete_metric
,@numeric_metric
, etc.) and class-instantiated metrics (viaDiscreteMetric()
,NumericMetric()
, etc.) should have different base classes but were incorrectly sharing the same inheritance hierarchy.The Problem:
SimpleBaseMetric
(lightweight, decorator-based)SimpleLLMMetric
(LLM-enabled, full-featured)The Solution:
• Separated base classes: Created
SimpleBaseMetric
(for factory) andSimpleLLMMetric
(for class instantiation) as distinct, unrelated base classes• Removed
llm_based.py
: ConsolidatedBaseLLMMetric
andLLMMetric
intobase.py
asSimpleBaseMetric
andSimpleLLMMetric
• Fixed decorator inheritance: Factory methods now create metrics that inherit from
SimpleBaseMetric + ValidatorMixin
only• Fixed class inheritance: Class-based metrics like
DiscreteMetric
now inherit fromSimpleLLMMetric + ValidatorMixin
• Added validator system: Introduced modular validation mixins that work with both inheritance patterns
• Maintained backward compatibility: Added aliases
BaseMetric = SimpleBaseMetric
andLLMMetric = SimpleLLMMetric
Exact Steps Taken:
7d6de2a
- Updated gitignore for experimental directoriesc6101f8
- Renamed classes and established proper naming convention46450d8
- Refactored decorator and class-based inheritance patternsa464c37
- Simplified validator system with proper mixinsfe996f6
- Removedllm_based.py
after consolidationTest plan
@discrete_metric
) inherit fromSimpleBaseMetric
onlyDiscreteMetric()
) inherit fromSimpleLLMMetric
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]