MCPcopy
hub / github.com/ray-project/ray / _bind

Method _bind

python/ray/actor.py:944–1020  ·  view source on GitHub ↗
(
        self,
        args=None,
        kwargs=None,
        name="",
        num_returns=None,
        concurrency_group=None,
        _generator_backpressure_num_objects=None,
    )

Source from the content-addressed store, hash-verified

942 @wrap_auto_init
943 @_tracing_actor_method_invocation
944 def _bind(
945 self,
946 args=None,
947 kwargs=None,
948 name="",
949 num_returns=None,
950 concurrency_group=None,
951 _generator_backpressure_num_objects=None,
952 ) -> Union["ray.dag.ClassMethodNode", Tuple["ray.dag.ClassMethodNode", ...]]:
953 from ray.dag.class_node import (
954 BIND_INDEX_KEY,
955 IS_CLASS_METHOD_OUTPUT_KEY,
956 PARENT_CLASS_NODE_KEY,
957 PREV_CLASS_METHOD_CALL_KEY,
958 ClassMethodNode,
959 )
960
961 # TODO(sang): unify option passing
962 options = {
963 "name": name,
964 "num_returns": num_returns,
965 "concurrency_group": concurrency_group,
966 "_generator_backpressure_num_objects": _generator_backpressure_num_objects,
967 }
968
969 actor = self._actor
970 if actor is None:
971 # Ref is GC'ed. It happens when the actor handle is GC'ed
972 # when bind is called.
973 raise RuntimeError("Lost reference to actor")
974
975 other_args_to_resolve = {
976 PARENT_CLASS_NODE_KEY: actor,
977 PREV_CLASS_METHOD_CALL_KEY: None,
978 BIND_INDEX_KEY: actor._ray_dag_bind_index,
979 }
980 actor._ray_dag_bind_index += 1
981
982 assert (
983 self._signature is not None
984 ), "self._signature should be set for .bind API."
985 try:
986 signature.validate_args(self._signature, args, kwargs)
987 except TypeError as e:
988 signature_copy = self._signature.copy()
989 if len(signature_copy) > 0 and signature_copy[-1].name == "_ray_trace_ctx":
990 # Remove the trace context arg for readability.
991 signature_copy.pop(-1)
992 signature_copy = inspect.Signature(parameters=signature_copy)
993 raise TypeError(
994 f"{str(e)}. The function `{self._method_name}` has a signature "
995 f"`{signature_copy}`, but the given arguments to `bind` doesn't "
996 f"match. args: {args}. kwargs: {kwargs}."
997 ) from None
998
999 node = ClassMethodNode(
1000 self._method_name,
1001 args,

Callers 2

bindMethod · 0.95
bindMethod · 0.45

Calls 5

ClassMethodNodeClass · 0.90
copyMethod · 0.65
rangeFunction · 0.50
popMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected