Cythonize ray actor class



我正在使用Ray库,然后我想Cythonize我的包。虽然有一个如何适应常规远程功能的参考

some_cython_func = ray.remote(some_cython_module.some_cython_func)

不清楚如何处理光线Actor(类级别的装饰器)

@ray.remote
class MyService:
def __init__(self):
pass
def run(self):
...
def helper(self):
...

经过cythonized后,此代码产生如下错误

File "/Users/user/anaconda3/envs/ray-test/lib/python3.7/site-packages/ray/actor.py", line 538, in _remote
meta.method_meta.methods.keys())
File "/Users/user/anaconda3/envs/ray-test/lib/python3.7/site-packages/ray/function_manager.py", line 358, in export_actor_class
"class": pickle.dumps(Class),
File "/Users/user/anaconda3/envs/ray-test/lib/python3.7/site-packages/ray/cloudpickle/cloudpickle_fast.py", line 70, in dumps
cp.dump(obj)
File "/Users/user/anaconda3/envs/ray-test/lib/python3.7/site-packages/ray/cloudpickle/cloudpickle_fast.py", line 656, in dump
return Pickler.dump(self, obj)
_pickle.PicklingError: Can't pickle <cyfunction MyService.__init__ at 0x7fc230367c80>: it's not the same object as app.my_service.__init__

如何重写/适应现有的工作射线代码与Cython一起工作?

Python 3.7.9/ray==0.8.6

是的,似乎是一个简单的解决方案

MyService = ray.remote(_MyService)

工作正常

指向Ray源代码

相关内容

  • 没有找到相关文章

最新更新