mirror of
https://github.com/wassname/ray.git
synced 2026-07-03 18:57:46 +08:00
Add ray.is_initialized() function. (#2818)
* Add ray.is_initialized() function. * Add assert.
This commit is contained in:
committed by
Philipp Moritz
parent
e7db54bdb0
commit
3f6ed537a4
@@ -50,7 +50,8 @@ from ray.local_scheduler import ObjectID, _config # noqa: E402
|
||||
from ray.profiling import profile # noqa: E402
|
||||
from ray.worker import (error_info, init, connect, disconnect, get, put, wait,
|
||||
remote, get_gpu_ids, get_resource_ids, get_webui_url,
|
||||
register_custom_serializer, shutdown) # noqa: E402
|
||||
register_custom_serializer, shutdown,
|
||||
is_initialized) # noqa: E402
|
||||
from ray.worker import (SCRIPT_MODE, WORKER_MODE, LOCAL_MODE,
|
||||
PYTHON_MODE) # noqa: E402
|
||||
from ray.worker import global_state # noqa: E402
|
||||
@@ -67,9 +68,10 @@ __version__ = "0.5.2"
|
||||
__all__ = [
|
||||
"error_info", "init", "connect", "disconnect", "get", "put", "wait",
|
||||
"remote", "profile", "actor", "method", "get_gpu_ids", "get_resource_ids",
|
||||
"get_webui_url", "register_custom_serializer", "shutdown", "SCRIPT_MODE",
|
||||
"WORKER_MODE", "LOCAL_MODE", "PYTHON_MODE", "global_state", "ObjectID",
|
||||
"_config", "__version__", "internal"
|
||||
"get_webui_url", "register_custom_serializer", "shutdown",
|
||||
"is_initialized", "SCRIPT_MODE", "WORKER_MODE", "LOCAL_MODE",
|
||||
"PYTHON_MODE", "global_state", "ObjectID", "_config", "__version__",
|
||||
"internal"
|
||||
]
|
||||
|
||||
import ctypes # noqa: E402
|
||||
|
||||
@@ -1987,6 +1987,15 @@ def print_error_messages_raylet(worker):
|
||||
pass
|
||||
|
||||
|
||||
def is_initialized():
|
||||
"""Check if ray.init has been called yet.
|
||||
|
||||
Returns:
|
||||
True if ray.init has already been called and false otherwise.
|
||||
"""
|
||||
return ray.worker.global_worker.connected
|
||||
|
||||
|
||||
def print_error_messages(worker):
|
||||
"""Print error messages in the background on the driver.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user