mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-26 03:06:01 +00:00
fix(rtc): validate trained prefix capacity
This commit is contained in:
@@ -93,6 +93,19 @@ def test_rtc_processor_initialization_without_debug(rtc_config_debug_disabled):
|
||||
assert processor.tracker is None
|
||||
|
||||
|
||||
def test_rtc_processor_rejects_trained_mode_when_policy_does_not_support_it():
|
||||
config = RTCConfig(mode="trained")
|
||||
|
||||
with pytest.raises(ValueError, match="requires a Pi052 checkpoint"):
|
||||
RTCProcessor(config)
|
||||
|
||||
processor = RTCProcessor(config, trained_mode_supported=True)
|
||||
assert processor.rtc_config.mode == "trained"
|
||||
|
||||
disabled = RTCProcessor(RTCConfig(enabled=False, mode="trained"))
|
||||
assert disabled.rtc_config.enabled is False
|
||||
|
||||
|
||||
# ====================== Tracker Proxy Methods Tests ======================
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import dataclasses
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
@@ -130,6 +131,38 @@ def test_trained_rtc_rejects_measured_delay_above_checkpoint_support():
|
||||
)
|
||||
|
||||
|
||||
def test_trained_rtc_rejects_prefix_shorter_than_conditioned_delay():
|
||||
from lerobot.rollout.inference.rtc import (
|
||||
_TrainedRTCPrefixUnavailableError,
|
||||
_validate_trained_rtc_prefix_available,
|
||||
)
|
||||
|
||||
with pytest.raises(_TrainedRTCPrefixUnavailableError, match="only 2"):
|
||||
_validate_trained_rtc_prefix_available(conditioned_delay=4, available_steps=2)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("execution_horizon", "queue_threshold", "match"),
|
||||
[
|
||||
(3, 4, "execution_horizon"),
|
||||
(4, 3, "queue_threshold"),
|
||||
],
|
||||
)
|
||||
def test_trained_rtc_rollout_requires_capacity_for_max_delay(execution_horizon, queue_threshold, match):
|
||||
from lerobot.policies.rtc.configuration_rtc import RTCConfig
|
||||
from lerobot.rollout.context import _validate_trained_rtc_rollout_config
|
||||
from lerobot.rollout.inference import RTCInferenceConfig
|
||||
|
||||
policy_config = SimpleNamespace(type="pi052", rtc_training_max_delay=4)
|
||||
inference_config = RTCInferenceConfig(
|
||||
rtc=RTCConfig(mode="trained", execution_horizon=execution_horizon),
|
||||
queue_threshold=queue_threshold,
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=match):
|
||||
_validate_trained_rtc_rollout_config(policy_config, inference_config)
|
||||
|
||||
|
||||
def test_sentry_config_defaults():
|
||||
from lerobot.rollout import SentryStrategyConfig
|
||||
|
||||
|
||||
Reference in New Issue
Block a user