(cls)
| 2646 | |
| 2647 | |
| 2648 | def _modify_class(cls): |
| 2649 | # cls has been modified. |
| 2650 | if hasattr(cls, "__ray_actor_class__"): |
| 2651 | return cls |
| 2652 | |
| 2653 | # Modify the class to have additional default methods. |
| 2654 | class Class(cls): |
| 2655 | __ray_actor_class__ = cls # The original actor class |
| 2656 | |
| 2657 | def __ray_ready__(self): |
| 2658 | return True |
| 2659 | |
| 2660 | def __ray_call__(self, fn, *args, **kwargs): |
| 2661 | return fn(self, *args, **kwargs) |
| 2662 | |
| 2663 | def __ray_terminate__(self): |
| 2664 | ray.actor.exit_actor() |
| 2665 | |
| 2666 | Class.__module__ = cls.__module__ |
| 2667 | Class.__name__ = cls.__name__ |
| 2668 | |
| 2669 | if not is_function_or_method(getattr(Class, "__init__", None)): |
| 2670 | # Add __init__ if it does not exist. |
| 2671 | # Actor creation will be executed with __init__ together. |
| 2672 | |
| 2673 | # Assign an __init__ function will avoid many checks later on. |
| 2674 | def __init__(self): |
| 2675 | pass |
| 2676 | |
| 2677 | Class.__init__ = __init__ |
| 2678 | |
| 2679 | return Class |
| 2680 | |
| 2681 | |
| 2682 | def _make_actor(cls, actor_options): |
no test coverage detected
searching dependent graphs…