Skip to content

Commit 094bc75

Browse files
authored
chore(llmobs): remove submit_evaluation_for method (#15045)
## Description [MLOB-4217] Removes `submit_evaluation_for` method in favor of `submit_evaluation` which should be released in ddtrace 4.0. ## Testing <!-- Describe your testing strategy or note what tests are included --> ## Risks <!-- Note any risks associated with this change, or "None" if no risks --> ## Additional Notes <!-- Any other information that would be helpful for reviewers --> [MLOB-4217]: https://datadoghq.atlassian.net/browse/MLOB-4217?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 9fe33ac commit 094bc75

File tree

3 files changed

+10
-51
lines changed

3 files changed

+10
-51
lines changed

ddtrace/llmobs/_llmobs.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,50 +1561,12 @@ def _set_dict_attribute(span: Span, key, value: Dict[str, Any]) -> None:
15611561
existing_value.update(value)
15621562
span._set_ctx_item(key, existing_value)
15631563

1564-
@classmethod
1565-
def submit_evaluation_for(
1566-
cls,
1567-
label: str,
1568-
metric_type: str,
1569-
value: Union[str, int, float, bool],
1570-
span: Optional[dict] = None,
1571-
span_with_tag_value: Optional[Dict[str, str]] = None,
1572-
tags: Optional[Dict[str, str]] = None,
1573-
ml_app: Optional[str] = None,
1574-
timestamp_ms: Optional[int] = None,
1575-
metadata: Optional[Dict[str, object]] = None,
1576-
assessment: Optional[str] = None,
1577-
reasoning: Optional[str] = None,
1578-
) -> None:
1579-
"""
1580-
Submits a custom evaluation metric for a given span. This method is deprecated and will be
1581-
removed in the next major version of ddtrace (4.0). Please use `LLMObs.submit_evaluation()` instead.
1582-
"""
1583-
log.warning(
1584-
"LLMObs.submit_evaluation_for() is deprecated and will be removed in the next major "
1585-
"version of ddtrace (4.0). Please use LLMObs.submit_evaluation() instead."
1586-
)
1587-
return cls.submit_evaluation(
1588-
label=label,
1589-
metric_type=metric_type,
1590-
value=value,
1591-
span=span,
1592-
span_with_tag_value=span_with_tag_value,
1593-
tags=tags,
1594-
ml_app=ml_app,
1595-
timestamp_ms=timestamp_ms,
1596-
metadata=metadata,
1597-
assessment=assessment,
1598-
reasoning=reasoning,
1599-
)
1600-
16011564
@classmethod
16021565
def submit_evaluation(
16031566
cls,
16041567
label: str,
16051568
metric_type: str,
16061569
value: Union[str, int, float, bool],
1607-
span_context: Optional[Dict[str, str]] = None,
16081570
span: Optional[dict] = None,
16091571
span_with_tag_value: Optional[Dict[str, str]] = None,
16101572
tags: Optional[Dict[str, str]] = None,
@@ -1621,9 +1583,6 @@ def submit_evaluation(
16211583
:param str metric_type: The type of the evaluation metric. One of "categorical", "score", "boolean".
16221584
:param value: The value of the evaluation metric.
16231585
Must be a string (categorical), integer (score), float (score), or boolean (boolean).
1624-
:param dict span_context: A dictionary containing the span_id and trace_id of interest. This is a
1625-
deprecated parameter and will be removed in the next major version of
1626-
ddtrace (4.0). Please use `span` or `span_with_tag_value` instead.
16271586
:param dict span: A dictionary of shape {'span_id': str, 'trace_id': str} uniquely identifying
16281587
the span associated with this evaluation.
16291588
:param dict span_with_tag_value: A dictionary with the format {'tag_key': str, 'tag_value': str}
@@ -1637,13 +1596,6 @@ def submit_evaluation(
16371596
:param str assessment: An assessment of this evaluation. Must be either "pass" or "fail".
16381597
:param str reasoning: An explanation of the evaluation result.
16391598
"""
1640-
if span_context is not None:
1641-
log.warning(
1642-
"The `span_context` parameter is deprecated and will be removed in the next major version of "
1643-
"ddtrace (4.0). Please use `span` or `span_with_tag_value` instead."
1644-
)
1645-
span = span or span_context
1646-
16471599
if cls.enabled is False:
16481600
log.debug(
16491601
"LLMObs.submit_evaluation() called when LLMObs is not enabled. ",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
upgrade:
2+
- |
3+
LLM Observability: ``LLMObs.submit_evaluation_for()`` has been removed. Please use ``LLMObs.submit_evaluation()`` instead for submitting evaluations.
4+
To migrate:
5+
- ``LLMObs.submit_evaluation_for(...)`` users: rename to ``LLMObs.submit_evaluation(...)``
6+
- ``LLMObs.submit_evaluation_for(...)`` users: rename the ``span_context`` argument to ``span``, i.e.
7+
``LLMObs.submit_evaluation(span_context={"span_id": ..., "trace_id": ...}, ...)`` to ``LLMObs.submit_evaluation(span={"span_id": ..., "trace_id": ...}, ...)``

tests/llmobs/test_llmobs_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,8 +1930,8 @@ def test_submit_evaluation_invalid_reasoning_raises_warning(llmobs, mock_llmobs_
19301930
mock_llmobs_logs.warning.assert_called_once_with("Failed to parse reasoning. reasoning must be a string.")
19311931

19321932

1933-
def test_submit_evaluation_for_enqueues_writer_with_reasoning(llmobs, mock_llmobs_eval_metric_writer):
1934-
llmobs.submit_evaluation_for(
1933+
def test_submit_evaluation_enqueues_writer_with_reasoning(llmobs, mock_llmobs_eval_metric_writer):
1934+
llmobs.submit_evaluation(
19351935
span={"span_id": "123", "trace_id": "456"},
19361936
label="toxicity",
19371937
metric_type="categorical",
@@ -1955,7 +1955,7 @@ def test_submit_evaluation_for_enqueues_writer_with_reasoning(llmobs, mock_llmob
19551955
)
19561956
)
19571957
mock_llmobs_eval_metric_writer.reset()
1958-
llmobs.submit_evaluation_for(
1958+
llmobs.submit_evaluation(
19591959
span={"span_id": "123", "trace_id": "456"},
19601960
label="toxicity",
19611961
metric_type="categorical",

0 commit comments

Comments
 (0)