MCPcopy Index your code
hub / github.com/ray-project/ray / _modify_class

Function _modify_class

python/ray/actor.py:2648–2679  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

2646
2647
2648def _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
2682def _make_actor(cls, actor_options):

Callers 1

_make_actorFunction · 0.85

Calls 1

is_function_or_methodFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…