Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,14 @@ jobs:

- name: Lint
run: make lint

version:
name: make version-check
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

# No Python setup: the script only needs the image's python3.
- name: Check versions match VERSION
run: make version-check
41 changes: 41 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Docs

on:
pull_request:
paths:
- docs/**
- .github/workflows/docs.yml

permissions:
contents: read

jobs:
lint:
name: docs lint
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
working-directory: docs
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

# Uses the pnpm version in docs/package.json's packageManager field.
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
with:
package_json_file: docs/package.json

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
cache: pnpm
cache-dependency-path: docs/pnpm-lock.yaml

- name: Install
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm lint

- name: Typecheck
run: pnpm typecheck
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PYTHON ?= python3
MANIFEST := core/Cargo.toml

.DEFAULT_GOAL := help
.PHONY: help build install test lint generate generate-check
.PHONY: help build install test lint generate generate-check version version-check

help: ## list the targets
@awk -F ':.*## ' '/^[a-z-]+:.*## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
Expand All @@ -25,3 +25,9 @@ generate: ## regenerate protocol.schema.json and the Python SDK's protocol.py

generate-check: ## fail if a generated file is out of date
$(PYTHON) scripts/generate.py --check

version: ## copy the version in VERSION into the CLI and SDKs
$(PYTHON) scripts/version.py

version-check: ## fail if the CLI or an SDK doesn't match VERSION
$(PYTHON) scripts/version.py --check
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
3 changes: 3 additions & 0 deletions core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ make test # unit and end-to-end tests
make lint # clippy, failing on any warning
make generate # regenerate the files derived from src/schema/
make generate-check # fail if a generated file is out of date
make version # copy the version in VERSION into the CLI and SDKs
make version-check # fail if the CLI or an SDK doesn't match VERSION
```

`cargo run` builds and runs the CLI in one step, and the example project makes a handy target:
Expand All @@ -139,6 +141,7 @@ Unit tests sit next to the code they test. The end-to-end tests in `tests/cli.rs

- **New flag or command** - define it in `src/cli/args.rs` (shared flags go in `flags.rs`), route it in `dispatch.rs` and implement it in `src/commands/`.
- **New config key** - add it to `eac_yml.rs` or `dataset_yml.rs` in `src/eac/config/` and check it in that module's `impl Loader`, so mistakes fail before anything runs. Then document it below.
- **New version** - change `VERSION` at the repo root and run `make version`, which updates `Cargo.toml`, `Cargo.lock` and each SDK's version. CI's `make version-check` fails if they drift. `eac --version` prints it.
- **Protocol change** - edit the types in `src/schema/` and run `make generate` (needs Python 3.9+), which rewrites `protocol.schema.json` and the Python SDK's `protocol.py`. Then update [PROTOCOL.md](PROTOCOL.md), the Python SDK and the stand-in worker in `tests/fixtures/project`.

## Reference
Expand Down
1 change: 1 addition & 0 deletions core/src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::schema::Object;
#[derive(Parser)]
#[command(
name = "eac",
version,
about = "Run evals defined in code",
after_help = "exit codes: 0 all passed, 1 failures or errors, 2 eac itself failed"
)]
Expand Down
5 changes: 5 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
.next/
out/
next-env.d.ts
*.tsbuildinfo
58 changes: 58 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# docs

eac docs - a Next.js app with pages written in MDX and styled with [`@sentry/scraps`](https://www.npmjs.com/package/@sentry/scraps).

```sh
pnpm install
pnpm dev # http://localhost:3000
pnpm build
pnpm lint # ESLint, failing on any warning
pnpm typecheck # TypeScript
```

CI runs `pnpm lint` and `pnpm typecheck` on pull requests that change
`docs/` (`.github/workflows/docs.yml`).

## Adding a page

1. Create `app/<slug>/page.mdx`, starting with `export const metadata = {title: '...'}`.
2. Add it to the sidebar in `components/nav.ts`.

## Languages

The dropdown at the top of the sidebar picks the SDK language, and pages show code for that language. The list lives in `components/languages.ts`. To add one:

1. Add it to `LANGUAGES`, with the code fence names that count as it.
2. Add its version of each sample next to the existing ones:

````mdx
<LanguageCode>

```python
...
```

```typescript
...
```

</LanguageCode>
````

`<LanguageCode>` shows the sample whose label matches the selected language. For a sample whose label doesn't say the language, like a shell command, wrap it in `<ForLanguage lang="...">` or give its `<CodeFile>` a `lang`. When a language has no sample yet, the first one shows with a note.

`<ForLanguage lang="python">` also works on its own, for examples that only apply to some languages.

## Light and dark

The switcher in the header toggles Scraps' `lightTheme` and `darkTheme`
(`components/themeContext.tsx`). Until a reader picks one, the site follows
their OS. The choice is kept in a cookie that `app/layout.tsx` reads, so the
server renders the right theme and there's no flash of the wrong one. Reading
the cookie makes pages render per request rather than at build time.

## Version

The version in the header comes from `VERSION` at the repo root, which
`next.config.ts` reads at build time. Run `make version` from the root after
changing it, so the CLI and SDKs match.
79 changes: 79 additions & 0 deletions docs/app/cases-and-runners/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
export const metadata = {title: 'Cases and runners'};

# Cases and runners

A **case** is one input to test. A **runner** takes a case, calls your system, and returns whatever it got back.

## Cases

<LanguageCode>

```python
from eac import Case
from eac.judges import Contains, Equals

CASES = [
Case(
name="greets",
input={"query": "hi"},
expected_output={"response": "hello"},
judges=[Contains(["hello"]), Equals()],
splits=["smoke"],
),
]
```

</LanguageCode>

A few other options you might want:

- `seeds=[...]` for fixtures the case needs. See [Seeds](/seeds).
- `enabled=False` to skip a case unless you ask for it by name.
- `splits` to group cases, then run a group with `--split smoke`.

<ForLanguage lang="python">

Prefer keeping cases in data files? `from_jsonl("cases/*.jsonl", judges=[...])` loads one case per line.

</ForLanguage>

## Runners

<LanguageCode>

```python
from eac import OfflineRunner

class ChatRunner(OfflineRunner):
def execute(self, case, ctx):
reply = my_chatbot(case.input["query"], tag=ctx.conversation_id)
return {"response": reply}
```

</LanguageCode>

Return plain JSON and leave the scoring to your judges. The `ctx` gives you:

- `ctx.seed("name")` to get a fixture.
- `ctx.args` for anything passed with `--args`.
- `ctx.conversation_id` to tag your agent's run, so judges can find its trace later.

<Callout type="tip">
Runners, judges and seeds can be sync or async. Use whichever fits your code.
</Callout>

## Comparing variants

Want to compare two models or agents on the same cases? Add a comparison to `dataset.yml`:

```yaml
offline:
comparisons:
- name: models
arms:
- name: small
- name: big
args: {model: big}
```

Then run `eac offline compare models`. Each arm gets its own run, and they share fixtures.
51 changes: 51 additions & 0 deletions docs/app/cli/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
export const metadata = {title: 'CLI'};

# CLI

Run `eac --help` any time for the full list.

## Commands

<Table
columns={['Command', 'What it does']}
widths={[240, 'auto']}
rows={[
['`eac list`', 'Show the datasets and cases eac found.'],
['`eac offline run`', 'Seed, collect and judge in one go.'],
['`eac offline seed`', 'Set up fixtures and start a new run.'],
['`eac offline collect`', 'Run your system on each case.'],
['`eac offline judge`', 'Score the outputs.'],
['`eac offline compare NAME`', 'Run a comparison, one run per arm.'],
['`eac offline prune`', "Clean up cached fixtures nothing uses."],
['`eac online run`', 'Fetch production records and judge them.'],
['`eac online collect`', 'Fetch production records into a new run.'],
['`eac online judge`', 'Judge a collected run.'],
['`eac auth`', 'Log in to every credential your datasets need.'],
['`eac catalog`', 'Print every dataset, case and split as JSON.'],
]}
/>

## Common flags

<Table
columns={['Flag', 'What it does']}
widths={[240, 'auto']}
rows={[
['`--dataset NAME`', 'Only run this dataset.'],
['`--case NAME`', 'Only run this case.'],
['`--split NAME`', 'Only run cases in this split.'],
['`--args JSON`', 'Pass args to your runner.'],
['`--judge-args JSON`', 'Pass args to your judges, keyed by judge name.'],
['`--run ID`', 'Which run to use. Defaults to `latest`.'],
['`--concurrency N`', 'How many cases to run at once.'],
['`--judge NAME`', 'Online: which judge to score with.'],
['`--since 24h`', 'Online: how far back to fetch. Defaults to 1h.'],
['`-C DIR`', 'Run as if from another directory.'],
]}
/>

`--dataset`, `--case`, `--split` and `--judge` can be repeated.

## Exit codes

`0` means everything passed, `1` means a case failed, and `2` means eac itself hit a problem.
37 changes: 37 additions & 0 deletions docs/app/concepts/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export const metadata = {title: 'How eac works'};

# How eac works

## Projects and datasets

A **project** is any folder with an `eac.yml` in it. A **dataset** is a `dataset.yml` and the code next to it. eac finds every dataset under the project root on its own, so adding one never means editing shared config.

## Workers

The CLI doesn't run your code itself. Instead, it starts a **worker** process for your language and sends it work over a small JSON protocol. That's what lets eac support more than one language.

Workers handle one thing at a time, so you never have to think about thread safety. To run cases in parallel, set `concurrency` and eac starts more workers.

## Runs

Every run gets its own folder, and each phase reads the previous phase's output from there. So you can:

- Seed in one CI job and collect in another.
- Re-judge an old run after tweaking a judge.
- Point your own scripts at the folder to upload results.

An offline run has three phases:

<PhaseFlow
phases={[
{title: 'Seed', command: 'eac offline seed', description: 'Pick the cases and set up their fixtures.', writes: 'seeds.json'},
{title: 'Collect', command: 'eac offline collect', description: 'Call your runner on each case.', writes: 'outputs/'},
{title: 'Judge', command: 'eac offline judge', description: 'Score each output and write a summary.', writes: 'scores/, summary.json'},
]}
/>

`eac offline run` does all three in one go. Online runs skip seeding: they **collect** records from production and **judge** them.

## Passing and failing

A case passes when every judge gives it a 1. Anything lower is a failure, and if your runner throws, the case errors. Online runs just report average scores, so they never fail.
43 changes: 43 additions & 0 deletions docs/app/configuration/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export const metadata = {title: 'Configuration'};

# Configuration

## eac.yml

This file marks your project's root. Every key is optional, so an empty file works fine.

```yaml
artifacts: .eac # where runs are saved
exclude: [legacy_evals] # folders to skip when looking for datasets

runtimes:
python:
command: [uv, run, python]
env: {PYTHONPATH: src}

online:
judges: # judges every online dataset can use
- {name: polite, path: "evals.judges:Polite"}
```

If you don't set a Python command, eac uses your active virtualenv, then the nearest `.venv`, then `uv run python` if there's a `uv.lock`, then `python3`. It also loads a `.env` file next to `eac.yml`.

## dataset.yml

```yaml
name: chat # lowercase, digits and underscores
runtime: python
agent: chat_agent # optional, used to look up traces

offline:
runner: ./dataset.py:ChatRunner
cases: ./dataset.py:CASES
concurrency: 4 # optional, defaults to 1

online:
runner: ./dataset.py:ProdChats
judges:
- {name: polite, path: ./judges.py:Polite}
```

A dataset needs `offline`, `online`, or both. Code can be referenced as `./file.py:name` (relative to the YAML file) or `module.path:name`.
Loading
Loading