docs(pipeline): Clarify transition handling and hook behavior

- Updated documentation to specify that hooks always receive transitions in EnvTransition format, ensuring consistent behavior across input formats.
- Refactored the step_through method to yield only EnvTransition objects, regardless of the input format, and updated related tests to reflect this change.
- Enhanced test assertions to verify the structure of results and the correctness of processing steps.
This commit is contained in:
Adil Zouitine
2025-08-02 14:51:52 +02:00
parent 2c4e888c7f
commit 41959389b6
2 changed files with 46 additions and 23 deletions
+16 -5
View File
@@ -268,14 +268,25 @@ def test_step_through_with_dict():
assert len(results) == 3 # Original + 2 steps
# Ensure all results are dicts (same format as input)
# Ensure all results are EnvTransition dicts (regardless of input format)
for result in results:
assert isinstance(result, dict)
# Check that keys are TransitionKey enums or at least valid transition keys
for key in result:
assert key in [
TransitionKey.OBSERVATION,
TransitionKey.ACTION,
TransitionKey.REWARD,
TransitionKey.DONE,
TransitionKey.TRUNCATED,
TransitionKey.INFO,
TransitionKey.COMPLEMENTARY_DATA,
]
# Check that the processing worked - the complementary data from steps
# should show up in the info or complementary_data fields when converted back to dict
# Note: This depends on how _default_transition_to_batch handles complementary_data
# For now, just check that we get dict outputs
# Check that the processing worked - verify step counters in complementary_data
assert results[1].get(TransitionKey.COMPLEMENTARY_DATA, {}).get("step1_counter") == 0
assert results[2].get(TransitionKey.COMPLEMENTARY_DATA, {}).get("step1_counter") == 0
assert results[2].get(TransitionKey.COMPLEMENTARY_DATA, {}).get("step2_counter") == 0
def test_step_through_no_hooks():