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

Function init

python/ray/_private/worker.py:1438–2059  ·  view source on GitHub ↗

Connect to an existing Ray cluster or start one and connect to it. This method handles two cases; either a Ray cluster already exists and we just attach this driver to it or we start all of the processes associated with a Ray cluster and attach to the newly started cluster. Not

(
    address: Optional[str] = None,
    *,
    num_cpus: Optional[int] = None,
    num_gpus: Optional[int] = None,
    resources: Optional[Dict[str, float]] = None,
    labels: Optional[Dict[str, str]] = None,
    object_store_memory: Optional[int] = None,
    local_mode: bool = False,
    ignore_reinit_error: bool = False,
    include_dashboard: Optional[bool] = None,
    dashboard_host: str = get_localhost_ip(),
    dashboard_port: Optional[int] = None,
    job_config: "ray.job_config.JobConfig" = None,
    configure_logging: bool = True,
    logging_level: int = ray_constants.LOGGER_LEVEL,
    logging_format: Optional[str] = None,
    logging_config: Optional[LoggingConfig] = None,
    log_to_driver: Optional[bool] = None,
    namespace: Optional[str] = None,
    runtime_env: Optional[Union[Dict[str, Any], "RuntimeEnv"]] = None,  # noqa: F821
    enable_resource_isolation: bool = False,
    cgroup_path: Optional[str] = None,
    system_reserved_cpu: Optional[float] = None,
    system_reserved_memory: Optional[int] = None,
    proxy_server_url: Optional[str] = None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

1436@PublicAPI
1437@client_mode_hook
1438def init(
1439 address: Optional[str] = None,
1440 *,
1441 num_cpus: Optional[int] = None,
1442 num_gpus: Optional[int] = None,
1443 resources: Optional[Dict[str, float]] = None,
1444 labels: Optional[Dict[str, str]] = None,
1445 object_store_memory: Optional[int] = None,
1446 local_mode: bool = False,
1447 ignore_reinit_error: bool = False,
1448 include_dashboard: Optional[bool] = None,
1449 dashboard_host: str = get_localhost_ip(),
1450 dashboard_port: Optional[int] = None,
1451 job_config: "ray.job_config.JobConfig" = None,
1452 configure_logging: bool = True,
1453 logging_level: int = ray_constants.LOGGER_LEVEL,
1454 logging_format: Optional[str] = None,
1455 logging_config: Optional[LoggingConfig] = None,
1456 log_to_driver: Optional[bool] = None,
1457 namespace: Optional[str] = None,
1458 runtime_env: Optional[Union[Dict[str, Any], "RuntimeEnv"]] = None, # noqa: F821
1459 enable_resource_isolation: bool = False,
1460 cgroup_path: Optional[str] = None,
1461 system_reserved_cpu: Optional[float] = None,
1462 system_reserved_memory: Optional[int] = None,
1463 proxy_server_url: Optional[str] = None,
1464 **kwargs,
1465) -> BaseContext:
1466 """
1467 Connect to an existing Ray cluster or start one and connect to it.
1468
1469 This method handles two cases; either a Ray cluster already exists and we
1470 just attach this driver to it or we start all of the processes associated
1471 with a Ray cluster and attach to the newly started cluster.
1472 Note: This method overwrite sigterm handler of the driver process.
1473
1474 In most cases, it is enough to just call this method with no arguments.
1475 This will autodetect an existing Ray cluster or start a new Ray instance if
1476 no existing cluster is found:
1477
1478 .. testcode::
1479
1480 ray.init()
1481
1482 To explicitly connect to an existing local cluster, use this as follows. A
1483 ConnectionError will be thrown if no existing local cluster is found.
1484
1485 .. testcode::
1486 :skipif: True
1487
1488 ray.init(address="auto")
1489
1490 To connect to an existing remote cluster, use this as follows (substituting
1491 in the appropriate address). Note the addition of "ray://" at the beginning
1492 of the address. This requires `ray[client]`.
1493
1494 .. testcode::
1495 :skipif: True

Callers 1

Calls 15

set_runtime_envMethod · 0.95
set_metadataMethod · 0.95
set_py_logging_configMethod · 0.95
setup_loggerFunction · 0.90
LoggingConfigClass · 0.90
get_ray_doc_versionFunction · 0.90
_merge_runtime_envFunction · 0.90
hookFunction · 0.90
RayContextClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…