From fb92935601b22c947642948d80916a17d2f8a36b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 13:33:36 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lerobot/common/envs/utils.py | 8 ++------ lerobot/common/policies/sac/modeling_sac.py | 2 +- lerobot/common/robot_devices/control_utils.py | 2 +- lerobot/scripts/server/gym_manipulator.py | 2 +- lerobot/scripts/visualize_dataset_html.py | 4 +--- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lerobot/common/envs/utils.py b/lerobot/common/envs/utils.py index 907e9138..b73e19ea 100644 --- a/lerobot/common/envs/utils.py +++ b/lerobot/common/envs/utils.py @@ -108,9 +108,7 @@ def check_env_attributes_and_types(env: gym.vector.VectorEnv) -> None: with warnings.catch_warnings(): warnings.simplefilter("once", UserWarning) # Apply filter only in this function - if not ( - hasattr(env.envs[0], "task_description") and hasattr(env.envs[0], "task") - ): + if not (hasattr(env.envs[0], "task_description") and hasattr(env.envs[0], "task")): warnings.warn( "The environment does not have 'task_description' and 'task'. Some policies require these features.", UserWarning, @@ -124,9 +122,7 @@ def check_env_attributes_and_types(env: gym.vector.VectorEnv) -> None: ) -def add_envs_task( - env: gym.vector.VectorEnv, observation: dict[str, Any] -) -> dict[str, Any]: +def add_envs_task(env: gym.vector.VectorEnv, observation: dict[str, Any]) -> dict[str, Any]: """Adds task feature to the observation dict with respect to the first environment attribute.""" if hasattr(env.envs[0], "task_description"): observation["task"] = env.call("task_description") diff --git a/lerobot/common/policies/sac/modeling_sac.py b/lerobot/common/policies/sac/modeling_sac.py index 81859119..aa130984 100644 --- a/lerobot/common/policies/sac/modeling_sac.py +++ b/lerobot/common/policies/sac/modeling_sac.py @@ -490,7 +490,7 @@ class SACObservationEncoder(nn.Module): """Encode image and/or state vector observations.""" def __init__(self, config: SACConfig, input_normalizer: nn.Module) -> None: - super(SACObservationEncoder, self).__init__() + super().__init__() self.config = config self.input_normalization = input_normalizer self._init_image_layers() diff --git a/lerobot/common/robot_devices/control_utils.py b/lerobot/common/robot_devices/control_utils.py index ef72810a..499b1b2c 100644 --- a/lerobot/common/robot_devices/control_utils.py +++ b/lerobot/common/robot_devices/control_utils.py @@ -24,8 +24,8 @@ from contextlib import nullcontext from copy import copy from functools import cache -import rerun as rr import numpy as np +import rerun as rr import torch from deepdiff import DeepDiff from termcolor import colored diff --git a/lerobot/scripts/server/gym_manipulator.py b/lerobot/scripts/server/gym_manipulator.py index 6a8e848a..1a4caee3 100644 --- a/lerobot/scripts/server/gym_manipulator.py +++ b/lerobot/scripts/server/gym_manipulator.py @@ -700,7 +700,7 @@ class KeyboardInterfaceWrapper(gym.Wrapper): Reset the environment and clear any pending events """ with self.event_lock: - self.events = {k: False for k in self.events} + self.events = dict.fromkeys(self.events, False) return self.env.reset(**kwargs) def close(self): diff --git a/lerobot/scripts/visualize_dataset_html.py b/lerobot/scripts/visualize_dataset_html.py index ef0385e7..2bf1fac9 100644 --- a/lerobot/scripts/visualize_dataset_html.py +++ b/lerobot/scripts/visualize_dataset_html.py @@ -179,9 +179,7 @@ def run_server( ] videos_info = [ { - "url": url_for( - "static", filename=str(video_path).replace("\\", "/") - ), + "url": url_for("static", filename=str(video_path).replace("\\", "/")), "filename": video_path.parent.name, } for video_path in video_paths