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

Method _init_args

python/ray/client_builder.py:205–260  ·  view source on GitHub ↗

When a client builder is constructed through ray.init, for example `ray.init(ray://..., namespace=...)`, all of the arguments passed into ray.init with non-default values are passed again into this method. Custom client builders can override this method to do

(self, **kwargs)

Source from the content-addressed store, hash-verified

203 self.env(json.loads(runtime_env_var))
204
205 def _init_args(self, **kwargs) -> "ClientBuilder":
206 """
207 When a client builder is constructed through ray.init, for example
208 `ray.init(ray://..., namespace=...)`, all of the
209 arguments passed into ray.init with non-default values are passed
210 again into this method. Custom client builders can override this method
211 to do their own handling/validation of arguments.
212 """
213 # Use namespace and runtime_env from ray.init call
214 if kwargs.get("namespace") is not None:
215 self.namespace(kwargs["namespace"])
216 del kwargs["namespace"]
217 if kwargs.get("runtime_env") is not None:
218 self.env(kwargs["runtime_env"])
219 del kwargs["runtime_env"]
220
221 # Put logging_config on JobConfig so remote workers receive it via the job config
222 if kwargs.get("logging_config") is not None:
223 lc_raw = kwargs.pop("logging_config")
224 if isinstance(lc_raw, dict):
225 lc = LoggingConfig.from_dict(lc_raw)
226 elif isinstance(lc_raw, LoggingConfig):
227 lc = lc_raw
228 else:
229 raise TypeError(
230 "logging_config must be a dict or LoggingConfig, "
231 f"got {type(lc_raw)}"
232 )
233 self._job_config.set_py_logging_config(lc)
234
235 if kwargs.get("allow_multiple") is True:
236 self._allow_multiple_connections = True
237 del kwargs["allow_multiple"]
238
239 if "_credentials" in kwargs.keys():
240 self._credentials = kwargs["_credentials"]
241 del kwargs["_credentials"]
242
243 if "_metadata" in kwargs.keys():
244 self._metadata = kwargs["_metadata"]
245 del kwargs["_metadata"]
246
247 if kwargs:
248 expected_sig = inspect.signature(ray_driver_init)
249 extra_args = set(kwargs.keys()).difference(expected_sig.parameters.keys())
250 if len(extra_args) > 0:
251 raise RuntimeError(
252 "Got unexpected kwargs: {}".format(", ".join(extra_args))
253 )
254 self._remote_init_kwargs = kwargs
255 unknown = ", ".join(kwargs)
256 logger.info(
257 "Passing the following kwargs to ray.init() "
258 f"on the server: {unknown}"
259 )
260 return self
261
262 def _client_deprecation_warn(self) -> None:

Callers 1

initFunction · 0.80

Calls 10

namespaceMethod · 0.95
envMethod · 0.95
set_py_logging_configMethod · 0.80
getMethod · 0.65
popMethod · 0.45
from_dictMethod · 0.45
keysMethod · 0.45
formatMethod · 0.45
joinMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected