mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 23:23:15 +08:00
Remove typing module.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
from typing import List
|
||||
import numpy as np
|
||||
import ray.array.remote as ra
|
||||
import ray
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from typing import List
|
||||
|
||||
import numpy as np
|
||||
import ray.array.remote as ra
|
||||
import ray
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from typing import List, Any
|
||||
import numpy as np
|
||||
import ray
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from typing import List
|
||||
import numpy as np
|
||||
import ray
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from typing import List
|
||||
import numpy as np
|
||||
import ray
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user