plot_config_delta
¶
Applying a small edit to the trial viewer's plot config, the way SensAI changes the plot.
The agent never retypes the whole config. It sends only what changes, in the shape of a JSON Merge Patch (RFC 7386): an object merges into the config key by key, and anything else, a value or a list, replaces what was there. One difference from the RFC: null never deletes anything. Models write null for "nothing here", so reading it as a removal wiped signals and reset fields that were meant to stay. null is only accepted as a value, for the few fields that allow it (an automatic range, say), and a signal is removed with remove_plot_signals. The edit is applied to the current config and the result is checked, so a field the config does not have, a signal the trial does not have, or a value out of range is refused with a message the agent can act on, instead of landing in the plot.
PlotConfigDeltaError
¶
Bases: ValueError
An edit that cannot be applied, worded for the agent that wrote it so it can correct itself.
compact_plot_config
¶
compact_plot_config(config: PlotConfig) -> dict[str, Any]
The config without anything that has its default value, so a prompt carries only what has been set.
Filters stay whole when there are any, since their type is a default value too and the filter would be unreadable without it. A signal always keeps its color, which has no default.
Source code in src/mujoco_mojo/utils/layers/dojo/sensai/plot_config_delta.py
apply_plot_config_delta
¶
apply_plot_config_delta(
config: PlotConfig,
delta: Mapping[str, Any],
columns: Collection[str] = (),
) -> PlotConfig
The config with the edit delta applied. config itself is not changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
PlotConfig
|
The current plot config. |
required |
delta
|
Mapping[str, Any]
|
The edit, as a JSON Merge Patch in which |
required |
columns
|
Collection[str]
|
The columns of the trial. When there are any, a signal or x-axis column the edit names has to be one of them; when there are none (nothing is known about the trial) names are not checked. |
()
|
Raises:
| Type | Description |
|---|---|
PlotConfigDeltaError
|
If a field does not exist, a signal is not in the trial, or the result is not a valid config. The message says what to fix. |
Source code in src/mujoco_mojo/utils/layers/dojo/sensai/plot_config_delta.py
remove_plot_signals
¶
remove_plot_signals(
config: PlotConfig, names: Collection[str]
) -> PlotConfig
The config without the signals named. config itself is not changed.
Raises:
| Type | Description |
|---|---|
PlotConfigDeltaError
|
If no name is given, or a name is not plotted. The message lists what is plotted. |