Skip to content

Commit dfe4122

Browse files
committed
reformat
1 parent 6bd11f0 commit dfe4122

4 files changed

Lines changed: 47 additions & 49 deletions

File tree

deepeval/synthesizer/synthesizer.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ def _build_contexts_with_sources(
167167
contexts_with_sources: List[ContextWithSources] = []
168168
for idx, context in enumerate(contexts):
169169
source_file = source_files[idx] if idx < len(source_files) else None
170-
score = context_scores[idx] if context_scores and idx < len(context_scores) else None
170+
score = (
171+
context_scores[idx]
172+
if context_scores and idx < len(context_scores)
173+
else None
174+
)
171175
contexts_with_sources.append(
172176
ContextWithSources(
173177
context=context,
@@ -199,9 +203,7 @@ def _validate_merge_request(
199203
"`target_files_per_context` must be at least 2 when provided."
200204
)
201205
if max_files_per_context < 2:
202-
raise ValueError(
203-
"`max_files_per_context` must be at least 2."
204-
)
206+
raise ValueError("`max_files_per_context` must be at least 2.")
205207
if len(contexts_with_sources) < 2:
206208
return False
207209
distinct_files = {
@@ -219,7 +221,9 @@ def _merge_cross_file_contexts(
219221
max_files_per_context: int = 3,
220222
) -> List[ContextWithSources]:
221223
if not self._validate_merge_request(
222-
contexts_with_sources, target_files_per_context, max_files_per_context
224+
contexts_with_sources,
225+
target_files_per_context,
226+
max_files_per_context,
223227
):
224228
return contexts_with_sources
225229
context_texts = [
@@ -241,7 +245,9 @@ async def _a_merge_cross_file_contexts(
241245
max_files_per_context: int = 3,
242246
) -> List[ContextWithSources]:
243247
if not self._validate_merge_request(
244-
contexts_with_sources, target_files_per_context, max_files_per_context
248+
contexts_with_sources,
249+
target_files_per_context,
250+
max_files_per_context,
245251
):
246252
return contexts_with_sources
247253
context_texts = [
@@ -793,9 +799,8 @@ def generate_goldens_from_contexts(
793799
qualified_synthetic_inputs
794800
):
795801
context_source_files: List[str] = []
796-
if (
797-
source_files is not None
798-
and context_index < len(source_files)
802+
if source_files is not None and context_index < len(
803+
source_files
799804
):
800805
context_source = source_files[context_index]
801806
if isinstance(context_source, list):
@@ -1109,9 +1114,7 @@ async def process_input(
11091114
context=context,
11101115
expected_output=expected_output,
11111116
source_file=(
1112-
context_source_files[0]
1113-
if context_source_files
1114-
else None
1117+
context_source_files[0] if context_source_files else None
11151118
),
11161119
additional_metadata={
11171120
"evolutions": evolutions_used,
@@ -2257,27 +2260,25 @@ async def a_generate_conversational_goldens_from_docs(
22572260
)
22582261

22592262
# Generate conversational goldens from contexts
2260-
goldens = (
2261-
await self.a_generate_conversational_goldens_from_contexts(
2262-
contexts=[item.context for item in contexts_with_sources],
2263-
include_expected_outcome=include_expected_outcome,
2264-
max_goldens_per_context=max_goldens_per_context,
2265-
source_files=[
2266-
item.source_files for item in contexts_with_sources
2267-
],
2268-
context_chunk_source_files=[
2269-
item.chunk_source_files or []
2270-
for item in contexts_with_sources
2271-
],
2272-
target_files_per_context=context_construction_config.target_files_per_context,
2273-
_context_scores=[
2274-
item.score if item.score is not None else 0.0
2275-
for item in contexts_with_sources
2276-
],
2277-
_progress=progress,
2278-
_pbar_id=pbar_id,
2279-
_reset_cost=False,
2280-
)
2263+
goldens = await self.a_generate_conversational_goldens_from_contexts(
2264+
contexts=[item.context for item in contexts_with_sources],
2265+
include_expected_outcome=include_expected_outcome,
2266+
max_goldens_per_context=max_goldens_per_context,
2267+
source_files=[
2268+
item.source_files for item in contexts_with_sources
2269+
],
2270+
context_chunk_source_files=[
2271+
item.chunk_source_files or []
2272+
for item in contexts_with_sources
2273+
],
2274+
target_files_per_context=context_construction_config.target_files_per_context,
2275+
_context_scores=[
2276+
item.score if item.score is not None else 0.0
2277+
for item in contexts_with_sources
2278+
],
2279+
_progress=progress,
2280+
_pbar_id=pbar_id,
2281+
_reset_cost=False,
22812282
)
22822283
if _reset_cost and self.cost_tracking and self.using_native_model:
22832284
print(f"💰 API cost: {self.synthesis_cost:.6f}")
@@ -2434,9 +2435,8 @@ def generate_conversational_goldens_from_contexts(
24342435
qualified_synthetic_scenarios
24352436
):
24362437
context_source_files: List[str] = []
2437-
if (
2438-
source_files is not None
2439-
and context_index < len(source_files)
2438+
if source_files is not None and context_index < len(
2439+
source_files
24402440
):
24412441
context_source = source_files[context_index]
24422442
if isinstance(context_source, list):

test_agentcore_agent.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from pathlib import Path
2626

2727
import pytest
28+
2829
# from strands import Agent
2930

3031
from deepeval import assert_test
@@ -63,6 +64,7 @@ async def run_agent(prompt: str) -> str:
6364
"""
6465
return "output"
6566

67+
6668
dataset = EvaluationDataset()
6769
dataset.pull(alias="Single Turn QA")
6870

tests/test_core/test_synthesizer_bugs.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,7 @@ def test_format_context_no_sources_returns_context(self):
271271
synth = _make_synthesizer()
272272
context = ["only chunk"]
273273

274-
assert (
275-
synth._format_context_with_sources(context, None) == context
276-
)
274+
assert synth._format_context_with_sources(context, None) == context
277275
# Mismatched lengths fall back to the raw context.
278276
assert (
279277
synth._format_context_with_sources(context, ["a", "b"]) == context
@@ -399,9 +397,7 @@ def test_merge_noop_for_single_context(self):
399397
synth = _make_synthesizer()
400398
built = self._build(synth, ["a.txt"])
401399

402-
merged = synth._merge_cross_file_contexts(
403-
built, self._fake_embedder()
404-
)
400+
merged = synth._merge_cross_file_contexts(built, self._fake_embedder())
405401

406402
assert merged == built
407403

@@ -436,9 +432,8 @@ def test_merge_passes_through_unlabeled_contexts(self):
436432

437433
# Every merged context keeps chunk labels aligned (or has none).
438434
for m in merged:
439-
assert (
440-
not m.chunk_source_files
441-
or len(m.chunk_source_files) == len(m.context)
435+
assert not m.chunk_source_files or len(m.chunk_source_files) == len(
436+
m.context
442437
)
443438
# The unlabeled chunk survives untouched in exactly one context.
444439
assert any("unlabeled chunk" in m.context for m in merged)
@@ -589,9 +584,7 @@ async def test_async_rewrite_keeps_used_source_files(self):
589584
used_source_files=["a.txt", "b.txt"],
590585
)
591586
]
592-
filtered, scores = await synth._a_rewrite_scenarios(
593-
["ctx"], scenarios
594-
)
587+
filtered, scores = await synth._a_rewrite_scenarios(["ctx"], scenarios)
595588

596589
assert filtered[0].used_source_files == ["a.txt", "b.txt"]
597590
assert scores == [1.0]

tests/test_core/test_tracing/test_integration/test_dataset_iterator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import os
33
import pytest
44

5-
if os.getenv("OPENAI_API_KEY") is None or not os.getenv("OPENAI_API_KEY").strip():
5+
if (
6+
os.getenv("OPENAI_API_KEY") is None
7+
or not os.getenv("OPENAI_API_KEY").strip()
8+
):
69
pytest.skip("needs OPENAI_API_KEY", allow_module_level=True)
710

811

0 commit comments

Comments
 (0)