[Core] The *args **kwargs parameters of the __new__ method are missing during actor initialization.
What happened + What you expected to happen
*args and **kwargs parameters in __new__ of an actor always empty, it seems that the parameters are being ignored by Ray.
See: https://github.com/ray-project/ray/blob/master/python/ray/_raylet.pyx#L2068
Versions / Dependencies
This issue exists in all versions.
Reproduction script
import ray
ray.init()
@ray.remote
class TestWorker:
def __init__(self, *args, **kwargs):
print(f'This is __init__ {args} {kwargs}')
def __new__(cls, *args, **kwargs):
print(f'This is __new__ {args}, {kwargs}')
return super().__new__(cls)
def foo(self):
return 10000
worker = TestWorker.remote(100)
print(ray.get(worker.foo.remote()))
We got:
python3.9 ./mytest/test_new.py
2024-02-20 16:21:53,693 INFO worker.py:1652 -- Started a local Ray instance. View the dashboard at 127.0.0.1:8265
This is __new__ (), {}
(pid=28948) This is __new__ (), {}
10000
(TestWorker pid=28948) This is init (100,) {}
Issue Severity
High: It blocks me from completing my task.
@rkooo567 Could you help triage this issue?
@MissiontoMars do you mind creating a PR to fix it?
@MissiontoMars do you mind creating a PR to fix it?
OK, i will try to fix it.