镜像自地址
https://github.com/MINT-SJTU/Evo-RL.git
已同步 2026-11-20 18:17:06 +00:00
test(ci): fix fast tests for ACP config and sarm import guards
- update ACP training tests to use current ACPConfig fields and shared ACP tag constants - skip sarm subtask annotation tests when Qwen3VLMoe symbol is unavailable in transformers - keep changes scoped to fast-tests paths and preserve runtime behavior
这个提交包含在:
@ -16,7 +16,12 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
pytest.importorskip("transformers")
|
transformers = pytest.importorskip("transformers")
|
||||||
|
if not hasattr(transformers, "Qwen3VLMoeForConditionalGeneration"):
|
||||||
|
pytest.skip(
|
||||||
|
"requires transformers with Qwen3VLMoeForConditionalGeneration",
|
||||||
|
allow_module_level=True,
|
||||||
|
)
|
||||||
|
|
||||||
from lerobot.data_processing.sarm_annotations.subtask_annotation import (
|
from lerobot.data_processing.sarm_annotations.subtask_annotation import (
|
||||||
Subtask,
|
Subtask,
|
||||||
|
|||||||
@ -9,6 +9,7 @@ from lerobot.configs.types import FeatureType, PolicyFeature
|
|||||||
from lerobot.policies.pi05.configuration_pi05 import PI05Config
|
from lerobot.policies.pi05.configuration_pi05 import PI05Config
|
||||||
from lerobot.policies.pi05.processor_pi05 import make_pi05_pre_post_processors
|
from lerobot.policies.pi05.processor_pi05 import make_pi05_pre_post_processors
|
||||||
from lerobot.rl.acp_hook import build_acp_raw_batch_hook
|
from lerobot.rl.acp_hook import build_acp_raw_batch_hook
|
||||||
|
from lerobot.rl.acp_tags import ACP_NEGATIVE_TAG, ACP_POSITIVE_TAG
|
||||||
from lerobot.utils.constants import OBS_LANGUAGE_ATTENTION_MASK, OBS_LANGUAGE_TOKENS
|
from lerobot.utils.constants import OBS_LANGUAGE_ATTENTION_MASK, OBS_LANGUAGE_TOKENS
|
||||||
from tests.utils import require_package
|
from tests.utils import require_package
|
||||||
|
|
||||||
@ -78,8 +79,6 @@ def test_acp_prompt_reaches_pi05_tokenizer(mock_auto_tokenizer):
|
|||||||
ACPConfig(
|
ACPConfig(
|
||||||
enable=True,
|
enable=True,
|
||||||
indicator_field="complementary_info.acp_indicator",
|
indicator_field="complementary_info.acp_indicator",
|
||||||
positive_tag="Advantage: positive",
|
|
||||||
negative_tag="Advantage: negative",
|
|
||||||
indicator_dropout_prob=0.0,
|
indicator_dropout_prob=0.0,
|
||||||
),
|
),
|
||||||
seed=123,
|
seed=123,
|
||||||
@ -101,8 +100,8 @@ def test_acp_prompt_reaches_pi05_tokenizer(mock_auto_tokenizer):
|
|||||||
|
|
||||||
prompts = tracking_tokenizer.calls[-1]
|
prompts = tracking_tokenizer.calls[-1]
|
||||||
assert len(prompts) == 2
|
assert len(prompts) == 2
|
||||||
assert "Advantage: positive" in prompts[0]
|
assert ACP_POSITIVE_TAG in prompts[0]
|
||||||
assert "Advantage: negative" in prompts[1]
|
assert ACP_NEGATIVE_TAG in prompts[1]
|
||||||
assert prompts[0].startswith("Task: Pick bottle")
|
assert prompts[0].startswith("Task: Pick bottle")
|
||||||
assert "State:" in prompts[0]
|
assert "State:" in prompts[0]
|
||||||
assert OBS_LANGUAGE_TOKENS in out
|
assert OBS_LANGUAGE_TOKENS in out
|
||||||
|
|||||||
@ -7,6 +7,7 @@ from torch.utils.data import DataLoader
|
|||||||
from lerobot.configs.train import ACPConfig
|
from lerobot.configs.train import ACPConfig
|
||||||
from lerobot.datasets.lerobot_dataset import LeRobotDataset
|
from lerobot.datasets.lerobot_dataset import LeRobotDataset
|
||||||
from lerobot.rl.acp_hook import build_acp_raw_batch_hook
|
from lerobot.rl.acp_hook import build_acp_raw_batch_hook
|
||||||
|
from lerobot.rl.acp_tags import ACP_NEGATIVE_TAG, ACP_POSITIVE_TAG
|
||||||
|
|
||||||
|
|
||||||
def test_acp_hook_accepts_integer_indicators():
|
def test_acp_hook_accepts_integer_indicators():
|
||||||
@ -14,8 +15,6 @@ def test_acp_hook_accepts_integer_indicators():
|
|||||||
ACPConfig(
|
ACPConfig(
|
||||||
enable=True,
|
enable=True,
|
||||||
indicator_field="acp_indicator",
|
indicator_field="acp_indicator",
|
||||||
positive_tag="POS",
|
|
||||||
negative_tag="NEG",
|
|
||||||
indicator_dropout_prob=0.0,
|
indicator_dropout_prob=0.0,
|
||||||
),
|
),
|
||||||
seed=42,
|
seed=42,
|
||||||
@ -27,8 +26,8 @@ def test_acp_hook_accepts_integer_indicators():
|
|||||||
|
|
||||||
out = hook(batch, 0)
|
out = hook(batch, 0)
|
||||||
assert out["task"] == [
|
assert out["task"] == [
|
||||||
"pick bottle\nPOS",
|
f"pick bottle\n{ACP_POSITIVE_TAG}",
|
||||||
"place bottle\nNEG",
|
f"place bottle\n{ACP_NEGATIVE_TAG}",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -37,8 +36,6 @@ def test_acp_hook_injects_tags():
|
|||||||
ACPConfig(
|
ACPConfig(
|
||||||
enable=True,
|
enable=True,
|
||||||
indicator_field="complementary_info.acp_indicator",
|
indicator_field="complementary_info.acp_indicator",
|
||||||
positive_tag="POS",
|
|
||||||
negative_tag="NEG",
|
|
||||||
indicator_dropout_prob=0.0,
|
indicator_dropout_prob=0.0,
|
||||||
),
|
),
|
||||||
seed=42,
|
seed=42,
|
||||||
@ -49,7 +46,7 @@ def test_acp_hook_injects_tags():
|
|||||||
}
|
}
|
||||||
|
|
||||||
out = hook(batch, 0)
|
out = hook(batch, 0)
|
||||||
assert out["task"] == ["pick bottle\nPOS", "place bottle\nNEG"]
|
assert out["task"] == [f"pick bottle\n{ACP_POSITIVE_TAG}", f"place bottle\n{ACP_NEGATIVE_TAG}"]
|
||||||
|
|
||||||
|
|
||||||
def test_acp_hook_dropout_keeps_original_task():
|
def test_acp_hook_dropout_keeps_original_task():
|
||||||
@ -57,8 +54,6 @@ def test_acp_hook_dropout_keeps_original_task():
|
|||||||
ACPConfig(
|
ACPConfig(
|
||||||
enable=True,
|
enable=True,
|
||||||
indicator_field="complementary_info.acp_indicator",
|
indicator_field="complementary_info.acp_indicator",
|
||||||
positive_tag="POS",
|
|
||||||
negative_tag="NEG",
|
|
||||||
indicator_dropout_prob=1.0,
|
indicator_dropout_prob=1.0,
|
||||||
),
|
),
|
||||||
seed=42,
|
seed=42,
|
||||||
@ -87,8 +82,6 @@ def test_acp_hook_non_integer_type_raises():
|
|||||||
ACPConfig(
|
ACPConfig(
|
||||||
enable=True,
|
enable=True,
|
||||||
indicator_field="acp_indicator",
|
indicator_field="acp_indicator",
|
||||||
positive_tag="POS",
|
|
||||||
negative_tag="NEG",
|
|
||||||
indicator_dropout_prob=0.0,
|
indicator_dropout_prob=0.0,
|
||||||
),
|
),
|
||||||
seed=42,
|
seed=42,
|
||||||
@ -106,8 +99,6 @@ def test_acp_hook_non_binary_value_raises():
|
|||||||
ACPConfig(
|
ACPConfig(
|
||||||
enable=True,
|
enable=True,
|
||||||
indicator_field="acp_indicator",
|
indicator_field="acp_indicator",
|
||||||
positive_tag="POS",
|
|
||||||
negative_tag="NEG",
|
|
||||||
indicator_dropout_prob=0.0,
|
indicator_dropout_prob=0.0,
|
||||||
),
|
),
|
||||||
seed=42,
|
seed=42,
|
||||||
@ -143,8 +134,6 @@ def test_acp_hook_with_real_local_dataset_batch(batch_size: int):
|
|||||||
ACPConfig(
|
ACPConfig(
|
||||||
enable=True,
|
enable=True,
|
||||||
indicator_field="complementary_info.acp_indicator",
|
indicator_field="complementary_info.acp_indicator",
|
||||||
positive_tag="POS",
|
|
||||||
negative_tag="NEG",
|
|
||||||
indicator_dropout_prob=0.0,
|
indicator_dropout_prob=0.0,
|
||||||
),
|
),
|
||||||
seed=42,
|
seed=42,
|
||||||
@ -153,5 +142,5 @@ def test_acp_hook_with_real_local_dataset_batch(batch_size: int):
|
|||||||
|
|
||||||
assert len(out["task"]) == batch_size
|
assert len(out["task"]) == batch_size
|
||||||
for i in range(batch_size):
|
for i in range(batch_size):
|
||||||
expected_tag = "POS" if int(indicators[i].item()) == 1 else "NEG"
|
expected_tag = ACP_POSITIVE_TAG if int(indicators[i].item()) == 1 else ACP_NEGATIVE_TAG
|
||||||
assert out["task"][i].endswith(expected_tag)
|
assert out["task"][i].endswith(expected_tag)
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户