reeval-python 0.30.1__tar.gz → 0.33.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- reeval_python-0.33.0/PKG-INFO +140 -0
- reeval_python-0.33.0/README.md +116 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/pyproject.toml +1 -1
- {reeval_python-0.30.1 → reeval_python-0.33.0}/src/reeval_python/__init__.py +24 -12
- {reeval_python-0.30.1 → reeval_python-0.33.0}/src/reeval_python/_wire.py +859 -915
- reeval_python-0.33.0/src/reeval_python/binaries.json +55 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/src/reeval_python/cli.py +1 -1
- reeval_python-0.33.0/src/reeval_python/context.py +424 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/src/reeval_python/declare.py +72 -80
- {reeval_python-0.30.1 → reeval_python-0.33.0}/src/reeval_python/environment.py +1 -1
- reeval_python-0.33.0/src/reeval_python/errors.py +46 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/src/reeval_python/options.py +34 -55
- {reeval_python-0.30.1 → reeval_python-0.33.0}/src/reeval_python/runner.py +85 -91
- reeval_python-0.33.0/src/reeval_python/target.py +18 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/src/reeval_python/types.py +34 -25
- reeval_python-0.33.0/src/reeval_python/wire.py +96 -0
- reeval_python-0.33.0/tests/context/decide.eval.py +14 -0
- reeval_python-0.33.0/tests/context/decide.sync.eval.py +14 -0
- reeval_python-0.33.0/tests/context/exec-env.eval.py +11 -0
- reeval_python-0.33.0/tests/context/exec-env.sync.eval.py +11 -0
- reeval_python-0.33.0/tests/context/sync-async.async.eval.py +6 -0
- reeval_python-0.33.0/tests/context/sync-async.eval.py +6 -0
- reeval_python-0.33.0/tests/declare/best-of.eval.py +24 -0
- reeval_python-0.33.0/tests/declare/builtin-graders.eval.py +24 -0
- reeval_python-0.33.0/tests/declare/cases.eval.py +32 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/declare/compare-questions.eval.py +7 -14
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/declare/compare-variants.eval.py +7 -4
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/declare/egress-cascade.eval.py +8 -8
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/declare/environment-extend.eval.py +3 -3
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/declare/environment-plugin-marketplace.eval.py +2 -2
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/declare/environment-plugins.eval.py +3 -3
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/declare/environment-traits.eval.py +1 -1
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/declare/questions-group.eval.py +7 -9
- reeval_python-0.33.0/tests/declare/questions-trials.eval.py +45 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/declare/revision.eval.py +2 -2
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/declare/tags.eval.py +1 -1
- reeval_python-0.33.0/tests/declare/targets.eval.py +46 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/runner_process.py +2 -2
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/stdio_host.py +3 -24
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_api.py +68 -90
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_conformance_context.py +3 -18
- reeval_python-0.33.0/tests/test_decision.py +17 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_load.py +3 -3
- reeval_python-0.30.1/tests/test_runner_checks.py → reeval_python-0.33.0/tests/test_runner_asserts.py +20 -69
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_runner_isolation.py +2 -2
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_runner_json.py +14 -20
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_runner_misuse.py +9 -71
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_runner_sdk.py +8 -69
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_runner_stdio.py +1 -1
- reeval_python-0.33.0/tests/test_runner_trials.py +151 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_source.py +5 -5
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_types.py +33 -32
- {reeval_python-0.30.1 → reeval_python-0.33.0}/uv.lock +1 -1
- reeval_python-0.30.1/PKG-INFO +0 -226
- reeval_python-0.30.1/README.md +0 -202
- reeval_python-0.30.1/src/reeval_python/aio.py +0 -14
- reeval_python-0.30.1/src/reeval_python/binaries.json +0 -55
- reeval_python-0.30.1/src/reeval_python/checks.py +0 -284
- reeval_python-0.30.1/src/reeval_python/context.py +0 -497
- reeval_python-0.30.1/src/reeval_python/errors.py +0 -26
- reeval_python-0.30.1/src/reeval_python/expect.py +0 -354
- reeval_python-0.30.1/src/reeval_python/wire.py +0 -180
- reeval_python-0.30.1/tests/context/exec-env.eval.py +0 -11
- reeval_python-0.30.1/tests/context/exec-env.sync.eval.py +0 -11
- reeval_python-0.30.1/tests/context/expect-fail.eval.py +0 -12
- reeval_python-0.30.1/tests/context/expect-fail.sync.eval.py +0 -11
- reeval_python-0.30.1/tests/context/expect.eval.py +0 -17
- reeval_python-0.30.1/tests/context/expect.sync.eval.py +0 -15
- reeval_python-0.30.1/tests/context/judge.eval.py +0 -14
- reeval_python-0.30.1/tests/context/judge.sync.eval.py +0 -10
- reeval_python-0.30.1/tests/context/record.async.eval.py +0 -14
- reeval_python-0.30.1/tests/context/record.eval.py +0 -14
- reeval_python-0.30.1/tests/context/stay-within.eval.py +0 -9
- reeval_python-0.30.1/tests/context/sync-async.async.eval.py +0 -7
- reeval_python-0.30.1/tests/context/sync-async.eval.py +0 -6
- reeval_python-0.30.1/tests/declare/best-of.eval.py +0 -24
- reeval_python-0.30.1/tests/declare/cases.eval.py +0 -29
- reeval_python-0.30.1/tests/declare/observe.eval.py +0 -26
- reeval_python-0.30.1/tests/declare/questions-attempts.eval.py +0 -56
- reeval_python-0.30.1/tests/declare/questions-state.eval.py +0 -85
- reeval_python-0.30.1/tests/test_checks.py +0 -314
- reeval_python-0.30.1/tests/test_patterns.py +0 -178
- reeval_python-0.30.1/tests/test_runner_attempts.py +0 -186
- {reeval_python-0.30.1 → reeval_python-0.33.0}/.gitignore +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/CHANGELOG.md +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/LICENSE +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/package.json +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/src/reeval_python/__main__.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/src/reeval_python/py.typed +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/context/abort.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/context/abort.sync.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/context/exec-retries.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/context/exec-retries.sync.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/context/exec.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/context/exec.sync.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/context/files.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/context/files.sync.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/context/observe.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/context/observe.sync.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/context/send.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/context/send.sync.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/declare/groups-skip-todo.eval.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_cli.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_conformance_declare.py +0 -0
- {reeval_python-0.30.1 → reeval_python-0.33.0}/tests/test_python_wheels.py +0 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: reeval-python
|
|
3
|
+
Version: 0.33.0
|
|
4
|
+
Summary: Python authoring SDK for reeval (*.eval.py eval files)
|
|
5
|
+
Project-URL: Homepage, https://reeval.ai
|
|
6
|
+
Project-URL: Repository, https://github.com/reeval-ai/reeval
|
|
7
|
+
Project-URL: Documentation, https://github.com/reeval-ai/reeval/tree/main/packages/reeval-python#readme
|
|
8
|
+
Project-URL: Issues, https://github.com/reeval-ai/reeval/issues
|
|
9
|
+
Author-email: Invertase <oss@invertase.io>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Software Development :: Testing
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# reeval-python
|
|
26
|
+
|
|
27
|
+
Python authoring SDK for [reeval](https://github.com/reeval-ai/reeval). Write `*.eval.py` files,
|
|
28
|
+
declare evals with the same options as TypeScript, and run them through reeval's language runner
|
|
29
|
+
(over its stdin and stdout, runner protocol 3). Use the reeval-python version that matches your
|
|
30
|
+
reeval: each says which runner protocol it speaks, and refuses another.
|
|
31
|
+
|
|
32
|
+
Import as `reeval_python` (`from reeval_python import evaluate`). The PyPI distribution is
|
|
33
|
+
**reeval-python** (the name `reeval` is already taken on PyPI by another project).
|
|
34
|
+
|
|
35
|
+
With reeval installed, default discovery includes `evals/**/*.eval.py`. When your project has
|
|
36
|
+
`pyproject.toml` or `uv.lock` and [uv](https://docs.astral.sh/uv/) is on `PATH`, reeval starts the
|
|
37
|
+
runner with `uv run --project <root> python -m reeval_python`. Otherwise it uses `<root>/.venv/bin/python`
|
|
38
|
+
when present, then `python3` (`python` on Windows). Set `REEVAL_PYTHON` to override the interpreter.
|
|
39
|
+
The standalone `reeval` binary works the same way and needs only uv besides; install the
|
|
40
|
+
reeval-python release made for your reeval, since a runner on another protocol stops the run.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uv add reeval-python
|
|
46
|
+
# or: pip install reeval-python
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Then `uv run reeval run`. reeval-python's `reeval` command runs the reeval binary of its own
|
|
50
|
+
version: the first run downloads it from the GitHub release, checks it against the sha256 this
|
|
51
|
+
release recorded, and caches it in `<cache>/reeval/bin/<version>/`.
|
|
52
|
+
|
|
53
|
+
Monorepo development:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
cd packages/reeval-python
|
|
57
|
+
uv sync --dev
|
|
58
|
+
uv run pytest
|
|
59
|
+
uv run ruff check .
|
|
60
|
+
uv run pyright
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Declare trees are checked against `packages/reeval/test/conformance/declare/` goldens. From the
|
|
64
|
+
reeval package, `test/python-sdk.test.ts` runs the same suite in CI.
|
|
65
|
+
|
|
66
|
+
## Writing evals
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from reeval_python import SyncTrialContext, evaluate
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@evaluate("lands", {"trials": 3, "timeout": 300})
|
|
73
|
+
def lands(c: SyncTrialContext) -> None:
|
|
74
|
+
c.send("Create greet.py that prints hi")
|
|
75
|
+
assert c.exec("python greet.py").stdout == "hi\n"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
A body is the task: it drives the agent and fails the trial by raising. Plain `assert` keeps
|
|
79
|
+
Python's semantics: a failure ends the body, and its message (or, with none, the statement as
|
|
80
|
+
written) is the trial's failure. An `AssertionError` the body catches fails nothing, so a retry
|
|
81
|
+
loop can assert. Raise `EvalError("the build fails")` for a trial that didn't get far enough to
|
|
82
|
+
grade. Use typed results (`ExecResult.ok`, `Turn.text`, …) and `c.file(path)`.
|
|
83
|
+
|
|
84
|
+
Use snake_case on the context (`read_file`, `write_file`, `file`). Options are typed
|
|
85
|
+
(`EvalOptions`), so pyright refuses a misspelled key such as `runz`. They take reeval's keys in
|
|
86
|
+
snake_case at any depth (`min_lift`, `delay_ms`); the keys of `env`, `headers` and the other maps of
|
|
87
|
+
your own keep their spelling. Every duration is seconds or a `timedelta`: `{"timeout": 90}`,
|
|
88
|
+
`docker(start_timeout=timedelta(minutes=2))`. `docker()`, `fake_harness()`, `fake_judge()` and
|
|
89
|
+
`plugin.*` return values to pass as options, not data to edit.
|
|
90
|
+
|
|
91
|
+
### `def` and `async def` bodies
|
|
92
|
+
|
|
93
|
+
A `def` body gets a blocking context: `c.exec(…)` runs the command and returns its `ExecResult`,
|
|
94
|
+
and `c.read_file(…)` returns the contents.
|
|
95
|
+
|
|
96
|
+
An `async def` body gets the async context: every `c.*` call is a coroutine to await. A call the
|
|
97
|
+
body never awaits never runs, so it fails the trial, and so does a task the body started and
|
|
98
|
+
left running when it returns: await each one (`asyncio.gather`, a `TaskGroup`). A body that
|
|
99
|
+
`yield`s is refused where it's declared.
|
|
100
|
+
|
|
101
|
+
Annotate `c` (`SyncTrialContext` or `TrialContext`) and pyright checks the body too: a missing
|
|
102
|
+
`await`, the wrong context for the kind of body, a generator or a returned value. An unannotated
|
|
103
|
+
body is checked only when it runs.
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from reeval_python import TrialContext, evaluate
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@evaluate("lands, async")
|
|
110
|
+
async def lands(c: TrialContext) -> None:
|
|
111
|
+
await c.send("Create greet.py that prints hi")
|
|
112
|
+
assert (await c.exec("python greet.py")).ok
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`c.exec(cmd, retries=2, interval=2)` runs a command that exits non-zero again, up to 2 more
|
|
116
|
+
times, 2 seconds apart (`interval` is seconds or a timedelta, one second by default), and returns
|
|
117
|
+
the last try. Use it for a command that can fail on a transient, such as a test that calls a
|
|
118
|
+
model: `c.exec("pytest -q tests/hidden", retries=2)`. Any non-zero exit retries, and the record and
|
|
119
|
+
output say `passed on try 2 of 3`.
|
|
120
|
+
|
|
121
|
+
`c.exec(cmd, env={"EXPECTED": "42"})` sets variables for that command only, over the
|
|
122
|
+
environment's, in the background too. A value named like a secret (`*_TOKEN`, `*_KEY`, …) is
|
|
123
|
+
masked in everything reeval writes.
|
|
124
|
+
|
|
125
|
+
### Cases
|
|
126
|
+
|
|
127
|
+
`"cases"` runs one eval over a list, and the body takes the trial and its case. Each case is a
|
|
128
|
+
dict (a `Case`, `TypedDict` with `key`) or a dataclass with a `key`. A key is 1–80 characters with
|
|
129
|
+
no surrounding whitespace, `#`, `›` or control characters, and unique within the eval; the run reports each case as `<eval> [<key>]`.
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
@evaluate("greets", {"cases": [{"key": "en"}, {"key": "fr"}]})
|
|
133
|
+
def greets(c: SyncTrialContext, case: Case) -> None: ...
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Examples
|
|
137
|
+
|
|
138
|
+
- Feature smoke: `packages/reeval/test/features/python-sdk/hello/` (uv project with a project dependency)
|
|
139
|
+
- Plan case: `packages/reeval/test/plan/python/`
|
|
140
|
+
- Contributor guide: `.agents/skills/add-a-language/SKILL.md` in the reeval repo
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# reeval-python
|
|
2
|
+
|
|
3
|
+
Python authoring SDK for [reeval](https://github.com/reeval-ai/reeval). Write `*.eval.py` files,
|
|
4
|
+
declare evals with the same options as TypeScript, and run them through reeval's language runner
|
|
5
|
+
(over its stdin and stdout, runner protocol 3). Use the reeval-python version that matches your
|
|
6
|
+
reeval: each says which runner protocol it speaks, and refuses another.
|
|
7
|
+
|
|
8
|
+
Import as `reeval_python` (`from reeval_python import evaluate`). The PyPI distribution is
|
|
9
|
+
**reeval-python** (the name `reeval` is already taken on PyPI by another project).
|
|
10
|
+
|
|
11
|
+
With reeval installed, default discovery includes `evals/**/*.eval.py`. When your project has
|
|
12
|
+
`pyproject.toml` or `uv.lock` and [uv](https://docs.astral.sh/uv/) is on `PATH`, reeval starts the
|
|
13
|
+
runner with `uv run --project <root> python -m reeval_python`. Otherwise it uses `<root>/.venv/bin/python`
|
|
14
|
+
when present, then `python3` (`python` on Windows). Set `REEVAL_PYTHON` to override the interpreter.
|
|
15
|
+
The standalone `reeval` binary works the same way and needs only uv besides; install the
|
|
16
|
+
reeval-python release made for your reeval, since a runner on another protocol stops the run.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
uv add reeval-python
|
|
22
|
+
# or: pip install reeval-python
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Then `uv run reeval run`. reeval-python's `reeval` command runs the reeval binary of its own
|
|
26
|
+
version: the first run downloads it from the GitHub release, checks it against the sha256 this
|
|
27
|
+
release recorded, and caches it in `<cache>/reeval/bin/<version>/`.
|
|
28
|
+
|
|
29
|
+
Monorepo development:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
cd packages/reeval-python
|
|
33
|
+
uv sync --dev
|
|
34
|
+
uv run pytest
|
|
35
|
+
uv run ruff check .
|
|
36
|
+
uv run pyright
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Declare trees are checked against `packages/reeval/test/conformance/declare/` goldens. From the
|
|
40
|
+
reeval package, `test/python-sdk.test.ts` runs the same suite in CI.
|
|
41
|
+
|
|
42
|
+
## Writing evals
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from reeval_python import SyncTrialContext, evaluate
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@evaluate("lands", {"trials": 3, "timeout": 300})
|
|
49
|
+
def lands(c: SyncTrialContext) -> None:
|
|
50
|
+
c.send("Create greet.py that prints hi")
|
|
51
|
+
assert c.exec("python greet.py").stdout == "hi\n"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
A body is the task: it drives the agent and fails the trial by raising. Plain `assert` keeps
|
|
55
|
+
Python's semantics: a failure ends the body, and its message (or, with none, the statement as
|
|
56
|
+
written) is the trial's failure. An `AssertionError` the body catches fails nothing, so a retry
|
|
57
|
+
loop can assert. Raise `EvalError("the build fails")` for a trial that didn't get far enough to
|
|
58
|
+
grade. Use typed results (`ExecResult.ok`, `Turn.text`, …) and `c.file(path)`.
|
|
59
|
+
|
|
60
|
+
Use snake_case on the context (`read_file`, `write_file`, `file`). Options are typed
|
|
61
|
+
(`EvalOptions`), so pyright refuses a misspelled key such as `runz`. They take reeval's keys in
|
|
62
|
+
snake_case at any depth (`min_lift`, `delay_ms`); the keys of `env`, `headers` and the other maps of
|
|
63
|
+
your own keep their spelling. Every duration is seconds or a `timedelta`: `{"timeout": 90}`,
|
|
64
|
+
`docker(start_timeout=timedelta(minutes=2))`. `docker()`, `fake_harness()`, `fake_judge()` and
|
|
65
|
+
`plugin.*` return values to pass as options, not data to edit.
|
|
66
|
+
|
|
67
|
+
### `def` and `async def` bodies
|
|
68
|
+
|
|
69
|
+
A `def` body gets a blocking context: `c.exec(…)` runs the command and returns its `ExecResult`,
|
|
70
|
+
and `c.read_file(…)` returns the contents.
|
|
71
|
+
|
|
72
|
+
An `async def` body gets the async context: every `c.*` call is a coroutine to await. A call the
|
|
73
|
+
body never awaits never runs, so it fails the trial, and so does a task the body started and
|
|
74
|
+
left running when it returns: await each one (`asyncio.gather`, a `TaskGroup`). A body that
|
|
75
|
+
`yield`s is refused where it's declared.
|
|
76
|
+
|
|
77
|
+
Annotate `c` (`SyncTrialContext` or `TrialContext`) and pyright checks the body too: a missing
|
|
78
|
+
`await`, the wrong context for the kind of body, a generator or a returned value. An unannotated
|
|
79
|
+
body is checked only when it runs.
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from reeval_python import TrialContext, evaluate
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@evaluate("lands, async")
|
|
86
|
+
async def lands(c: TrialContext) -> None:
|
|
87
|
+
await c.send("Create greet.py that prints hi")
|
|
88
|
+
assert (await c.exec("python greet.py")).ok
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`c.exec(cmd, retries=2, interval=2)` runs a command that exits non-zero again, up to 2 more
|
|
92
|
+
times, 2 seconds apart (`interval` is seconds or a timedelta, one second by default), and returns
|
|
93
|
+
the last try. Use it for a command that can fail on a transient, such as a test that calls a
|
|
94
|
+
model: `c.exec("pytest -q tests/hidden", retries=2)`. Any non-zero exit retries, and the record and
|
|
95
|
+
output say `passed on try 2 of 3`.
|
|
96
|
+
|
|
97
|
+
`c.exec(cmd, env={"EXPECTED": "42"})` sets variables for that command only, over the
|
|
98
|
+
environment's, in the background too. A value named like a secret (`*_TOKEN`, `*_KEY`, …) is
|
|
99
|
+
masked in everything reeval writes.
|
|
100
|
+
|
|
101
|
+
### Cases
|
|
102
|
+
|
|
103
|
+
`"cases"` runs one eval over a list, and the body takes the trial and its case. Each case is a
|
|
104
|
+
dict (a `Case`, `TypedDict` with `key`) or a dataclass with a `key`. A key is 1–80 characters with
|
|
105
|
+
no surrounding whitespace, `#`, `›` or control characters, and unique within the eval; the run reports each case as `<eval> [<key>]`.
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
@evaluate("greets", {"cases": [{"key": "en"}, {"key": "fr"}]})
|
|
109
|
+
def greets(c: SyncTrialContext, case: Case) -> None: ...
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Examples
|
|
113
|
+
|
|
114
|
+
- Feature smoke: `packages/reeval/test/features/python-sdk/hello/` (uv project with a project dependency)
|
|
115
|
+
- Plan case: `packages/reeval/test/plan/python/`
|
|
116
|
+
- Contributor guide: `.agents/skills/add-a-language/SKILL.md` in the reeval repo
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Python eval authoring API for reeval (*.eval.py)."""
|
|
2
2
|
|
|
3
|
-
from reeval_python.context import
|
|
3
|
+
from reeval_python.context import SyncTrialContext, TrialContext
|
|
4
4
|
from reeval_python.declare import evaluate, group, todo
|
|
5
5
|
from reeval_python.environment import (
|
|
6
6
|
DEFAULT_EGRESS_ALLOW,
|
|
@@ -18,50 +18,62 @@ from reeval_python.environment import (
|
|
|
18
18
|
plugin,
|
|
19
19
|
tart,
|
|
20
20
|
)
|
|
21
|
-
from reeval_python.errors import
|
|
22
|
-
from reeval_python.expect import Expectation, expect
|
|
21
|
+
from reeval_python.errors import EvalError, ReevalCallError
|
|
23
22
|
from reeval_python.options import (
|
|
24
23
|
BestOf,
|
|
24
|
+
BuiltinGrader,
|
|
25
|
+
Case,
|
|
25
26
|
CaseOptions,
|
|
26
27
|
EvalOptions,
|
|
27
28
|
JudgeDefaults,
|
|
28
|
-
JudgeOptions,
|
|
29
29
|
)
|
|
30
|
-
from reeval_python.
|
|
30
|
+
from reeval_python.target import Target, capability, regression
|
|
31
|
+
from reeval_python.types import (
|
|
32
|
+
BackgroundHandle,
|
|
33
|
+
Decision,
|
|
34
|
+
DecisionUsage,
|
|
35
|
+
Diff,
|
|
36
|
+
ExecResult,
|
|
37
|
+
FileChange,
|
|
38
|
+
Turn,
|
|
39
|
+
)
|
|
31
40
|
|
|
32
41
|
__all__ = [
|
|
33
42
|
"DEFAULT_EGRESS_ALLOW",
|
|
34
|
-
"
|
|
43
|
+
"TrialContext",
|
|
35
44
|
"BackgroundHandle",
|
|
45
|
+
"Decision",
|
|
46
|
+
"DecisionUsage",
|
|
36
47
|
"BestOf",
|
|
48
|
+
"BuiltinGrader",
|
|
37
49
|
"Diff",
|
|
38
50
|
"DockerSandbox",
|
|
39
51
|
"Environment",
|
|
52
|
+
"Case",
|
|
53
|
+
"EvalError",
|
|
40
54
|
"CaseOptions",
|
|
41
55
|
"EvalOptions",
|
|
42
56
|
"ExecResult",
|
|
43
|
-
"Expectation",
|
|
44
57
|
"FakeHarness",
|
|
45
58
|
"FakeJudge",
|
|
46
59
|
"FileChange",
|
|
47
60
|
"JudgeDefaults",
|
|
48
|
-
"JudgeOptions",
|
|
49
61
|
"Plugin",
|
|
50
62
|
"PluginBuild",
|
|
51
|
-
"ReevalAssertionError",
|
|
52
63
|
"ReevalCallError",
|
|
53
|
-
"
|
|
64
|
+
"SyncTrialContext",
|
|
65
|
+
"Target",
|
|
54
66
|
"TartSandbox",
|
|
55
67
|
"Turn",
|
|
56
|
-
"Verdict",
|
|
57
68
|
"define_environment",
|
|
58
69
|
"docker",
|
|
59
70
|
"evaluate",
|
|
60
|
-
"expect",
|
|
61
71
|
"fake_harness",
|
|
72
|
+
"capability",
|
|
62
73
|
"fake_judge",
|
|
63
74
|
"group",
|
|
64
75
|
"plugin",
|
|
76
|
+
"regression",
|
|
65
77
|
"tart",
|
|
66
78
|
"todo",
|
|
67
79
|
]
|