fix(ci): make pre-commit quality checks pass

这个提交包含在:
Elvin
2026-03-07 02:21:09 +08:00
父节点 b69ffe3c02
当前提交 1be38954e6
共有 6 个文件被更改,包括 30 次插入 和 26 次删除

查看文件

@ -36,7 +36,9 @@ repos:
- id: check-yaml - id: check-yaml
- id: check-toml - id: check-toml
- id: end-of-file-fixer - id: end-of-file-fixer
exclude: ^src/lerobot/assets/(piper_description|piper_x_description)/
- id: trailing-whitespace - id: trailing-whitespace
exclude: ^src/lerobot/assets/(piper_description|piper_x_description)/
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.1 rev: v0.14.1

查看文件

@ -18,7 +18,6 @@ from dataclasses import dataclass, field
from lerobot.cameras import CameraConfig from lerobot.cameras import CameraConfig
from ..config import RobotConfig from ..config import RobotConfig

查看文件

@ -24,10 +24,10 @@ from lerobot.processor import RobotAction, RobotObservation
from lerobot.utils.decorators import check_if_already_connected, check_if_not_connected from lerobot.utils.decorators import check_if_already_connected, check_if_not_connected
from lerobot.utils.piper_sdk import ( from lerobot.utils.piper_sdk import (
PIPER_ACTION_KEYS, PIPER_ACTION_KEYS,
guard_piper_ctrl_mode_on_connect,
PIPER_JOINT_ACTION_KEYS, PIPER_JOINT_ACTION_KEYS,
PIPER_JOINT_NAMES, PIPER_JOINT_NAMES,
get_piper_sdk, get_piper_sdk,
guard_piper_ctrl_mode_on_connect,
milli_to_unit, milli_to_unit,
parse_piper_log_level, parse_piper_log_level,
unit_to_milli, unit_to_milli,
@ -93,11 +93,7 @@ class PiperFollower(Robot):
connected_cameras = [] connected_cameras = []
try: try:
self.configure() self.configure()
should_auto_calibrate = ( should_auto_calibrate = not self.is_calibrated and calibrate and self.config.require_calibration
not self.is_calibrated
and calibrate
and self.config.require_calibration
)
if should_auto_calibrate: if should_auto_calibrate:
logger.info( logger.info(
"No piper-follower calibration file found for '%s'. Running lerobot-calibrate flow.", "No piper-follower calibration file found for '%s'. Running lerobot-calibrate flow.",

查看文件

@ -141,7 +141,6 @@ def setup_interface_with_fallback(interface: str, cfg: CANSetupConfig) -> tuple[
return False, None, " | ".join(attempt_msgs) return False, None, " | ".join(attempt_msgs)
def test_motor(bus, motor_id: int, timeout: float, use_fd: bool): def test_motor(bus, motor_id: int, timeout: float, use_fd: bool):
"""Test a single motor and return responses.""" """Test a single motor and return responses."""
import can import can

查看文件

@ -25,10 +25,10 @@ from lerobot.processor import RobotAction
from lerobot.utils.decorators import check_if_already_connected, check_if_not_connected from lerobot.utils.decorators import check_if_already_connected, check_if_not_connected
from lerobot.utils.piper_sdk import ( from lerobot.utils.piper_sdk import (
PIPER_ACTION_KEYS, PIPER_ACTION_KEYS,
guard_piper_ctrl_mode_on_connect,
PIPER_JOINT_ACTION_KEYS, PIPER_JOINT_ACTION_KEYS,
PIPER_JOINT_NAMES, PIPER_JOINT_NAMES,
get_piper_sdk, get_piper_sdk,
guard_piper_ctrl_mode_on_connect,
milli_to_unit, milli_to_unit,
parse_piper_log_level, parse_piper_log_level,
unit_to_milli, unit_to_milli,
@ -55,8 +55,8 @@ def _ensure_not_lfs_pointer(path_obj: Any, relpath: str) -> None:
raise RuntimeError( raise RuntimeError(
"Bundled PiPER assets are still Git LFS pointer files. " "Bundled PiPER assets are still Git LFS pointer files. "
"Please run `git lfs pull --include=" "Please run `git lfs pull --include="
"\"src/lerobot/assets/piper_description/**,src/lerobot/assets/piper_x_description/**\" " '"src/lerobot/assets/piper_description/**,src/lerobot/assets/piper_x_description/**" '
"--exclude=\"*\"` and `git lfs checkout src/lerobot/assets/piper_description " '--exclude="*"` and `git lfs checkout src/lerobot/assets/piper_description '
"src/lerobot/assets/piper_x_description`, then retry. " "src/lerobot/assets/piper_x_description`, then retry. "
f"(file: {relpath})" f"(file: {relpath})"
) )
@ -109,11 +109,7 @@ class PiperLeader(Teleoperator):
self._manual_control_enabled = None self._manual_control_enabled = None
try: try:
self.configure() self.configure()
if ( if not self.is_calibrated and calibrate and self.config.require_calibration:
not self.is_calibrated
and calibrate
and self.config.require_calibration
):
logger.info( logger.info(
"No piper-leader calibration file found for '%s'. Running lerobot-calibrate flow.", "No piper-leader calibration file found for '%s'. Running lerobot-calibrate flow.",
self.id, self.id,
@ -214,7 +210,9 @@ class PiperLeader(Teleoperator):
return return
if enabled and self._manual_control_enabled is not True: if enabled and self._manual_control_enabled is not True:
if not self._wait_enable(self.config.enable_timeout_s): if not self._wait_enable(self.config.enable_timeout_s):
logger.warning("Piper leader did not report enabled state before entering gravity compensation.") logger.warning(
"Piper leader did not report enabled state before entering gravity compensation."
)
if self.config.sync_gripper: if self.config.sync_gripper:
self._set_gripper_enabled(False) self._set_gripper_enabled(False)
self._ensure_gravity_comp_loop().start() self._ensure_gravity_comp_loop().start()

查看文件

@ -9,9 +9,19 @@ import lerobot.robots.piper_follower.piper_follower as piper_follower_module
import lerobot.teleoperators.piper_leader.piper_leader as piper_leader_module import lerobot.teleoperators.piper_leader.piper_leader as piper_leader_module
import lerobot.utils.piper_sdk as piper_sdk_utils import lerobot.utils.piper_sdk as piper_sdk_utils
from lerobot.motors import MotorCalibration from lerobot.motors import MotorCalibration
from lerobot.robots.piper_follower import PiperFollower, PiperFollowerConfig, PiperXFollower, PiperXFollowerConfig from lerobot.robots.piper_follower import (
PiperFollower,
PiperFollowerConfig,
PiperXFollower,
PiperXFollowerConfig,
)
from lerobot.robots.utils import make_robot_from_config from lerobot.robots.utils import make_robot_from_config
from lerobot.teleoperators.piper_leader import PiperLeader, PiperLeaderConfig, PiperXLeader, PiperXLeaderConfig from lerobot.teleoperators.piper_leader import (
PiperLeader,
PiperLeaderConfig,
PiperXLeader,
PiperXLeaderConfig,
)
from lerobot.teleoperators.utils import make_teleoperator_from_config from lerobot.teleoperators.utils import make_teleoperator_from_config
from lerobot.utils.piper_sdk import PIPER_ACTION_KEYS from lerobot.utils.piper_sdk import PIPER_ACTION_KEYS
@ -442,7 +452,9 @@ def test_piper_leader_gravity_comp_manual_control_uses_mit(monkeypatch):
("device_kind", "port", "robot_id"), ("device_kind", "port", "robot_id"),
[("leader", "can1", None), ("follower", "can0", "piper_role_guard")], [("leader", "can1", None), ("follower", "can0", "piper_role_guard")],
) )
def test_piper_connect_fails_and_writes_follower_role_when_in_teach_mode(monkeypatch, device_kind, port, robot_id): def test_piper_connect_fails_and_writes_follower_role_when_in_teach_mode(
monkeypatch, device_kind, port, robot_id
):
patch_fake_sdk(monkeypatch) patch_fake_sdk(monkeypatch)
if device_kind == "leader": if device_kind == "leader":
@ -459,11 +471,9 @@ def test_piper_connect_fails_and_writes_follower_role_when_in_teach_mode(monkeyp
def test_piper_lfs_pointer_urdf_raises_actionable_error(tmp_path): def test_piper_lfs_pointer_urdf_raises_actionable_error(tmp_path):
pointer_file = tmp_path / "lfs_pointer.urdf" pointer_file = tmp_path / "lfs_pointer.urdf"
pointer_file.write_text( pointer_file.write_text("version https://git-lfs.github.com/spec/v1\noid sha256:deadbeef\nsize 123\n")
"version https://git-lfs.github.com/spec/v1\n"
"oid sha256:deadbeef\n"
"size 123\n"
)
with pytest.raises(RuntimeError, match="Git LFS pointer files"): with pytest.raises(RuntimeError, match="Git LFS pointer files"):
piper_leader_module._ensure_not_lfs_pointer(pointer_file, "assets/piper_description/urdf/pointer.urdf") piper_leader_module._ensure_not_lfs_pointer(
pointer_file, "assets/piper_description/urdf/pointer.urdf"
)