Skip to content

Commit 63b0fc7

Browse files
GoparapukethaNrueian
authored andcommitted
[RLlib] Clarify extra model output docstrings (ray-project#63524)
## Why `set_extra_model_outputs` currently asserts that the provided key already exists before calling `InfiniteLookbackBuffer.set`. The docstrings for `SingleAgentEpisode` and `MultiAgentEpisode` also said the method could insert a new key, which made the behavior ambiguous. This updates the docstrings to describe the current overwrite-only behavior. Closes ray-project#63217 ## Tests Not run. Documentation-only change. Signed-off-by: GoparapukethaN <goparapukethan01@gmail.com>
1 parent 15ecdcf commit 63b0fc7

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

rllib/env/multi_agent_episode.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,12 +2042,13 @@ def set_extra_model_outputs(
20422042
) -> None:
20432043
"""Overwrites all or some of this Episode's extra model outputs with `new_data`.
20442044
2045-
This is a helper method to batch `SingleAgentEpisode.set_extra_model_outputs`.
2046-
For more detail, see `SingleAgentEpisode.set_extra_model_outputs`.
2045+
This batches `SingleAgentEpisode.set_extra_model_outputs` calls for the
2046+
agent IDs provided in `new_data`. For more detail, see
2047+
`SingleAgentEpisode.set_extra_model_outputs`.
20472048
20482049
Args:
2049-
key: The `key` within `self.extra_model_outputs` to override data on or
2050-
to insert as a new key into `self.extra_model_outputs`.
2050+
key: Existing extra model output key to override on each target agent
2051+
episode.
20512052
new_data: A dict mapping agent IDs to new extra model outputs data.
20522053
Each value in the dict is the new extra model outputs data to overwrite existing data with.
20532054
This may be a list of individual reward(s) in case this episode

rllib/env/single_agent_episode.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,14 +1360,13 @@ def set_extra_model_outputs(
13601360
current `extra_model_output` values are added to the episode either by calling
13611361
`self.add_env_step` or more directly (and manually) via
13621362
`self.extra_model_outputs[key].append|extend()`. However, for certain
1363-
postprocessing steps, the entirety (or a slice) of an episode's
1364-
`extra_model_outputs` might have to be rewritten or a new key (a new type of
1365-
`extra_model_outputs`) must be inserted, which is when
1363+
postprocessing steps, an existing `extra_model_outputs` entry might have
1364+
to be overwritten fully or in slices, which is when
13661365
`self.set_extra_model_outputs()` should be used.
13671366
13681367
Args:
1369-
key: The `key` within `self.extra_model_outputs` to override data on or
1370-
to insert as a new key into `self.extra_model_outputs`.
1368+
key: Existing key in `self.extra_model_outputs` whose buffer should
1369+
be overwritten.
13711370
new_data: The new data to overwrite existing data with.
13721371
This may be a list of individual reward(s) in case this episode
13731372
is still not numpy'ized yet. In case this episode has already been

0 commit comments

Comments
 (0)