From aa67147796ad3c478014edc350420fa30227dc90 Mon Sep 17 00:00:00 2001 From: Noah Dormann Date: Thu, 5 Dec 2019 15:45:05 +0100 Subject: [PATCH] clarified bytesIO use for load --- torchy_baselines/common/base_class.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/torchy_baselines/common/base_class.py b/torchy_baselines/common/base_class.py index 251ce1d..ccb3f5e 100644 --- a/torchy_baselines/common/base_class.py +++ b/torchy_baselines/common/base_class.py @@ -359,7 +359,8 @@ class BaseRLModel(object): if "params.pth" in namelist: # Load parameters with build in torch function with archive.open("params.pth", mode="r") as param_file: - # File has to be seekable so load in BytesIO first + # File has to be seekable, but param_file is not, so load in BytesIO first + # fixed in python >= 3.7 file_content = io.BytesIO() file_content.write(param_file.read()) # go to start of file @@ -375,7 +376,8 @@ class BaseRLModel(object): opt_params = dict() for file_path in other_files: with archive.open(file_path, mode="r") as opt_param_file: - # File has to be seekable so load in BytesIO first + # File has to be seekable, but opt_param_file is not, so load in BytesIO first + # fixed in python >= 3.7 file_content = io.BytesIO() file_content.write(opt_param_file.read()) # go to start of file