mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-27 14:39:43 +00:00
fix(smolvla2): use TransitionKey enum (not .value) as transition keys
``EnvTransition`` is declared as a ``TypedDict`` keyed by ``TransitionKey.OBSERVATION.value`` (the string ``'observation'``), but every concrete ``ProcessorStep`` in the pipeline indexes the transition with the enum *member* (``transition[TransitionKey. OBSERVATION]`` / ``transition.get(TransitionKey.OBSERVATION)``). Those are two different keys in a Python dict — string key vs enum key — so steps couldn't find the observation we'd placed under the string variant, and bailed every tick with ``ObservationProcessorStep requires an observation in the transition``. Build the transition with the enum members directly. Matches how ``BatchProcessor``, ``RelativeActionProcessor``, ``HilProcessor``, etc. read the dict. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -629,21 +629,28 @@ def _build_robot_observation_provider(
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if preprocessor is not None:
|
if preprocessor is not None:
|
||||||
transition: dict[str, Any] = {
|
# ``EnvTransition``'s TypedDict is declared with
|
||||||
TransitionKey.OBSERVATION.value: obs_tensors,
|
# ``TransitionKey.OBSERVATION.value`` as keys, but every
|
||||||
TransitionKey.ACTION.value: None,
|
# ProcessorStep in the pipeline does
|
||||||
TransitionKey.REWARD.value: None,
|
# ``transition.get(TransitionKey.OBSERVATION)`` / indexes
|
||||||
TransitionKey.DONE.value: None,
|
# with the *enum member* — not the string ``.value``. Build
|
||||||
TransitionKey.TRUNCATED.value: None,
|
# the dict with enum keys so the steps actually find the
|
||||||
TransitionKey.INFO.value: None,
|
# observation.
|
||||||
TransitionKey.COMPLEMENTARY_DATA.value: {},
|
transition: dict[Any, Any] = {
|
||||||
|
TransitionKey.OBSERVATION: obs_tensors,
|
||||||
|
TransitionKey.ACTION: None,
|
||||||
|
TransitionKey.REWARD: None,
|
||||||
|
TransitionKey.DONE: None,
|
||||||
|
TransitionKey.TRUNCATED: None,
|
||||||
|
TransitionKey.INFO: None,
|
||||||
|
TransitionKey.COMPLEMENTARY_DATA: {},
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
transition = preprocessor(transition)
|
transition = preprocessor(transition)
|
||||||
except Exception as exc: # noqa: BLE001
|
except Exception as exc: # noqa: BLE001
|
||||||
logger.warning("preprocessor failed on robot observation: %s", exc)
|
logger.warning("preprocessor failed on robot observation: %s", exc)
|
||||||
return None
|
return None
|
||||||
obs_tensors = transition.get(TransitionKey.OBSERVATION.value) or {}
|
obs_tensors = transition.get(TransitionKey.OBSERVATION) or {}
|
||||||
|
|
||||||
observation = {
|
observation = {
|
||||||
k: v
|
k: v
|
||||||
|
|||||||
Reference in New Issue
Block a user