Package akka.javasdk.testkit.eval
Interface Experiment<V>
- Type Parameters:
V- the reply type of the agent's command handler
@DoNotInherit
public interface Experiment<V>
Cases bound to the agent under test, ready to run. Obtained from
ExperimentCases.agent(akka.japi.function.Function2<A, C, akka.javasdk.agent.Agent.Effect<R>>).
An experiment is immutable. Every setting returns a new experiment and leaves this one
unchanged, so call run() on the experiment the last setting returned.
Not for user extension.
-
Method Summary
Modifier and TypeMethodDescriptionevaluationTimeout(Duration timeout) Sets how long an attempt waits for the ledger to hold its interaction and one evaluation per bound evaluator,ExperimentRunner.DEFAULT_EVALUATION_TIMEOUTunless set.Sets the gaterun()checks.Sets how the reply of an attempt is compared with the expected reply of its case.Sets the name the report carries, seeExperimentRunner.EvalReport.name().repeat(int times) Runs every case this many times in total, each time in a fresh session.reportDirectory(Path directory) Sets the directoryrun()writes the report file to, seeExperimentRunner.EvalReport.reportFile().run()Runs all cases, checks the gate and writes the report file.Disables writing a report file onrun().
-
Method Details
-
gate
Sets the gaterun()checks. Without a gate every case must pass.- Parameters:
gate- the gate condition to satisfy- Returns:
- a new experiment with the setting applied
- Throws:
IllegalArgumentException- whengateis null
-
grade
Sets how the reply of an attempt is compared with the expected reply of its case. Without a grader the runner compares them withObject.equals(java.lang.Object), which suits a mocked model or a typed reply. The result of the comparison is theExperimentRunner.EXPECTEDresult of the attempt, next to the verdicts of the bound evaluators, and the gate and the report treat it like an evaluator verdict.The grader is not called when the agent call failed or returned no value. The
ExperimentRunner.EXPECTEDresult is then inconclusive.- Parameters:
grader- the grader to evaluate the expected reply against the actual reply- Returns:
- a new experiment with the setting applied
- Throws:
IllegalArgumentException- when no case has an expected reply, orgraderis null
-
name
Sets the name the report carries, seeExperimentRunner.EvalReport.name(). It names the report file, so it must be usable as a file name on every platform: not blank, at most 200 characters, and without< > : " / \ | ? *or control characters. Without a name the report is named after the test method that calledrun(), for exampleSupportAgentEvalTest.qualityGate.- Parameters:
name- the report name- Returns:
- a new experiment with the setting applied
- Throws:
IllegalArgumentException- when the name is not usable as a file name
-
reportDirectory
Sets the directoryrun()writes the report file to, seeExperimentRunner.EvalReport.reportFile(). Without one the report goes totarget/eval-reportsunder the working directory.- Parameters:
directory- the directory to write the report file to- Returns:
- a new experiment with the setting applied
- Throws:
IllegalArgumentException- whendirectoryis null
-
withoutReportFile
Experiment<V> withoutReportFile()Disables writing a report file onrun().- Returns:
- a new experiment with the setting applied
-
evaluationTimeout
Sets how long an attempt waits for the ledger to hold its interaction and one evaluation per bound evaluator,ExperimentRunner.DEFAULT_EVALUATION_TIMEOUTunless set. An evaluator without an evaluation at the timeout is inconclusive on that attempt. Raise it for a judge that calls a real model or for a durable evaluator with slow steps.- Parameters:
timeout- duration to wait, must be positive- Returns:
- a new experiment with the setting applied
- Throws:
IllegalArgumentException- whentimeoutis null, zero, or negative
-
repeat
Runs every case this many times in total, each time in a fresh session. Once by default. The gate, the rates and the spend count every attempt, soGate.allCasesShouldPass()passes only when every case passed in every run. The report names the evaluators that passed in some runs and failed in others of the same case, seeExperimentRunner.EvalReport.cases().A case that passes in every run is not shown to always pass:
timesruns cannot show a failure rate below one intimes. The stubs and the runtime are not reset between runs, so a stub or an evaluator must not depend on state an attempt writes.- Parameters:
times- number of times to run each case, at least 1- Returns:
- a new experiment with the setting applied
- Throws:
IllegalArgumentException- whentimesis less than 1
-
run
Runs all cases, checks the gate and writes the report file. Does not throw on a failed gate; assert on the report.- Returns:
- the evaluation report
-