Skip to content

Commit 541916c

Browse files
Chris Elionsurfnerd
Chris Elion
authored andcommitted
Update cattrs dependencies to support python3.9 (#4821)
1 parent dd4fd79 commit 541916c

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

com.unity.ml-agents/CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to
77
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).
88

9+
10+
## [Unreleased]
11+
### Major Changes
12+
#### com.unity.ml-agents (C#)
13+
#### ml-agents / ml-agents-envs / gym-unity (Python)
14+
15+
### Minor Changes
16+
#### com.unity.ml-agents / com.unity.ml-agents.extensions (C#)
17+
#### ml-agents / ml-agents-envs / gym-unity (Python)
18+
- The `cattrs` version dependency was updated to allow `>=1.1.0` on Python 3.8 or higher. (#4821)
19+
20+
### Bug Fixes
21+
#### com.unity.ml-agents (C#)
22+
#### ml-agents / ml-agents-envs / gym-unity (Python)
23+
- An issue that caused `GAIL` to fail for environments where agents can terminate episodes by self-sacrifice has been fixed. (#4971)
24+
925
## [1.8.0-preview] - 2021-02-17
1026
### Major Changes
1127
#### com.unity.ml-agents (C#)

ml-agents-envs/mlagents_envs/tests/test_envs.py

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def test_port_defaults(
4545
)
4646
env = UnityEnvironment(file_name=file_name, worker_id=0, base_port=base_port)
4747
assert expected == env._port
48+
env.close()
4849

4950

5051
@mock.patch("mlagents_envs.env_utils.launch_executable")
@@ -57,6 +58,7 @@ def test_log_file_path_is_set(mock_communicator, mock_launcher):
5758
args = env._executable_args()
5859
log_file_index = args.index("-logFile")
5960
assert args[log_file_index + 1] == "./some-log-folder-path/Player-0.log"
61+
env.close()
6062

6163

6264
@mock.patch("mlagents_envs.env_utils.launch_executable")

ml-agents-envs/mlagents_envs/tests/test_rpc_utils.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import io
22
import numpy as np
33
import pytest
4-
from typing import List, Tuple
4+
from typing import List, Tuple, Any
55

66
from mlagents_envs.communicator_objects.agent_info_pb2 import AgentInfoProto
77
from mlagents_envs.communicator_objects.observation_pb2 import (
@@ -137,13 +137,14 @@ def proto_from_steps(
137137
reward = decision_steps.reward[agent_id_index]
138138
done = False
139139
max_step_reached = False
140-
agent_mask = None
140+
agent_mask: Any = None
141141
if decision_steps.action_mask is not None:
142-
agent_mask = [] # type: ignore
142+
agent_mask = []
143143
for _branch in decision_steps.action_mask:
144144
agent_mask = np.concatenate(
145145
(agent_mask, _branch[agent_id_index, :]), axis=0
146146
)
147+
agent_mask = agent_mask.astype(np.bool).tolist()
147148
observations: List[ObservationProto] = []
148149
for all_observations_of_type in decision_steps.obs:
149150
observation = all_observations_of_type[agent_id_index]
@@ -161,7 +162,7 @@ def proto_from_steps(
161162
reward=reward,
162163
done=done,
163164
id=agent_id,
164-
max_step_reached=max_step_reached,
165+
max_step_reached=bool(max_step_reached),
165166
action_mask=agent_mask,
166167
observations=observations,
167168
)
@@ -190,7 +191,7 @@ def proto_from_steps(
190191
reward=reward,
191192
done=done,
192193
id=agent_id,
193-
max_step_reached=max_step_reached,
194+
max_step_reached=bool(max_step_reached),
194195
action_mask=None,
195196
observations=final_observations,
196197
)

ml-agents/setup.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ def run(self):
6868
# https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Installation.md#windows-installing-pytorch
6969
'torch>=1.6.0,<1.8.0;platform_system!="Windows"',
7070
"tensorboard>=1.15",
71-
# cattrs 1.1.0 dropped support for python 3.6.
72-
"cattrs>=1.0.0,<1.1.0",
71+
# cattrs 1.1.0 dropped support for python 3.6, but 1.0.0 doesn't work for python 3.9
72+
# Since there's no version that supports both, we have to draw the line somwehere.
73+
"cattrs<1.1.0; python_version<'3.8'",
74+
"cattrs>=1.1.0; python_version>='3.8'",
7375
"attrs>=19.3.0",
7476
'pypiwin32==223;platform_system=="Windows"',
7577
"importlib_metadata; python_version<'3.8'",

0 commit comments

Comments
 (0)