Skip to content

[Core] classmethod support for actors #36986

@Darkdragon84

Description

@Darkdragon84

Description

Please support calls to classmethods of actors. Currently this

import ray


class Foo:
    def __init__(self, x):
        self.x = x

    def run(self):
        pass

    @classmethod
    def main(cls, x):
        main_instance = cls(x)
        return main_instance.run()


@ray.remote
class Bar(Foo):
    def run(self):
        return self.x

ray.init()
x = ray.get(Bar.main.remote(1))
print(x)

fails with

Traceback (most recent call last):
  File "...", line 23, in <module>
    x = ray.get(Bar.main.remote(1))
AttributeError: 'function' object has no attribute 'remote'

I would expect to see the output

1

Use case

classmethods are useful concepts and are used all over the place. For example, they are a great way to overload the __init__ by implementing several from_<whatever>(data: whatever) classmethods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Issue that should be fixed within a few weekscoreIssues that should be addressed in Ray Corecore-apienhancementRequest for new feature and/or capability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions