Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.
Open
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.6
FROM python:3.9

RUN apt-get -y update && apt-get -y install ffmpeg
# RUN apt-get -y update && apt-get -y install git wget python-dev python3-dev libopenmpi-dev python-pip zlib1g-dev cmake python-opencv
Expand Down
28 changes: 25 additions & 3 deletions baselines/common/vec_env/vec_env.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
import contextlib
import os
from abc import ABC, abstractmethod

import io
import builtins
from baselines.common.tile_images import tile_images

safe_builtins = {
'range',
'complex',
'set',
'frozenset',
'slice',
}

class RestrictedUnpickler(pickle.Unpickler):

def find_class(self, module, name):
"""Only allow safe classes from builtins"""
if module == "builtins" and name in safe_builtins:
return getattr(builtins, name)
"""Forbid everything else"""
raise pickle.UnpicklingError("global '%s.%s' is forbidden" %
(module, name))

def restricted_loads(s):
"""Helper function analogous to pickle.loads()"""
return RestrictedUnpickler(io.BytesIO(s)).load()
class AlreadySteppingError(Exception):
"""
Raised when an asynchronous step is running while
Expand Down Expand Up @@ -200,7 +221,8 @@ def __getstate__(self):
return cloudpickle.dumps(self.x)

def __setstate__(self, ob):
import pickle
#import pickle
restricted_loads(ob)
self.x = pickle.loads(ob)


Expand Down