Repository navigation
Expand file tree
/
Copy pathtest_banking.py
More file actions
425 lines (389 loc) · 24.8 KB
/
Copy pathtest_banking.py
File metadata and controls
425 lines (389 loc) · 24.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
#!/usr/bin/env python3
"""Eval Protocol entrypoint for τ²-bench banking RFT (policy = qwen3.6-27b).
==============================================================================
BIG PICTURE — what this single file IS and WHERE it runs
==============================================================================
This is the file that BOTH commands load:
ep local-test # local eval, no weight updates
eval-protocol create rft (training_run.sh --go) # the paid RFT job on Fireworks
Eval Protocol (EP) discovers the `@evaluation_test`-decorated function below,
and from that decorator it knows everything it needs to run one rollout and
score it. EP then drives this loop (see TRAINING_LOOP.md §3.5):
dataset row ──► policy model takes a turn ──► MCP server runs a banking tool
▲ │
└──────────── (repeat until stop) ◄──────┘
│
▼
this file's reward fn → one scalar 0..1
GLOSSARY — what "ROLLOUT" means here (read this once):
A ROLLOUT = one COMPLETE play-through of ONE banking task. The ENTIRE box above
— from a dataset row entering, through EVERY agent turn and tool call, until the
episode stops and a single reward comes out — is ONE rollout. It is NOT one
model call and NOT one tool call; it's the whole multi-turn conversation.
• one rollout: row in ──► (agent turn ↔ banking tool, repeated) ──► one score 0..1
• the per-step "reward: 0.00" in the server logs is a PLACEHOLDER; the REAL
reward is computed ONCE at the end of the rollout (in the reward fn).
• a log line like "Rollout 8 completed: 4 steps" = one rollout that made 4 tool
calls. "Rollout 15 completed: 1 steps" = a different rollout, 1 tool call.
• num_runs=2 (below) => each task is rolled out TWICE and the scores averaged
(the simulated user is stochastic). max_concurrent_rollouts=16 => up to 16
of these episodes run in parallel.
• SAME mechanics in eval vs training; only the use of the score differs:
ep local-test : rollout -> score -> just RECORD it (no weight change).
create rft : per task, generate a GROUP of G rollouts; the SPREAD of
their scores is the GRPO/DAPO gradient. (That's also why
temperature=0.8 — you WANT the group's rollouts to differ.)
In one line: a rollout is the atomic unit both evaluation and RL are built from.
So this file does exactly THREE things, and nothing else:
1. dataset_adapter : turn each JSONL row -> an EvaluationRow EP can roll out
(`banking_to_evaluation_row`)
2. @evaluation_test : declare HOW to roll out (which model, which MCP server,
how many parallel rollouts, the pass threshold, …)
3. reward : score the FINISHED rollout (delegated to
FIREWORKS_TRAINING/score_from_reward_info.py → score_evaluation_row)
Everything heavy lives elsewhere (all now under FIREWORKS_TRAINING/):
- the ENVIRONMENT + TOOLS -> FIREWORKS_TRAINING/banking_mcp/server.py (MCP server)
- the REWARD MATH -> FIREWORKS_TRAINING/score_from_reward_info.py
- the REWARD PRIMITIVES -> FIREWORKS_TRAINING/reward_functions/recompute_partial_credit.py
- the LAUNCH/flags -> FIREWORKS_TRAINING/training_run.sh
==============================================================================
Run order (see FIREWORKS_TRAINING/RUNBOOK.md):
ep local-test # local eval, no training (model calls hit Fireworks)
bash FIREWORKS_TRAINING/training_run.sh --go # launch RFT on Fireworks
"""
# ---------------------------------------------------------------------------
# WHY no `from __future__ import annotations` (this is a real footgun here):
# That import turns every annotation into a STRING at runtime. EP's "pointwise"
# mode inspects the test function's signature and requires the `row` parameter to
# be a *real* EvaluationRow type, not the string "EvaluationRow". With the future
# import, EP's validator rejects the test ("'row' parameter must be of type
# EvaluationRow"). So we deliberately leave it out.
# ---------------------------------------------------------------------------
import json # (kept for parity / ad-hoc dataset poking; harmless if unused here)
import os # read env vars: POLICY_MODEL, EP_DATASET, USE_LEANMCP_GATEWAY, keys
import socket # probe for a free MCP server port (see MCP_PORT below)
import sys # to extend sys.path so we can import the reward sitting next to us
# --- make this dir importable so we can pull in the reward function -----------
# This file, score_from_reward_info.py, and reward_functions/ now ALL live under
# FIREWORKS_TRAINING/. We add THIS file's dir to sys.path, then import the scorer
# (which in turn imports reward_functions/ as a sibling package).
# __file__ -> .../tau2-bench/FIREWORKS_TRAINING/test_banking.py
# HERE = dirname(__file__) -> .../tau2-bench/FIREWORKS_TRAINING
# ROOT = dirname(HERE) -> .../tau2-bench (repo root)
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(HERE)
sys.path.insert(0, HERE)
# score_evaluation_row(row) -> row (with row.evaluation_result set). All the
# reward logic (tau2 evaluate_simulation + gated partial credit) is in there.
from score_from_reward_info import score_evaluation_row # noqa: E402
# --- EP imports (verified against installed eval-protocol 0.3.0) --------------
# EvaluationRow : the unit EP rolls out and scores (carries messages + metadata).
# Message : one chat message (role + content [+ tool_calls]).
# InputMetadata : side-channel we attach to each row (task id + dataset_info);
# it survives the rollout so the reward fn can read the task back.
from eval_protocol.models import EvaluationRow, Message, InputMetadata # noqa: E402
# evaluation_test : the decorator that registers this as an EP test.
# MCPGymRolloutProcessor: the rollout engine that launches our MCP server and
# steps the env (agent ↔ banking tools) to produce a row.
from eval_protocol.pytest import evaluation_test, MCPGymRolloutProcessor # noqa: E402
# ===========================================================================
# WHICH MODEL PLAYS THE AGENT (the "policy")
# ===========================================================================
# IMPORTANT — there are TWO different model ids for TWO different jobs:
# * TRAINING (`create rft --base-model`): the BASE path
# accounts/fireworks/models/qwen3p6-27b (the artifact you fine-tune)
# * INFERENCE (eval rollout / gateway): the DEPLOYMENT path
# accounts/dheerajmpaicmu-4f4056/deployments/b2f04w5c
# The base path is NOT serverless-callable for this custom 27B — calling it
# returns an empty 'stop' with 0 tokens. Custom models must hit a deployment.
# (deployment b2f04w5c is scale-to-zero, so the first call cold-starts.)
#
# Default policy for LOCAL TEST = gpt-oss-20b on SERVERLESS (no deployment, no
# cold start, works through plain Fireworks). For real training, training_run.sh
# `--base-model` selects what's tuned; override here with POLICY_MODEL if needed.
#
# The `fireworks_ai/` PREFIX is a LiteLLM provider tag: it tells LiteLLM "this is
# a Fireworks model, call the Fireworks API." (EP routes model calls via LiteLLM.)
POLICY_MODEL = os.environ.get(
"POLICY_MODEL",
"fireworks_ai/accounts/fireworks/models/gpt-oss-20b",
)
# Policy sampling knobs (env-overridable). For DEBUG set TEMPERATURE=0 (greedy) and
# SEED=<int> for deterministic, reproducible generations.
# default 0.8 in normal runs -> exploration -> in-group variance -> RL gradient.
TEMPERATURE = float(os.environ.get("TEMPERATURE", "0.8"))
# Optional reproducibility seed. Unset/empty -> no seed (nondeterministic). LiteLLM
# forwards `seed` to Fireworks' OpenAI-compatible API.
SEED = os.environ.get("SEED") # str | None
# Which JSONL of tasks to roll out. Each line = one banking task (built by
# workspace/build_banking_easy.py). Override with EP_DATASET to point elsewhere.
DATASET = os.environ.get("EP_DATASET", "FIREWORKS_TRAINING/data/banking_easy_medium.jsonl")
# Turn the multi-turn SIMULATED USER on/off.
# ON = the FAITHFUL tau2 task: a simulated customer (its own LLM) converses with
# the agent each turn, so the agent must ASK for info to solve the task.
# This is what produces real reward variance => a usable training gradient.
# OFF = one-shot agent monologue (the customer never replies). Only useful for a
# cheap plumbing/smoke check; NOT a trainable signal.
# Default ON. EP enables its user simulator only when the row carries a
# user_simulation dict with enabled=True (see eval_protocol .../execution/manager.py).
ENABLE_USER_SIM = os.environ.get("ENABLE_USER_SIM", "1") == "1"
# Which model plays the simulated CUSTOMER (separate from the agent/policy). Falls
# back to the dataset row's recommended_user_model. Keep the fireworks_ai/ prefix.
USER_SIM_MODEL = os.environ.get(
"USER_SIM_MODEL", "fireworks_ai/accounts/fireworks/models/gpt-oss-120b"
)
# HARD per-rollout step ceiling, passed to @evaluation_test below (EP default = 30).
# EP enforces it in mcp/execution/manager.py (`if step >= steps: MAX_STEPS`). With the
# simulated user ON, one "step" = one full conversation turn; with it OFF, one step =
# one tool call. This is the HARD cap; the repetition loop-guard wired into
# banking_mcp/server.py (should_early_stop) normally ends degenerate loops sooner.
# Override per run, e.g. MAX_STEPS=20 bash FIREWORKS_TRAINING/run_model.sh ...
MAX_STEPS = int(os.environ.get("MAX_STEPS", "30"))
# WHICH PORT the banking MCP server binds to. EP's MCPGymRolloutProcessor defaults
# to a HARDCODED 9700 and hard-fails if it's taken — which kills any second
# concurrent run (e.g. eval'ing two models at once). So we pick the port HERE and
# hand it to EP via rollout_processor_kwargs: start at MCP_PORT (default 9700) and
# walk forward (9701, 9702, ...) until we find one nothing is listening on.
def _find_free_port(start: int, max_tries: int = 50) -> int:
for candidate in range(start, start + max_tries):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.settimeout(1)
if s.connect_ex(("localhost", candidate)) != 0: # nobody listening -> free
if candidate != start:
print(f"⚠️ Port {start} is in use — MCP server will use {candidate} instead")
return candidate
raise RuntimeError(f"No free port in range {start}-{start + max_tries - 1}")
MCP_PORT = _find_free_port(int(os.environ.get("MCP_PORT", "9700")))
# Optional per-difficulty SUBSET (default: use the WHOLE dataset). Cap how many
# tasks of each bucket get rolled out via MAX_<BUCKET> env vars, e.g.
# MAX_EASY=5 MAX_MEDIUM=5 -> a 10-task smoke run (5 Easy + 5 Medium)
# Buckets without a cap are used in full. Rows keep their dataset order.
def _bucket_caps() -> dict:
caps = {}
for name, value in os.environ.items():
# MAX_STEPS is the per-rollout step ceiling (see above), NOT a bucket cap.
if name == "MAX_STEPS":
continue
if name.startswith("MAX_") and value.strip().isdigit():
caps[name[4:].upper()] = int(value) # MAX_EASY -> "EASY" -> 5
return caps
def _subset_by_bucket(rows: list[dict]) -> list[dict]:
caps = _bucket_caps()
if not caps:
return rows
seen: dict[str, int] = {}
kept: list[dict] = []
for r in rows:
key = str(r.get("bucket") or "").strip().upper().replace(" ", "_")
cap = caps.get(key)
if cap is None:
kept.append(r) # no cap for this bucket -> keep all
elif seen.get(key, 0) < cap:
kept.append(r)
seen[key] = seen.get(key, 0) + 1
print(f"[test_banking] bucket subset {caps} -> {len(kept)}/{len(rows)} tasks")
return kept
# ===========================================================================
# OPTIONAL: route INFERENCE through the LeanMCP gateway (for logging)
# ===========================================================================
# The LeanMCP gateway is a transparent OpenAI-compatible proxy: it forwards to
# Fireworks but LOGS the call (visible at app.leanmcp.com/observability). Pattern
# copied from leanmcp_scripts/workspace/test_gateway_litellm.py: keep the
# `fireworks_ai/` model prefix, set api_base to the gateway, and auth with the
# LeanMCP key (read from the GLOBAL shell env — we do NOT touch any .env file).
#
# This ONLY affects `ep local-test` / baseline eval — i.e. rollouts EP runs on
# YOUR machine. It does NOT (and cannot) redirect the on-Fireworks RFT training
# rollouts: there the trainee policy is generated inside Fireworks against the
# live LoRA checkpoint, so there is no client api_base to hijack. (TRAINING_LOOP §7c.)
LEANMCP_GATEWAY_BASE = "https://aigateway.leanmcp.com/v1/fireworks"
# OPT-IN, default OFF. `training_run.sh --localtest` flips this on/off for you.
# Why default OFF: EP bakes completion_params into the pytest node id, so the
# api_key would (a) appear in local node ids and (b) be UPLOADED to Fireworks
# during `create rft` (where the evaluator can't read LEANMCP_API_KEY anyway).
# => gateway routing is a local-debug convenience only; the key stays on your box.
USE_LEANMCP_GATEWAY = os.environ.get("USE_LEANMCP_GATEWAY", "0") == "1"
def _completion_params() -> list[dict]:
"""Build the LiteLLM call settings for the AGENT (policy) model.
EP passes this straight to LiteLLM for every agent turn. Returns a LIST (EP
can sweep multiple param sets; we use exactly one). The dict keys are standard
LiteLLM/OpenAI knobs:
- model : which model plays the agent (see POLICY_MODEL above)
- temperature : sampling randomness. 0.8 = exploration -> in-group variance
-> a usable GRPO/DAPO gradient (OVERVIEW §6). Too low here
makes all G rollouts identical -> zero advantage -> no learning.
- max_tokens : per-response cap. Tight (4096) to curb small-model rambling
and the 300-message loops (Problem 1).
When USE_LEANMCP_GATEWAY=1 we additionally inject api_base+api_key so the call
is proxied through LeanMCP (logged) instead of hitting Fireworks directly.
"""
p = {
"model": POLICY_MODEL,
"temperature": TEMPERATURE, # env-overridable; 0 = greedy/deterministic (debug)
"max_tokens": 4096, # tight cap; small models ramble (Problem 1)
}
if SEED not in (None, ""):
p["seed"] = int(SEED) # reproducible sampling (forwarded to Fireworks)
if USE_LEANMCP_GATEWAY:
# Read the LeanMCP key from the shell env. Fail LOUD if it's missing, so
# we never silently fall back to an unlogged/unauthenticated call.
key = os.environ.get("LEANMCP_API_KEY")
if not key:
raise RuntimeError(
"USE_LEANMCP_GATEWAY=1 but LEANMCP_API_KEY not in the environment. "
"Export it (it's in your global shell env), or set USE_LEANMCP_GATEWAY=0 "
"to call Fireworks directly with FIREWORKS_API_KEY."
)
p["api_base"] = LEANMCP_GATEWAY_BASE # route through LeanMCP -> Fireworks, logged
p["api_key"] = key # LeanMCP key, NOT the Fireworks key
return [p]
# Fallback path to the banking domain's prompt files. The MCP server builds the
# REAL policy/system prompt from the env; this constant is just a safety net and
# is not the primary source of the prompt.
BANKING_SYSTEM_PROMPT = os.path.join(
ROOT, "data", "tau2", "domains", "banking_knowledge", "prompts"
) # the env builds the real policy prompt; this is a fallback path only
def banking_to_evaluation_row(rows: list[dict]) -> list[EvaluationRow]:
"""ADAPTER (step 1): our JSONL rows -> EP EvaluationRow objects.
EP calls this once with the full list of dataset rows (each `r` is one parsed
JSONL line from build_banking_easy.py). We must return one EvaluationRow per
task. Mirrors the airline tutorial's tau_bench_airline_to_evaluation_row.
Two things we set on each row:
• messages: the SEED conversation EP starts the rollout from. We seed it with
a single system message = the user-prompt template (the persona/scenario
the simulated user plays). The agent then responds to this.
• input_metadata: a side-channel that RIDES ALONG through the rollout and is
still attached to the FINISHED row, so the reward fn can read it back:
- row_id : the task id (e.g. "task_001"). The reward uses this
to load the real tau2 Task and grade against it.
- dataset_info : free-form dict; we stash everything the env/reward
might want (difficulty bucket, env context, the
simulated-user spec, the evaluation_criteria, and a
max-turns hint). bucket -> curriculum CAP; criteria
-> what "solved" means.
"""
rows = _subset_by_bucket(rows) # optional MAX_EASY / MAX_MEDIUM caps (no-op by default)
out: list[EvaluationRow] = []
for r in rows:
# Build the SIMULATED-USER config in the shape EP expects, from our row's
# persona. EP reads `row.user_simulation` (a top-level extra field) and only
# spins up the customer simulator when enabled=True. Our dataset stores the
# persona under user_simulation.instructions (recommended_user_model/temperature).
us = r.get("user_simulation") or {}
# The simulated user's LLM call (vendor.tau2 UserSimulator -> litellm) does
# NOT go through _completion_params(); it uses these llm_args directly. So
# when gateway routing is on we must inject api_base+api_key HERE too, or the
# customer turns would bypass LeanMCP and hit Fireworks directly (needing
# FIREWORKS_API_KEY). vendor's generate() forwards **llm_args to litellm.
user_llm_args = {"temperature": us.get("temperature", 0.0)}
if USE_LEANMCP_GATEWAY:
key = os.environ.get("LEANMCP_API_KEY")
if not key:
raise RuntimeError(
"USE_LEANMCP_GATEWAY=1 but LEANMCP_API_KEY not in the environment "
"(needed to route the simulated user through the gateway)."
)
user_llm_args["api_base"] = LEANMCP_GATEWAY_BASE # route customer turns via LeanMCP
user_llm_args["api_key"] = key # LeanMCP key, NOT Fireworks
user_simulation = {
"enabled": ENABLE_USER_SIM,
"system_prompt": us.get("instructions", ""), # the customer persona
"llm": us.get("recommended_user_model") or USER_SIM_MODEL,
"llm_args": user_llm_args,
}
out.append(
EvaluationRow(
# Seed message: the system/user-simulation prompt template. The
# env fills in the real scenario; the agent replies to this.
messages=[Message(role="system", content=r.get("user_prompt_template", ""))],
input_metadata=InputMetadata(
row_id=r["id"], # task id -> reward loads the matching tau2 Task
dataset_info={
# difficulty tier -> sets the partial-credit ceiling (CAP)
"bucket": r.get("bucket"),
# any domain/env setup the rollout/env may need
"environment_context": r.get("environment_context"),
# THE SIMULATED-USER CONFIG. EP reads it from HERE
# (eval_protocol/mcp_env.py: dataset_info.get("user_simulation"))
# to build the DatasetRow the rollout manager drives. It MUST
# be the {enabled, llm, system_prompt} shape — NOT our raw
# dataset shape — or .get("enabled") is False and no customer runs.
"user_simulation": user_simulation,
# the action/db/nl checks that define success (read by reward)
"evaluation_criteria": r.get("evaluation_criteria"),
# soft cap on turns; default 20 if the row didn't carry one
"max_turns_hint": (r.get("meta") or {}).get("max_turns_hint", 20),
},
),
)
)
return out
# ===========================================================================
# THE EP TEST DECLARATION (step 2) — every argument matters
# ===========================================================================
@evaluation_test(
# WHERE the tasks come from: list of JSONL paths. EP reads these into raw rows.
input_dataset=[DATASET],
# HOW to convert raw rows -> EvaluationRow (our adapter above).
dataset_adapter=banking_to_evaluation_row,
# The AGENT model + sampling settings (built once at import time). NOTE: this
# is evaluated NOW, so USE_LEANMCP_GATEWAY/POLICY_MODEL are read at import.
completion_params=_completion_params(), # routes via LeanMCP gateway when USE_LEANMCP_GATEWAY=1
# Should be something like [{'model': 'fireworks_ai/accounts/fireworks/models/gpt-oss-20b', 'temperature': 0.0, 'max_tokens': 4096, 'seed': 0}]
# Temperature made deliberatry zero to make sure it is working.
# The ROLLOUT ENGINE: MCP-Gym. It launches our MCP server as a subprocess and
# steps the env (agent turn -> tool call -> tool result -> repeat). This is
# what actually produces the multi-turn trajectory on each EvaluationRow.
# (See the "GLOSSARY — what ROLLOUT means here" block in the module docstring.)
rollout_processor=MCPGymRolloutProcessor(),
# Server kwargs for the processor: our auto-picked free port (default 9700,
# falls forward to 9701, 9702, ... when busy) so concurrent runs don't collide.
rollout_processor_kwargs={"port": MCP_PORT},
# WHICH MCP server to launch = our banking env + tools. MCP-Gym runs:
# python <this script> --port <p> (PATH-resolved python; see training_run.sh)
server_script_path="FIREWORKS_TRAINING/banking_mcp/server.py", # MCP server, RUNBOOK step 5
# "pointwise" = score each row INDEPENDENTLY (one reward per rollout), as
# opposed to pairwise/listwise comparisons. This is why the test fn takes a
# single `row` and returns a single scored `row`.
mode="pointwise",
# A row "passes" if its score ≥ 0.4. Used for the pass-rate summary / the
# green-vs-red per-row result. (Note: `ep local-test` also applies its own
# --ep-success-threshold for the overall suite gate.)
passed_threshold=0.4,
# HARD per-rollout step ceiling (EP default 30). Backstop against runaway
# rollouts; the repetition loop-guard in banking_mcp/server.py usually ends
# degenerate loops earlier. Env-tunable via MAX_STEPS.
steps=MAX_STEPS,
# Run each task TWICE and average — the simulated user is stochastic, so this
# smooths out luck/noise in the score (OVERVIEW §8). Costs 2x rollouts.
num_runs=2,
# Up to 16 rollouts in flight at once -> throughput. Pure speed knob; doesn't
# change the math. Matches the group size used in training.
max_concurrent_rollouts=16,
)
def test_banking(row: EvaluationRow) -> EvaluationRow:
"""REWARD HOOK (step 3): score ONE finished rollout.
EP calls this once per rolled-out row AFTER the trajectory is complete. The
incoming `row` already has the full conversation (row.messages) and our
input_metadata. We delegate ALL scoring to score_evaluation_row, which:
1. loads the real tau2 Task by row_id,
2. rebuilds a tau2 SimulationRun from row.messages,
3. runs tau2's evaluate_simulation -> reward_info (action_checks, db_check…),
4. applies the gated partial-credit math,
5. sets row.evaluation_result = EvaluateResult(score, reason) and returns row.
Keeping the body a one-liner means there is ONE source of truth for the reward
(the workspace/ module), reused identically by local eval and training.
"""
return score_evaluation_row(row)
# ===========================================================================
# Not the training entrypoint. Running this file directly is just a cheap
# "does the dataset load?" sanity check (no model, no rollout, no EP).
# Real runs go through `ep local-test` or `eval-protocol create rft`.
# ===========================================================================
if __name__ == "__main__":
path = os.path.join(ROOT, DATASET)
if os.path.exists(path):
n = sum(1 for _ in open(path))
print(f"dataset OK: {n} rows in {DATASET}")
else:
print(f"dataset MISSING: build it first -> python3 workspace/build_banking_easy.py")