Skip to content
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 com.unity.ml-agents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ TensorBoard. Thanks to @brccabral for the contribution! (#4816)
#### com.unity.ml-agents (C#)
- Fix a compile warning about using an obsolete enum in `GrpcExtensions.cs`. (#4812)
#### ml-agents / ml-agents-envs / gym-unity (Python)
- Fixed a bug that would cause an exception when `RunOptions` was deserialized via `pickle`. (#4842)


## [1.7.2-preview] - 2020-12-22
Expand Down
8 changes: 7 additions & 1 deletion ml-agents/mlagents/trainers/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,13 @@ def structure(d: Mapping, t: type) -> Any:

class DefaultTrainerDict(collections.defaultdict):
def __init__(self, *args):
super().__init__(TrainerSettings, *args)
# Depending on how this is called, args may have the defaultdict
# callable at the start of the list or not. In particular, unpickling
# will pass [TrainerSettings].
if args and args[0] == TrainerSettings:
super().__init__(*args)
else:
super().__init__(TrainerSettings, *args)

def __missing__(self, key: Any) -> "TrainerSettings":
if TrainerSettings.default_override is not None:
Expand Down
8 changes: 8 additions & 0 deletions ml-agents/mlagents/trainers/tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import attr
import cattr
import pickle
import pytest
import yaml

Expand Down Expand Up @@ -516,3 +517,10 @@ def test_default_settings():
test1_settings.max_steps = 1
test1_settings.network_settings.hidden_units == default_settings_cls.network_settings.hidden_units
check_if_different(test1_settings, default_settings_cls)


def test_pickle():
# Make sure RunOptions is pickle-able.
run_options = RunOptions()
p = pickle.dumps(run_options)
pickle.loads(p)