Add basic functionality for Cython functions and actors (#1193)

* Add basic functionality for Cython functions and actors

* Fix up per @pcmoritz comments

* Fixes per @richardliaw comments

* Fixes per @robertnishihara comments

* Forgot double quotes when updating masked_log

* Remove import typing for Python 2 compatibility
This commit is contained in:
Daniel Suo
2017-11-09 20:49:06 -05:00
committed by Philipp Moritz
parent 11f8f8bd8c
commit 4f0da6f81c
16 changed files with 1047 additions and 13 deletions
+15
View File
@@ -12,6 +12,21 @@ import sys
import ray.local_scheduler
def is_cython(obj):
"""Check if an object is a Cython function or method"""
# TODO(suo): We could split these into two functions, one for Cython
# functions and another for Cython methods.
# TODO(suo): There doesn't appear to be a Cython function 'type' we can
# check against via isinstance. Please correct me if I'm wrong.
def check_cython(x):
return type(x).__name__ == "cython_function_or_method"
# Check if function or method, respectively
return check_cython(obj) or \
(hasattr(obj, "__func__") and check_cython(obj.__func__))
def random_string():
"""Generate a random string to use as an ID.