mirror of
https://github.com/wassname/ray.git
synced 2026-07-02 19:05:42 +08:00
Move function/actor exporting & loading code to function_manager.py (#3003)
Move function/actor exporting & loading code to function_manager.py to prepare the code change for function descriptor for python.
This commit is contained in:
committed by
Robert Nishihara
parent
d73ee36e60
commit
9948e8c11b
@@ -5,6 +5,7 @@ from __future__ import print_function
|
||||
import binascii
|
||||
import functools
|
||||
import hashlib
|
||||
import inspect
|
||||
import numpy as np
|
||||
import os
|
||||
import subprocess
|
||||
@@ -144,6 +145,23 @@ def is_cython(obj):
|
||||
(hasattr(obj, "__func__") and check_cython(obj.__func__))
|
||||
|
||||
|
||||
def is_function_or_method(obj):
|
||||
"""Check if an object is a function or method.
|
||||
|
||||
Args:
|
||||
obj: The Python object in question.
|
||||
|
||||
Returns:
|
||||
True if the object is an function or method.
|
||||
"""
|
||||
return (inspect.isfunction(obj) or inspect.ismethod(obj) or is_cython(obj))
|
||||
|
||||
|
||||
def is_class_method(f):
|
||||
"""Returns whether the given method is a class_method."""
|
||||
return hasattr(f, "__self__") and f.__self__ is not None
|
||||
|
||||
|
||||
def random_string():
|
||||
"""Generate a random string to use as an ID.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user