From ec5495084087520dd8e32a228d72ffdf3ccefbea Mon Sep 17 00:00:00 2001 From: ariel Date: Fri, 26 Jan 2024 11:34:17 +0100 Subject: [PATCH 1/2] Add fix to ruff pre-commit --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8e6fbd9..0623ebc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,6 +31,7 @@ repos: rev: v0.1.13 hooks: - id: ruff + args: ["--fix"] - id: ruff-format - repo: https://github.com/asottile/pyupgrade rev: v3.3.1 From d48a15da9c035f0f84601037e5452c611580885d Mon Sep 17 00:00:00 2001 From: ariel Date: Fri, 26 Jan 2024 11:34:27 +0100 Subject: [PATCH 2/2] Remove big observation logs --- cogment_lab/core.py | 2 -- cogment_lab/envs/gymnasium.py | 2 +- cogment_lab/envs/pettingzoo.py | 4 +--- cogment_lab/humans/actor.py | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/cogment_lab/core.py b/cogment_lab/core.py index 89287d7..6089ce5 100644 --- a/cogment_lab/core.py +++ b/cogment_lab/core.py @@ -258,7 +258,6 @@ async def impl(self, actor_session: ActorSession): observation = self.session_helper.get_observation(event) if observation is None: continue - logging.info(f"Got observation: {observation}") if not observation.active: action = None @@ -266,7 +265,6 @@ async def impl(self, actor_session: ActorSession): action = None else: action = await self.act(observation.value, observation.rendered_frame) # type: ignore - logging.info(f"Got action: {action} with action_space: {self.action_space.gym_space}") cog_action = self.action_space.create_serialize(action) actor_session.do_action(cog_action) if event.rewards: diff --git a/cogment_lab/envs/gymnasium.py b/cogment_lab/envs/gymnasium.py index 1946e40..ba06473 100644 --- a/cogment_lab/envs/gymnasium.py +++ b/cogment_lab/envs/gymnasium.py @@ -236,7 +236,7 @@ async def step(self, state: State, action): logging.info("Stepping environment") obs, reward, terminated, truncated, info = state.env.step(action) - logging.info(f"Step returned {obs=}, {reward=}, {terminated=}, {truncated=}, {info=}") + logging.info("Stepping the environment") observation = state.observation_space.create_serialize( value=obs, diff --git a/cogment_lab/envs/pettingzoo.py b/cogment_lab/envs/pettingzoo.py index a0e1606..635989e 100644 --- a/cogment_lab/envs/pettingzoo.py +++ b/cogment_lab/envs/pettingzoo.py @@ -152,7 +152,6 @@ async def reset(self, state: State): state.actor_name = agent frame = state.env.render() if state.session_cfg.render else None - logging.info(f"Creating observation from {obs=}") observation = state.observation_spaces[agent].create_serialize( value=obs, rendered_frame=frame, active=True, alive=True ) @@ -300,7 +299,7 @@ def __init__( sub_dry: bool = True, ): """ - Initialize the AECEnvironment. + Initialize the ParallelEnvironment. Args: env_path: Path to the PettingZoo environment class. @@ -398,7 +397,6 @@ async def reset(self, state: State): obs, info = state.env.reset(seed=state.session_cfg.seed) frame = state.env.render() if state.session_cfg.render else None - logging.info(f"Creating observation from {obs=}") if frame is not None: logging.info(f"Frame shape at reset: {frame.shape}") diff --git a/cogment_lab/humans/actor.py b/cogment_lab/humans/actor.py index 38d8f74..4bb1649 100644 --- a/cogment_lab/humans/actor.py +++ b/cogment_lab/humans/actor.py @@ -104,7 +104,6 @@ async def get(): @app.websocket("/ws") async def websocket_endpoint(websocket: WebSocket): logging.info("Waiting for socket connection") - logging.info("Setting last_action_data") last_action_data = "no-op" logging.info(f"Set {last_action_data=}") await websocket.accept()