Skip to content

Commit 4beeccc

Browse files
authoredJan 10, 2025
chore(llmobs): fix tests to be less noisy locally (#11890)
These tests rely on env vars that may already be present on dev envs and will result in noisy errors as a result. ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
1 parent 1b223aa commit 4beeccc

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed
 

‎tests/llmobs/test_llmobs_evaluator_runner.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,7 @@ def test_evaluator_runner_on_exit(mock_writer_logs, run_python_code_in_subproces
6464
pypath = [os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))]
6565
if "PYTHONPATH" in env:
6666
pypath.append(env["PYTHONPATH"])
67-
env.update(
68-
{
69-
"DD_API_KEY": os.getenv("DD_API_KEY", "dummy-api-key"),
70-
"DD_SITE": "datad0g.com",
71-
"PYTHONPATH": ":".join(pypath),
72-
"DD_LLMOBS_ML_APP": "unnamed-ml-app",
73-
"_DD_LLMOBS_EVALUATOR_INTERVAL": "5",
74-
}
75-
)
67+
env.update({"PYTHONPATH": ":".join(pypath), "_DD_LLMOBS_EVALUATOR_INTERVAL": "5"})
7668
out, err, status, pid = run_python_code_in_subprocess(
7769
"""
7870
import os
@@ -87,7 +79,7 @@ def test_evaluator_runner_on_exit(mock_writer_logs, run_python_code_in_subproces
8779
ctx = logs_vcr.use_cassette("tests.llmobs.test_llmobs_evaluator_runner.send_score_metric.yaml")
8880
ctx.__enter__()
8981
atexit.register(lambda: ctx.__exit__())
90-
LLMObs.enable()
82+
LLMObs.enable(api_key="dummy-api-key", site="datad0g.com", ml_app="unnamed-ml-app")
9183
LLMObs._instance._evaluator_runner.evaluators.append(DummyEvaluator(llmobs_service=LLMObs))
9284
LLMObs._instance._evaluator_runner.start()
9385
LLMObs._instance._evaluator_runner.enqueue({"span_id": "123", "trace_id": "1234"}, None)

‎tests/llmobs/test_llmobs_ragas_evaluators.py

+3-12
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,11 @@ def test_llmobs_with_faithfulness_emits_traces_and_evals_on_exit(mock_writer_log
206206
pypath.append(env["PYTHONPATH"])
207207
env.update(
208208
{
209-
"DD_API_KEY": os.getenv("DD_API_KEY", "dummy-api-key"),
210-
"DD_SITE": "datad0g.com",
211209
"PYTHONPATH": ":".join(pypath),
212210
"OPENAI_API_KEY": os.getenv("OPENAI_API_KEY", "dummy-openai-api-key"),
213-
"DD_LLMOBS_ML_APP": "unnamed-ml-app",
214211
"_DD_LLMOBS_EVALUATOR_INTERVAL": "5",
215212
"_DD_LLMOBS_EVALUATORS": "ragas_faithfulness",
216-
"DD_LLMOBS_AGENTLESS_ENABLED": "1",
213+
"DD_TRACE_ENABLED": "0",
217214
}
218215
)
219216
out, err, status, pid = run_python_code_in_subprocess(
@@ -232,14 +229,8 @@ def test_llmobs_with_faithfulness_emits_traces_and_evals_on_exit(mock_writer_log
232229
)
233230
ctx.__enter__()
234231
atexit.register(lambda: ctx.__exit__())
235-
with mock.patch(
236-
"ddtrace.internal.writer.HTTPWriter._send_payload",
237-
return_value=Response(
238-
status=200,
239-
body="{}",
240-
),
241-
):
242-
LLMObs.enable()
232+
with mock.patch("ddtrace.internal.writer.HTTPWriter._send_payload", return_value=Response(status=200, body="{}")):
233+
LLMObs.enable(api_key="dummy-api-key", site="datad0g.com", ml_app="unnamed-ml-app", agentless_enabled=True)
243234
LLMObs._instance._evaluator_runner.enqueue(_llm_span_with_expected_ragas_inputs_in_messages(), None)
244235
""",
245236
env=env,

0 commit comments

Comments
 (0)