Remove six and cloudpickle from setup.py. (#7694)

This commit is contained in:
Robert Nishihara
2020-03-23 11:42:05 -07:00
committed by GitHub
parent 1a0c9228d0
commit ee8c9ff732
15 changed files with 20 additions and 67 deletions
@@ -1,8 +1,6 @@
# This file is used by CrossLanguageInvocationTest.java to test cross-language
# invocation.
import six
import ray
@@ -63,4 +61,4 @@ class Counter(object):
def increase(self, delta):
self.value += int(delta)
return str(self.value).encode("utf-8") if six.PY3 else str(self.value)
return str(self.value).encode("utf-8")
+1 -2
View File
@@ -1,7 +1,6 @@
import copy
import inspect
import logging
import six
import weakref
from abc import ABCMeta, abstractmethod
@@ -963,7 +962,7 @@ Checkpoint = namedtuple(
"""A namedtuple that represents a checkpoint."""
class Checkpointable(six.with_metaclass(ABCMeta, object)):
class Checkpointable(metaclass=ABCMeta):
"""An interface that indicates an actor can be checkpointed."""
@abstractmethod
-5
View File
@@ -3,7 +3,6 @@ from concurrent.futures import ThreadPoolExecutor
import json
import logging
import random
import six
import sys
import threading
import time
@@ -365,10 +364,6 @@ def test_illegal_api_calls(ray_start_regular):
ray.get(3)
# TODO(hchen): This test currently doesn't work in Python 2. This is likely
# because plasma client isn't thread-safe. This needs to be fixed from the
# Arrow side. See #4107 for relevant discussions.
@pytest.mark.skipif(six.PY2, reason="Doesn't work in Python 2.")
def test_multithreading(ray_start_2_cpus):
# This test requires at least 2 CPUs to finish since the worker does not
# release resources when joining the threads.
@@ -8,7 +8,7 @@ from ray import tune
from ray.tune import DurableTrainable
from ray.tune.sync_client import get_sync_client
import cloudpickle
from ray import cloudpickle
logger = logging.getLogger(__name__)
+1 -2
View File
@@ -1,7 +1,6 @@
import copy
import logging
import os
import six
from ray.tune.error import TuneError
from ray.tune.registry import register_trainable, get_trainable_cls
@@ -189,7 +188,7 @@ class Experiment:
A string representing the trainable identifier.
"""
if isinstance(run_object, six.string_types):
if isinstance(run_object, str):
return run_object
elif isinstance(run_object, sample_from):
logger.warning("Not registering trainable. Resolving as variant.")
+1 -2
View File
@@ -1,5 +1,4 @@
import logging
import six
from ray.tune.error import TuneError
from ray.tune.experiment import convert_to_experiment_list, Experiment
@@ -41,7 +40,7 @@ def _make_scheduler(args):
def _check_default_resources_override(run_identifier):
if not isinstance(run_identifier, six.string_types):
if not isinstance(run_identifier, str):
# If obscure dtype, assume it is overriden.
return True
trainable_cls = get_trainable_cls(run_identifier)
+4 -23
View File
@@ -5,7 +5,6 @@ import inspect
import logging
import numpy as np
import os
import six
import subprocess
import sys
import tempfile
@@ -223,32 +222,14 @@ def decode(byte_str, allow_none=False):
def ensure_str(s, encoding="utf-8", errors="strict"):
"""Coerce *s* to `str`.
To keep six with lower version, see Issue 4169, we copy this function
from six == 1.12.0.
TODO(yuhguo): remove this function when six >= 1.12.0.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
"""
if six.PY3:
text_type = str
binary_type = bytes
if isinstance(s, str):
return s
else:
text_type = unicode # noqa: F821
binary_type = str
if not isinstance(s, (text_type, binary_type)):
raise TypeError("not expecting type '%s'" % type(s))
if six.PY2 and isinstance(s, text_type):
s = s.encode(encoding, errors)
elif six.PY3 and isinstance(s, binary_type):
s = s.decode(encoding, errors)
return s
assert isinstance(s, bytes)
return s.decode(encoding, errors)
def binary_to_object_id(binary_object_id):
+3 -18
View File
@@ -171,24 +171,9 @@ def find_version(*filepath):
requires = [
"numpy >= 1.16",
"filelock",
"jsonschema",
"click",
"colorama",
"packaging",
"pyyaml",
"redis>=3.3.2",
# NOTE: Don't upgrade the version of six! Doing so causes installation
# problems. See https://github.com/ray-project/ray/issues/4169.
"six >= 1.0.0",
"faulthandler;python_version<'3.3'",
"protobuf >= 3.8.0",
"cloudpickle",
"py-spy >= 0.2.0",
"aiohttp",
"google",
"grpcio"
"numpy >= 1.16", "filelock", "jsonschema", "click", "colorama",
"packaging", "pyyaml", "redis >= 3.3.2", "protobuf >= 3.8.0",
"py-spy >= 0.2.0", "aiohttp", "google", "grpcio"
]
setup(
+1 -2
View File
@@ -4,7 +4,6 @@ import logging
import math
import os
import pickle
import six
import time
import tempfile
@@ -1022,7 +1021,7 @@ class Trainer(Trainable):
self.optimizer.restore(state["optimizer"])
def _register_if_needed(self, env_object):
if isinstance(env_object, six.string_types):
if isinstance(env_object, str):
return env_object
elif isinstance(env_object, type):
name = env_object.__name__
+1 -1
View File
@@ -1,5 +1,5 @@
import logging
import six.moves.queue as queue
import queue
import threading
import traceback
+1 -1
View File
@@ -1,7 +1,7 @@
from collections import defaultdict, namedtuple
import logging
import numpy as np
import six.moves.queue as queue
import queue
import threading
import time
+2 -3
View File
@@ -3,8 +3,7 @@ import json
import logging
import os
import random
import six
from six.moves.urllib.parse import urlparse
from urllib.parse import urlparse
try:
from smart_open import smart_open
@@ -39,7 +38,7 @@ class JsonReader(InputReader):
"""
self.ioctx = ioctx or IOContext()
if isinstance(inputs, six.string_types):
if isinstance(inputs, str):
inputs = os.path.abspath(os.path.expanduser(inputs))
if os.path.isdir(inputs):
inputs = os.path.join(inputs, "*.json")
+1 -2
View File
@@ -1,4 +1,3 @@
import six
import collections
import numpy as np
@@ -49,7 +48,7 @@ class SampleBatch:
self.data = dict(*args, **kwargs)
lengths = []
for k, v in self.data.copy().items():
assert isinstance(k, six.string_types), self
assert isinstance(k, str), self
lengths.append(len(v))
self.data[k] = np.array(v, copy=False)
if not lengths:
+1 -1
View File
@@ -4,7 +4,7 @@ import sys
from abc import ABC, abstractmethod
import typing
import cloudpickle
from ray import cloudpickle
from ray.streaming.runtime import gateway_client
+1 -1
View File
@@ -1,7 +1,7 @@
import importlib
from abc import ABC, abstractmethod
import cloudpickle
from ray import cloudpickle
from ray.streaming.runtime import gateway_client