Skip to content

Commit

Permalink
[rllib] Fix output API when lz4 not installed (#5421)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericl authored and richardliaw committed Aug 10, 2019
1 parent de95117 commit 8b6f0d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rllib/offline/json_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from ray.rllib.offline.io_context import IOContext
from ray.rllib.offline.output_writer import OutputWriter
from ray.rllib.utils.annotations import override, PublicAPI
from ray.rllib.utils.compression import pack
from ray.rllib.utils.compression import pack, compression_supported

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -99,7 +99,7 @@ def _get_file(self):


def _to_jsonable(v, compress):
if compress:
if compress and compression_supported():
return str(pack(v))
elif isinstance(v, np.ndarray):
return v.tolist()
Expand Down
5 changes: 5 additions & 0 deletions rllib/utils/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
LZ4_ENABLED = False


@DeveloperAPI
def compression_supported():
return LZ4_ENABLED


@DeveloperAPI
def pack(data):
if LZ4_ENABLED:
Expand Down

0 comments on commit 8b6f0d3

Please sign in to comment.