From b87912cb2f39784cafb8a3cc7d7083fe0afa7ec8 Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Mon, 29 Aug 2016 22:16:14 -0700 Subject: [PATCH] Remove typing module. --- doc/conf.py | 2 +- doc/install-on-macosx.md | 2 +- doc/install-on-ubuntu.md | 2 +- docker/deploy/Dockerfile | 2 +- docker/devel/Dockerfile | 2 +- docker/test-base/Dockerfile | 2 +- examples/alexnet/alexnet.py | 1 - install-dependencies.sh | 4 ++-- lib/python/ray/array/distributed/core.py | 1 - lib/python/ray/array/distributed/random.py | 2 -- lib/python/ray/array/remote/core.py | 1 - lib/python/ray/array/remote/linalg.py | 1 - lib/python/ray/array/remote/random.py | 1 - lib/python/ray/pickling.py | 9 --------- lib/python/ray/worker.py | 5 ++--- 15 files changed, 10 insertions(+), 27 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index bd0e5c493..3a8c5ac51 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -18,7 +18,7 @@ import shlex # These 4 lines added to enable ReadTheDocs to work. import mock -MOCK_MODULES = ["libraylib", "IPython", "numpy", "typing", "funcsigs", "subprocess32", "protobuf", "colorama", "graphviz", "cloudpickle", "ray.internal.graph_pb2"] +MOCK_MODULES = ["libraylib", "IPython", "numpy", "funcsigs", "subprocess32", "protobuf", "colorama", "graphviz", "cloudpickle", "ray.internal.graph_pb2"] for mod_name in MOCK_MODULES: sys.modules[mod_name] = mock.Mock() diff --git a/doc/install-on-macosx.md b/doc/install-on-macosx.md index 950638e36..aa0e8b398 100644 --- a/doc/install-on-macosx.md +++ b/doc/install-on-macosx.md @@ -19,7 +19,7 @@ brew update brew install git cmake automake autoconf libtool boost graphviz sudo easy_install pip sudo pip install ipython --user -sudo pip install numpy typing funcsigs subprocess32 protobuf colorama graphviz cloudpickle --ignore-installed six +sudo pip install numpy funcsigs subprocess32 protobuf colorama graphviz cloudpickle --ignore-installed six ``` ## Build diff --git a/doc/install-on-ubuntu.md b/doc/install-on-ubuntu.md index f98262ca7..19e831fee 100644 --- a/doc/install-on-ubuntu.md +++ b/doc/install-on-ubuntu.md @@ -15,7 +15,7 @@ First install the dependencies. We currently do not support Python 3. ``` sudo apt-get update sudo apt-get install -y git cmake build-essential autoconf curl libtool python-dev python-numpy python-pip libboost-all-dev unzip graphviz -sudo pip install ipython typing funcsigs subprocess32 protobuf colorama graphviz cloudpickle +sudo pip install ipython funcsigs subprocess32 protobuf colorama graphviz cloudpickle ``` ## Build diff --git a/docker/deploy/Dockerfile b/docker/deploy/Dockerfile index b58814553..5dd48fcbd 100644 --- a/docker/deploy/Dockerfile +++ b/docker/deploy/Dockerfile @@ -6,7 +6,7 @@ RUN apt-get update RUN apt-get -y install apt-utils RUN apt-get -y install sudo RUN apt-get install -y git cmake build-essential autoconf curl libtool python-dev python-numpy python-pip libboost-all-dev unzip graphviz -RUN pip install ipython typing funcsigs subprocess32 protobuf colorama graphviz cloudpickle +RUN pip install ipython funcsigs subprocess32 protobuf colorama graphviz cloudpickle RUN adduser --gecos --ingroup ray-user --disabled-login --gecos ray-user RUN adduser ray-user sudo RUN sed -i "s|%sudo\tALL=(ALL:ALL) ALL|%sudo\tALL=NOPASSWD: ALL|" /etc/sudoers diff --git a/docker/devel/Dockerfile b/docker/devel/Dockerfile index 35f979959..d2f35461a 100644 --- a/docker/devel/Dockerfile +++ b/docker/devel/Dockerfile @@ -6,7 +6,7 @@ RUN apt-get update RUN apt-get -y install apt-utils RUN apt-get -y install sudo RUN apt-get install -y git cmake build-essential autoconf curl libtool python-dev python-numpy python-pip libboost-all-dev unzip graphviz -RUN pip install ipython typing funcsigs subprocess32 protobuf colorama graphviz cloudpickle +RUN pip install ipython funcsigs subprocess32 protobuf colorama graphviz cloudpickle RUN adduser --gecos --ingroup ray-user --disabled-login --gecos ray-user --uid 500 RUN adduser ray-user sudo RUN sed -i "s|%sudo\tALL=(ALL:ALL) ALL|%sudo\tALL=NOPASSWD: ALL|" /etc/sudoers diff --git a/docker/test-base/Dockerfile b/docker/test-base/Dockerfile index f33a0cc34..66deac4b7 100644 --- a/docker/test-base/Dockerfile +++ b/docker/test-base/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get update RUN apt-get -y install apt-utils RUN apt-get -y install sudo RUN apt-get install -y git cmake build-essential autoconf curl libtool python-dev python-numpy python-pip libboost-all-dev unzip graphviz -RUN pip install ipython typing funcsigs subprocess32 protobuf colorama graphviz cloudpickle +RUN pip install ipython funcsigs subprocess32 protobuf colorama graphviz cloudpickle RUN adduser --gecos --ingroup ray-user --disabled-login --gecos ray-user RUN adduser ray-user sudo RUN sed -i "s|%sudo\tALL=(ALL:ALL) ALL|%sudo\tALL=NOPASSWD: ALL|" /etc/sudoers diff --git a/examples/alexnet/alexnet.py b/examples/alexnet/alexnet.py index f3de56044..8fa7a08bb 100644 --- a/examples/alexnet/alexnet.py +++ b/examples/alexnet/alexnet.py @@ -7,7 +7,6 @@ import tarfile, io import boto3 import PIL.Image as Image import tensorflow as tf -from typing import List, Tuple import ray.array.remote as ra diff --git a/install-dependencies.sh b/install-dependencies.sh index 52b213cab..be91454b7 100755 --- a/install-dependencies.sh +++ b/install-dependencies.sh @@ -31,11 +31,11 @@ if [[ $platform == "linux" ]]; then # These commands must be kept in sync with the installation instructions. sudo apt-get update sudo apt-get install -y git cmake build-essential autoconf curl libtool python-dev python-numpy python-pip libboost-all-dev unzip graphviz - sudo pip install ipython typing funcsigs subprocess32 protobuf colorama graphviz cloudpickle + sudo pip install ipython funcsigs subprocess32 protobuf colorama graphviz cloudpickle elif [[ $platform == "macosx" ]]; then # These commands must be kept in sync with the installation instructions. brew install git cmake automake autoconf libtool boost graphviz sudo easy_install pip sudo pip install ipython --user - sudo pip install numpy typing funcsigs subprocess32 protobuf colorama graphviz cloudpickle --ignore-installed six + sudo pip install numpy funcsigs subprocess32 protobuf colorama graphviz cloudpickle --ignore-installed six fi diff --git a/lib/python/ray/array/distributed/core.py b/lib/python/ray/array/distributed/core.py index e3347fad0..3938160ec 100644 --- a/lib/python/ray/array/distributed/core.py +++ b/lib/python/ray/array/distributed/core.py @@ -1,4 +1,3 @@ -from typing import List import numpy as np import ray.array.remote as ra import ray diff --git a/lib/python/ray/array/distributed/random.py b/lib/python/ray/array/distributed/random.py index 4c42fe433..4f905671e 100644 --- a/lib/python/ray/array/distributed/random.py +++ b/lib/python/ray/array/distributed/random.py @@ -1,5 +1,3 @@ -from typing import List - import numpy as np import ray.array.remote as ra import ray diff --git a/lib/python/ray/array/remote/core.py b/lib/python/ray/array/remote/core.py index bab484696..b96606780 100644 --- a/lib/python/ray/array/remote/core.py +++ b/lib/python/ray/array/remote/core.py @@ -1,4 +1,3 @@ -from typing import List, Any import numpy as np import ray diff --git a/lib/python/ray/array/remote/linalg.py b/lib/python/ray/array/remote/linalg.py index 92aea45f0..8cccf74da 100644 --- a/lib/python/ray/array/remote/linalg.py +++ b/lib/python/ray/array/remote/linalg.py @@ -1,4 +1,3 @@ -from typing import List import numpy as np import ray diff --git a/lib/python/ray/array/remote/random.py b/lib/python/ray/array/remote/random.py index 7aa5ddbd8..e86d321d1 100644 --- a/lib/python/ray/array/remote/random.py +++ b/lib/python/ray/array/remote/random.py @@ -1,4 +1,3 @@ -from typing import List import numpy as np import ray diff --git a/lib/python/ray/pickling.py b/lib/python/ray/pickling.py index 1cc5914c8..b0befa962 100644 --- a/lib/python/ray/pickling.py +++ b/lib/python/ray/pickling.py @@ -1,7 +1,6 @@ # Note that a little bit of code here is taken and slightly modified from the pickler because it was not possible to change its behavior otherwise. import sys -import typing from ctypes import c_void_p from cloudpickle import pickle, cloudpickle, CloudPickler, load, loads @@ -38,9 +37,6 @@ def _fill_function(func, globals, defaults, closure, dict): pythonapi.PyCell_Set(c_void_p(id(result.__closure__[i])), c_void_p(id(v))) return result -def _create_type(type_repr): - return eval(type_repr.replace("~", ""), None, (lambda d: d.setdefault("typing", typing) and None or d)(dict(typing.__dict__))) - class BetterPickler(CloudPickler): def save_function_tuple(self, func): code, f_globals, defaults, closure, dct, base_globals = self.extract_func_data(func) @@ -63,10 +59,5 @@ class BetterPickler(CloudPickler): self.save(cloudpickle._make_cell) self.save((obj.cell_contents,)) self.write(pickle.REDUCE) - def save_type(self, obj): - self.save(_create_type) - self.save((repr(obj),)) - self.write(pickle.REDUCE) dispatch = CloudPickler.dispatch.copy() dispatch[(lambda _: lambda: _)(0).__closure__[0].__class__] = save_cell - # dispatch[typing.GenericMeta] = save_type diff --git a/lib/python/ray/worker.py b/lib/python/ray/worker.py index ba27ee3b6..2ad41bcf5 100644 --- a/lib/python/ray/worker.py +++ b/lib/python/ray/worker.py @@ -4,7 +4,6 @@ import time import traceback import copy import logging -import typing import funcsigs import numpy as np import colorama @@ -192,13 +191,13 @@ class Reusable(object): def __init__(self, initializer, reinitializer=None): """Initialize a Reusable object.""" - if not isinstance(initializer, typing.Callable): + if not callable(initializer): raise Exception("When creating a RayReusable, initializer must be a function.") self.initializer = initializer if reinitializer is None: # If no reinitializer is passed in, use a wrapped version of the initializer. reinitializer = lambda value: initializer() - if not isinstance(reinitializer, typing.Callable): + if not callable(reinitializer): raise Exception("When creating a RayReusable, reinitializer must be a function.") self.reinitializer = reinitializer