codeflash-agent/evals/templates/ranking/tests/test_pipeline.py
Kevin Turcios 33faedf427
Add Unstructured report, rewrite statusline, format evals/scripts (#20)
* Add Unstructured engagement report as uv workspace member

Three-tier Plotly Dash app (Executive Brief, Engineering Team, Full
Detail) with data in JSON, theme constants in theme.py, and Dash
production improvements (Google Fonts, clientside callbacks, meta tags).

Also: add .playwright-mcp/ to .gitignore, add reports/* ruff overrides,
remove tracked .codeflash/observability/read-tracker.

* Rewrite statusline to derive context from git state

Detects active area from changed files (reports, packages, plugin,
.codeflash, case-studies, evals), falls back to branch name convention
(perf/*, feat/*, fix/*), shows dirty indicator. Uses whoami for
cross-platform user detection.

* Add pre-push lint rule to commit guidelines

* Exclude .codeflash/ from ruff linting

Benchmark and profiling scripts in .codeflash/ are scratch work, not
package source. Excluding them prevents CI failures from ad-hoc scripts.

* Run ruff format across packages, scripts, evals, and plugin refs

* Fix github-app async test failures in CI

Add asyncio_mode = "auto" to root pytest config so async tests
are detected when running from the repo root via uv run pytest packages/.
2026-04-15 03:06:16 -05:00

49 lines
1.6 KiB
Python

from pipeline.core import run_pipeline
def test_basic():
config = {
"required_fields": ["id", "value", "category"],
"blocked_ids": [999],
}
records = [
{"id": 1, "value": "hello world", "category": "a", "base_score": 1.0},
{"id": 2, "value": "foo", "category": "a", "base_score": 2.0},
{"id": 999, "value": "blocked", "category": "b", "base_score": 1.0},
{
"id": 3,
"value": "bar",
"category": "b",
}, # missing base_score is ok (defaults to 1.0)
{"value": "no id"}, # missing required field
]
result = run_pipeline(records, config)
assert len(result) == 3
# blocked and missing-id records filtered
assert all(r["id"] != 999 for r in result)
def test_large_batch():
"""Production batch — run_pipeline is too slow on 5k records."""
config = {
"required_fields": ["id", "value", "category", "source"],
"blocked_ids": list(range(9000, 9100)), # 100 blocked IDs
}
categories = [f"cat-{i}" for i in range(20)]
sources = [f"source-{i}" for i in range(10)]
records = []
for i in range(5_000):
records.append(
{
"id": i,
"value": f"record value {i} with extra spaces",
"category": categories[i % len(categories)],
"source": sources[i % len(sources)],
"base_score": float(i % 100) / 10,
}
)
result = run_pipeline(records, config)
assert (
len(result) == 5_000
) # none blocked (IDs 0-4999, blocklist 9000-9099)
assert all("score" in r for r in result)