Skip to content

Commit 54ed0d9

Browse files
author
Chris Elion
authored
pass file mode to h5py.File() (#3165) (#3166)
* force different versions of h5py in CI * pass file modes to h5py.File
1 parent bed276f commit 54ed0d9

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

ml-agents/mlagents/trainers/buffer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,15 @@ def save_to_file(self, file_object: BinaryIO) -> None:
226226
"""
227227
Saves the AgentBuffer to a file-like object.
228228
"""
229-
with h5py.File(file_object) as write_file:
229+
with h5py.File(file_object, "w") as write_file:
230230
for key, data in self.items():
231231
write_file.create_dataset(key, data=data, dtype="f", compression="gzip")
232232

233233
def load_from_file(self, file_object: BinaryIO) -> None:
234234
"""
235235
Loads the AgentBuffer from a file-like object.
236236
"""
237-
with h5py.File(file_object) as read_file:
237+
with h5py.File(file_object, "r") as read_file:
238238
for key in list(read_file.keys()):
239239
self[key] = AgentBuffer.AgentBufferField()
240240
# extend() will convert the numpy array's first dimension into list

test_constraints_max_tf1_version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
grpcio>=1.23.0
55
numpy>=1.17.2
66
tensorflow>=1.14.0,<2.0
7+
h5py>=2.10.0

test_constraints_max_tf2_version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
grpcio>=1.23.0
44
numpy>=1.17.2
55
tensorflow>=2.0.0,<2.1.0
6+
h5py>=2.10.0

test_constraints_min_version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ numpy==1.13.3
44
Pillow==4.2.1
55
protobuf==3.6
66
tensorflow==1.7
7+
h5py==2.9.0

0 commit comments

Comments
 (0)