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

Function client_mode_convert_function

python/ray/_private/client_mode_hook.py:153–171  ·  view source on GitHub ↗

Runs a preregistered ray RemoteFunction through the ray client. The common case for this is to transparently convert that RemoteFunction to a ClientRemoteFunction. This happens in circumstances where the RemoteFunction is declared early, in a library and only then is Ray used in cli

(func_cls, in_args, in_kwargs, **kwargs)

Source from the content-addressed store, hash-verified

151
152
153def client_mode_convert_function(func_cls, in_args, in_kwargs, **kwargs):
154 """Runs a preregistered ray RemoteFunction through the ray client.
155
156 The common case for this is to transparently convert that RemoteFunction
157 to a ClientRemoteFunction. This happens in circumstances where the
158 RemoteFunction is declared early, in a library and only then is Ray used in
159 client mode -- necessitating a conversion.
160 """
161 from ray.util.client import ray
162
163 key = getattr(func_cls, RAY_CLIENT_MODE_ATTR, None)
164
165 # Second part of "or" is needed in case func_cls is reused between Ray
166 # client sessions in one Python interpreter session.
167 if (key is None) or (not ray._converted_key_exists(key)):
168 key = ray._convert_function(func_cls)
169 setattr(func_cls, RAY_CLIENT_MODE_ATTR, key)
170 client_func = ray._get_converted(key)
171 return client_func._remote(in_args, in_kwargs, **kwargs)
172
173
174def client_mode_convert_actor(actor_cls, in_args, in_kwargs, **kwargs):

Callers 1

_remoteMethod · 0.90

Calls 4

_converted_key_existsMethod · 0.45
_convert_functionMethod · 0.45
_get_convertedMethod · 0.45
_remoteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…