Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lambda cannot be serialized. #2102

Merged
merged 3 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Copy and pasting the git commit messages is __NOT__ enough.
### 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.
- Fixed an issue where the `EnvisionDataFormatterArgs` default would use a locally defined lambda and cause a serialization failure.
### Removed
### Security

Expand Down
6 changes: 5 additions & 1 deletion envision/data_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class Operation(IntEnum):
_primitives = {int, float, str, VehicleType, TrafficActorType}


def _passthrough_method_1_arg(v):
return v


class ReductionContext:
"""Mappings between an object and its reduction to an ID."""

Expand Down Expand Up @@ -126,7 +130,7 @@ class EnvisionDataFormatterArgs(NamedTuple):
"""Data formatter configurations."""

id: Optional[str]
serializer: Callable[[list], Any] = lambda d: d
serializer: Callable[[list], Any] = _passthrough_method_1_arg
float_decimals: int = 2
bool_as_int: bool = True
enable_reduction: bool = True
Expand Down