Skip to content

Commit f4c4912

Browse files
OgeonX-AiAitomatesclaude
authored
perf(evaluate): optimize reference product evaluation with concurrency (#4)
* perf(evaluate): optimize reference product evaluation with concurrency * chore(ci): ignore Playwright artifacts; track UI test lockfile Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Kim Harjamäki <kim.harjamaki@prosimo.fi> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a9563f7 commit f4c4912

3 files changed

Lines changed: 114 additions & 11 deletions

File tree

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ dist/
55
build/
66
*.egg-info/
77
artifacts/
8+
9+
# Node / Playwright UI test artifacts (tests/ui)
10+
node_modules/
11+
playwright-report/
12+
test-results/
13+
.playwright/

src/cas_evals/reference_product.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import concurrent.futures
56
import hashlib
67
import json
78
from collections.abc import Callable
@@ -122,9 +123,8 @@ def evaluate_reference_suite(
122123
suite = json.loads(fixture_path.read_text(encoding="utf-8"))
123124
released_at = suite.get("releasedAt", DEFAULT_RELEASED_AT)
124125
invoke = transport or _http_transport(endpoint, timeout_seconds)
125-
evaluated = []
126126

127-
for source_case in suite["cases"]:
127+
def process_case(source_case: dict[str, Any]) -> tuple[dict[str, Any], dict[str, Any]]:
128128
envelope = _build_envelope(source_case, suite["suiteId"], released_at)
129129
output, events = _validate_response(invoke(envelope), envelope)
130130
live_case = {**source_case, "response": output}
@@ -142,17 +142,18 @@ def evaluate_reference_suite(
142142
"normalization": "fixture-observed",
143143
},
144144
}
145-
evaluated.append(
146-
_evaluate_case_with_evidence(
147-
live_case,
148-
suite["suiteId"],
149-
released_at,
150-
source_case=source_case,
151-
metadata=envelope,
152-
execution_evidence=evidence,
153-
)
145+
return _evaluate_case_with_evidence(
146+
live_case,
147+
suite["suiteId"],
148+
released_at,
149+
source_case=source_case,
150+
metadata=envelope,
151+
execution_evidence=evidence,
154152
)
155153

154+
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
155+
evaluated = list(executor.map(process_case, suite["cases"]))
156+
156157
results = [result for result, _ in evaluated]
157158
return {
158159
"schemaVersion": "0.2.0",

tests/ui/package-lock.json

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)