rlmesh::RunHooks
Observer callbacks for a run. Every default is a no-op; implement any subset.
trait RunHooks: SendA sync run calls hooks on the thread that called it, outside any async
execution context, so a hook may make sync rlmesh calls; under an
_async twin they run inside its future, where a blocking rlmesh call
fails with the RuntimeError class. A hook error aborts the run;
on_run_end still fires exactly once with the
completed episodes, and the run’s own error wins over its error.
Provided methods
- on_run_start()Once per run, before the first episode, with the run's context.
- on_episode_start()After each episode's reset returns (
episodeis 0-based). - on_step()After each env step.
- on_episode_end()With each completed episode's result.
- on_run_end()Exactly once when the run ends, also on an error or a cancel, with the (possibly partial) result.
on_run_start
provided method[source]fn on_run_start(&mut self, context: Arc<dyn RunContext>) -> Result<()>Once per run, before the first episode, with the run’s context.
on_episode_start
provided method[source]fn on_episode_start(
&mut self,
episode: i64,
seed: Option<i64>,
) -> Result<()>After each episode’s reset returns (episode is 0-based).
on_step
provided method[source]fn on_step(&mut self, event: &StepEvent) -> Result<()>After each env step.
on_episode_end
provided method[source]fn on_episode_end(&mut self, result: &EpisodeResult) -> Result<()>With each completed episode’s result.
on_run_end
provided method[source]fn on_run_end(&mut self, result: &RunResult) -> Result<()>Exactly once when the run ends, also on an error or a cancel, with the (possibly partial) result.