Skip to content

Commit

Permalink
Fix linter issues (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
jverre authored Sep 12, 2024
1 parent e5b1af0 commit 9f19c0f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions sdks/python/src/opik/api_objects/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class SpanData:
"""
The SpanData object is returned when calling :func:`opik.opik_context.get_current_span_data` from a tracked function.
"""

trace_id: str
id: str = dataclasses.field(default_factory=helpers.generate_id)
parent_span_id: Optional[str] = None
Expand Down
1 change: 1 addition & 0 deletions sdks/python/src/opik/api_objects/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class TraceData:
"""
The TraceData object is returned when calling :func:`opik.opik_context.get_current_trace_data` from a tracked function.
"""

id: str = dataclasses.field(default_factory=helpers.generate_id)
name: Optional[str] = None
start_time: Optional[datetime.datetime] = dataclasses.field(
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/src/opik/evaluation/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
"Moderation",
"RegexMatch",
"MetricComputationError",
"BaseMetric"
"BaseMetric",
]
9 changes: 5 additions & 4 deletions sdks/python/src/opik/evaluation/metrics/base_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@ class BaseMetric(abc.ABC):
"""
Abstract base class for all metrics. When creating a new metric, you should inherit
from this class and implement the abstract methods.
Args:
name: The name of the metric.
Example:
>>> from opik.evaluation.metrics import base_metric, score_result
>>>
>>>
>>> class MyCustomMetric(base_metric.BaseMetric):
>>> def __init__(self, name: str):
>>> self.name = name
>>>
>>>
>>> def score(self, input: str, output: str, **ignored_kwargs: Any):
>>> # Add you logic here
>>>
>>>
>>> return score_result.ScoreResult(
>>> value=0,
>>> name=self.name,
>>> reason="Optional reason for the score"
>>> )
"""

def __init__(self, name: str) -> None:
self.name = name

Expand Down

0 comments on commit 9f19c0f

Please sign in to comment.