__init__.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. from typing import List
  2. import ray
  3. from ray._private.auto_init_hook import wrap_auto_init
  4. from ray._private.client_mode_hook import client_mode_hook
  5. from ray._private.services import get_node_instance_id, get_node_ip_address
  6. from ray.util import accelerators, debugpy as ray_debugpy, iter, rpdb as pdb
  7. from ray.util.actor_pool import ActorPool
  8. from ray.util.annotations import PublicAPI
  9. from ray.util.check_serialize import inspect_serializability
  10. from ray.util.client_connect import connect, disconnect
  11. from ray.util.debug import disable_log_once_globally, enable_periodic_logging, log_once
  12. from ray.util.helpers import as_completed, map_unordered
  13. from ray.util.placement_group import (
  14. get_current_placement_group,
  15. get_placement_group,
  16. placement_group,
  17. placement_group_table,
  18. remove_placement_group,
  19. )
  20. from ray.util.serialization import deregister_serializer, register_serializer
  21. @PublicAPI(stability="beta")
  22. @wrap_auto_init
  23. @client_mode_hook
  24. def list_named_actors(all_namespaces: bool = False) -> List[str]:
  25. """List all named actors in the system.
  26. Actors must have been created with Actor.options(name="name").remote().
  27. This works for both detached & non-detached actors.
  28. By default, only actors in the current namespace will be returned
  29. and the returned entries will simply be their name.
  30. If `all_namespaces` is set to True, all actors in the cluster will be
  31. returned regardless of namespace, and the returned entries will be of the
  32. form {"namespace": namespace, "name": name}.
  33. """
  34. worker = ray._private.worker.global_worker
  35. worker.check_connected()
  36. actors = worker.core_worker.list_named_actors(all_namespaces)
  37. if all_namespaces:
  38. return [{"name": name, "namespace": namespace} for namespace, name in actors]
  39. else:
  40. return [name for _, name in actors]
  41. __all__ = [
  42. "accelerators",
  43. "ActorPool",
  44. "as_completed",
  45. "disable_log_once_globally",
  46. "enable_periodic_logging",
  47. "iter",
  48. "log_once",
  49. "pdb",
  50. "placement_group",
  51. "placement_group_table",
  52. "get_placement_group",
  53. "get_current_placement_group",
  54. "get_node_instance_id",
  55. "get_node_ip_address",
  56. "map_unordered",
  57. "remove_placement_group",
  58. "ray_debugpy",
  59. "inspect_serializability",
  60. "collective",
  61. "connect",
  62. "disconnect",
  63. "register_serializer",
  64. "deregister_serializer",
  65. "list_named_actors",
  66. ]