deisa.ray.utils module¶
- deisa.ray.utils.get_head_actor_options() dict[source]¶
Return the options that should be used to start the head actor.
- Returns:
Dictionary of Ray actor options including: - name: “simulation_head” - namespace: “deisa_ray” - scheduling_strategy: NodeAffinitySchedulingStrategy for the head node - max_concurrency: Very high value to prevent blocking - lifetime: “detached” to persist beyond function scope - enable_task_events: False for performance
- Return type:
dict
Notes
The head actor is scheduled on the head node with a detached lifetime to ensure it persists. High concurrency is set to prevent the actor from being blocked when gathering many references.
- deisa.ray.utils.get_head_node_id() str[source]¶
Get the node ID of the Ray cluster head node.
- Returns:
The node ID of the head node.
- Return type:
str
- Raises:
AssertionError – If there is not exactly one head node in the cluster.
Notes
This function queries Ray’s state API to find the head node. It assumes there is exactly one head node in the cluster.
- deisa.ray.utils.get_ready_actor_with_retry(name, namespace, deadline_s=180)[source]¶
Get a Ray actor by name with retry logic and readiness check.
This function attempts to retrieve a Ray actor by name and namespace, checking that it is ready before returning. It implements exponential backoff retry logic with a deadline.
- Parameters:
name (str) – The name of the actor to retrieve.
namespace (str) – The namespace of the actor.
deadline_s (float, optional) – Maximum time in seconds to wait for the actor to become available. Default is 180.
- Returns:
The handle to the ready actor.
- Return type:
RayActorHandle
- Raises:
TimeoutError – If the actor is not found or not ready within the deadline.
Notes
The function uses exponential backoff with jitter for retries. The delay starts at 0.2 seconds and increases by a factor of 1.5 up to a maximum of 5.0 seconds. A small random jitter (0-0.1 seconds) is added to avoid thundering herd problems.