From 58c87d427d7f48beca602565910e68abee5962a8 Mon Sep 17 00:00:00 2001 From: Tucker Date: Mon, 30 Oct 2023 10:41:10 -0400 Subject: [PATCH] Fix pickling error. --- CHANGELOG.md | 1 + envision/client_config.py | 9 +++++---- envision/tests/test_data_replay.py | 8 +++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19a30f68d3..25aabc7812 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Copy and pasting the git commit messages is __NOT__ enough. ### Deprecated ### Fixed - Fixed issue where `SumoTrafficSimulation` could get locked up on reset if a scenario had only 1 map but multiple scenario variations. +- Fixed an issue where an out-of-scope method reference caused a pickling error. ### Removed ### Security diff --git a/envision/client_config.py b/envision/client_config.py index 9e5078a055..b5e6155cbf 100644 --- a/envision/client_config.py +++ b/envision/client_config.py @@ -36,6 +36,10 @@ class SingleAttributeOverride(NamedTuple): """The maximum number of elements an iterable attribute can contain.""" +def _default_override(): + return SingleAttributeOverride(True, None) + + @dataclass(frozen=True) class EnvisionStateFilter: """A state filtering tool.""" @@ -49,7 +53,4 @@ class EnvisionStateFilter: def default(cls): """Give a new default filter.""" - def default_override(): - return SingleAttributeOverride(True, None) - - return cls(defaultdict(default_override), defaultdict(default_override)) + return cls(defaultdict(_default_override), defaultdict(_default_override)) diff --git a/envision/tests/test_data_replay.py b/envision/tests/test_data_replay.py index a98bbe5c2c..5ac7b44a5c 100644 --- a/envision/tests/test_data_replay.py +++ b/envision/tests/test_data_replay.py @@ -42,11 +42,13 @@ TIMESTEP_SEC = 0.1 +class KeepLaneAgent(Agent): + def act(self, obs): + return "keep_lane" + + @pytest.fixture def agent_spec(): - class KeepLaneAgent(Agent): - def act(self, obs): - return "keep_lane" return AgentSpec( interface=AgentInterface.from_type(