mirror of
https://github.com/wassname/ray.git
synced 2026-07-14 11:17:54 +08:00
[core worker] Python core worker object interface (#5272)
This commit is contained in:
@@ -15,7 +15,6 @@ except ImportError:
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
from pyarrow import plasma
|
||||
|
||||
import ray
|
||||
import ray.ray_constants as ray_constants
|
||||
@@ -41,8 +40,8 @@ def ray_checkpointable_actor_cls(request):
|
||||
self.resumed_from_checkpoint = False
|
||||
self.checkpoint_dir = checkpoint_dir
|
||||
|
||||
def local_plasma(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
def node_id(self):
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
def increase(self):
|
||||
self.value += 1
|
||||
@@ -904,7 +903,7 @@ def test_actor_load_balancing(ray_start_cluster):
|
||||
pass
|
||||
|
||||
def get_location(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
# Create a bunch of actors.
|
||||
num_actors = 30
|
||||
@@ -972,7 +971,7 @@ def test_actor_gpus(ray_start_cluster):
|
||||
|
||||
def get_location_and_ids(self):
|
||||
assert ray.get_gpu_ids() == self.gpu_ids
|
||||
return (ray.worker.global_worker.plasma_client.store_socket_name,
|
||||
return (ray.worker.global_worker.node.unique_id,
|
||||
tuple(self.gpu_ids))
|
||||
|
||||
# Create one actor per GPU.
|
||||
@@ -1011,7 +1010,7 @@ def test_actor_multiple_gpus(ray_start_cluster):
|
||||
|
||||
def get_location_and_ids(self):
|
||||
assert ray.get_gpu_ids() == self.gpu_ids
|
||||
return (ray.worker.global_worker.plasma_client.store_socket_name,
|
||||
return (ray.worker.global_worker.node.unique_id,
|
||||
tuple(self.gpu_ids))
|
||||
|
||||
# Create some actors.
|
||||
@@ -1042,7 +1041,7 @@ def test_actor_multiple_gpus(ray_start_cluster):
|
||||
self.gpu_ids = ray.get_gpu_ids()
|
||||
|
||||
def get_location_and_ids(self):
|
||||
return (ray.worker.global_worker.plasma_client.store_socket_name,
|
||||
return (ray.worker.global_worker.node.unique_id,
|
||||
tuple(self.gpu_ids))
|
||||
|
||||
# Create some actors.
|
||||
@@ -1080,7 +1079,7 @@ def test_actor_different_numbers_of_gpus(ray_start_cluster):
|
||||
self.gpu_ids = ray.get_gpu_ids()
|
||||
|
||||
def get_location_and_ids(self):
|
||||
return (ray.worker.global_worker.plasma_client.store_socket_name,
|
||||
return (ray.worker.global_worker.node.unique_id,
|
||||
tuple(self.gpu_ids))
|
||||
|
||||
# Create some actors.
|
||||
@@ -1126,8 +1125,7 @@ def test_actor_multiple_gpus_from_multiple_tasks(ray_start_cluster):
|
||||
self.gpu_ids = ray.get_gpu_ids()
|
||||
|
||||
def get_location_and_ids(self):
|
||||
return ((
|
||||
ray.worker.global_worker.plasma_client.store_socket_name),
|
||||
return ((ray.worker.global_worker.node.unique_id),
|
||||
tuple(self.gpu_ids))
|
||||
|
||||
def sleep(self):
|
||||
@@ -1173,7 +1171,7 @@ def test_actor_multiple_gpus_from_multiple_tasks(ray_start_cluster):
|
||||
self.gpu_ids = ray.get_gpu_ids()
|
||||
|
||||
def get_location_and_ids(self):
|
||||
return (ray.worker.global_worker.plasma_client.store_socket_name,
|
||||
return (ray.worker.global_worker.node.unique_id,
|
||||
tuple(self.gpu_ids))
|
||||
|
||||
# All the GPUs should be used up now.
|
||||
@@ -1217,8 +1215,8 @@ def test_actors_and_tasks_with_gpus(ray_start_cluster):
|
||||
gpu_ids = ray.get_gpu_ids()
|
||||
assert len(gpu_ids) == 1
|
||||
assert gpu_ids[0] in range(num_gpus_per_raylet)
|
||||
return (ray.worker.global_worker.plasma_client.store_socket_name,
|
||||
tuple(gpu_ids), [t1, t2])
|
||||
return (ray.worker.global_worker.node.unique_id, tuple(gpu_ids),
|
||||
[t1, t2])
|
||||
|
||||
@ray.remote(num_gpus=2)
|
||||
def f2():
|
||||
@@ -1229,8 +1227,8 @@ def test_actors_and_tasks_with_gpus(ray_start_cluster):
|
||||
assert len(gpu_ids) == 2
|
||||
assert gpu_ids[0] in range(num_gpus_per_raylet)
|
||||
assert gpu_ids[1] in range(num_gpus_per_raylet)
|
||||
return (ray.worker.global_worker.plasma_client.store_socket_name,
|
||||
tuple(gpu_ids), [t1, t2])
|
||||
return (ray.worker.global_worker.node.unique_id, tuple(gpu_ids),
|
||||
[t1, t2])
|
||||
|
||||
@ray.remote(num_gpus=1)
|
||||
class Actor1(object):
|
||||
@@ -1241,7 +1239,7 @@ def test_actors_and_tasks_with_gpus(ray_start_cluster):
|
||||
|
||||
def get_location_and_ids(self):
|
||||
assert ray.get_gpu_ids() == self.gpu_ids
|
||||
return (ray.worker.global_worker.plasma_client.store_socket_name,
|
||||
return (ray.worker.global_worker.node.unique_id,
|
||||
tuple(self.gpu_ids))
|
||||
|
||||
def locations_to_intervals_for_many_tasks():
|
||||
@@ -1416,8 +1414,8 @@ def test_exception_raised_when_actor_node_dies(ray_start_cluster_head):
|
||||
def __init__(self):
|
||||
self.x = 0
|
||||
|
||||
def local_plasma(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
def node_id(self):
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
def inc(self):
|
||||
self.x += 1
|
||||
@@ -1425,8 +1423,7 @@ def test_exception_raised_when_actor_node_dies(ray_start_cluster_head):
|
||||
|
||||
# Create an actor that is not on the raylet.
|
||||
actor = Counter.remote()
|
||||
while (ray.get(actor.local_plasma.remote()) !=
|
||||
remote_node.plasma_store_socket_name):
|
||||
while (ray.get(actor.node_id.remote()) != remote_node.unique_id):
|
||||
actor = Counter.remote()
|
||||
|
||||
# Kill the second node.
|
||||
@@ -1526,8 +1523,8 @@ def setup_counter_actor(test_checkpoint=False,
|
||||
self.save_exception = save_exception
|
||||
self.restored = False
|
||||
|
||||
def local_plasma(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
def node_id(self):
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
def inc(self, *xs):
|
||||
self.x += 1
|
||||
@@ -1554,11 +1551,11 @@ def setup_counter_actor(test_checkpoint=False,
|
||||
self.num_inc_calls = 0
|
||||
self.restored = True
|
||||
|
||||
local_plasma = ray.worker.global_worker.plasma_client.store_socket_name
|
||||
node_id = ray.worker.global_worker.node.unique_id
|
||||
|
||||
# Create an actor that is not on the raylet.
|
||||
actor = Counter.remote(save_exception)
|
||||
while ray.get(actor.local_plasma.remote()) == local_plasma:
|
||||
while ray.get(actor.node_id.remote()) == node_id:
|
||||
actor = Counter.remote(save_exception)
|
||||
|
||||
args = [ray.put(0) for _ in range(100)]
|
||||
@@ -1689,8 +1686,8 @@ def _test_nondeterministic_reconstruction(
|
||||
def __init__(self):
|
||||
self.queue = []
|
||||
|
||||
def local_plasma(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
def node_id(self):
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
def push(self, item):
|
||||
self.queue.append(item)
|
||||
@@ -1699,9 +1696,9 @@ def _test_nondeterministic_reconstruction(
|
||||
return self.queue
|
||||
|
||||
# Schedule the shared queue onto the remote raylet.
|
||||
local_plasma = ray.worker.global_worker.plasma_client.store_socket_name
|
||||
node_id = ray.worker.global_worker.node.unique_id
|
||||
actor = Queue.remote()
|
||||
while ray.get(actor.local_plasma.remote()) == local_plasma:
|
||||
while ray.get(actor.node_id.remote()) == node_id:
|
||||
actor = Queue.remote()
|
||||
|
||||
# A task that takes in the shared queue and a list of items to enqueue,
|
||||
@@ -2066,14 +2063,14 @@ def test_custom_label_placement(ray_start_cluster):
|
||||
@ray.remote(resources={"CustomResource1": 1})
|
||||
class ResourceActor1(object):
|
||||
def get_location(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
@ray.remote(resources={"CustomResource2": 1})
|
||||
class ResourceActor2(object):
|
||||
def get_location(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
local_plasma = ray.worker.global_worker.plasma_client.store_socket_name
|
||||
node_id = ray.worker.global_worker.node.unique_id
|
||||
|
||||
# Create some actors.
|
||||
actors1 = [ResourceActor1.remote() for _ in range(2)]
|
||||
@@ -2081,9 +2078,9 @@ def test_custom_label_placement(ray_start_cluster):
|
||||
locations1 = ray.get([a.get_location.remote() for a in actors1])
|
||||
locations2 = ray.get([a.get_location.remote() for a in actors2])
|
||||
for location in locations1:
|
||||
assert location == local_plasma
|
||||
assert location == node_id
|
||||
for location in locations2:
|
||||
assert location != local_plasma
|
||||
assert location != node_id
|
||||
|
||||
|
||||
def test_creating_more_actors_than_resources(shutdown_only):
|
||||
@@ -2225,21 +2222,15 @@ def test_actor_reconstruction(ray_start_regular):
|
||||
def test_actor_reconstruction_without_task(ray_start_regular):
|
||||
"""Test a dead actor can be reconstructed without sending task to it."""
|
||||
|
||||
def object_exists(obj_id):
|
||||
"""Check wether an object exists in plasma store."""
|
||||
plasma_client = ray.worker.global_worker.plasma_client
|
||||
plasma_id = plasma.ObjectID(obj_id.binary())
|
||||
return plasma_client.get(
|
||||
plasma_id, timeout_ms=0) != plasma.ObjectNotAvailable
|
||||
|
||||
@ray.remote(max_reconstructions=1)
|
||||
class ReconstructableActor(object):
|
||||
def __init__(self, obj_ids):
|
||||
for obj_id in obj_ids:
|
||||
# Every time the actor gets constructed,
|
||||
# put a new object in plasma store.
|
||||
if not object_exists(obj_id):
|
||||
ray.worker.global_worker.put_object(obj_id, 1)
|
||||
global_worker = ray.worker.global_worker
|
||||
if not global_worker.core_worker.object_exists(obj_id):
|
||||
global_worker.put_object(obj_id, 1)
|
||||
break
|
||||
|
||||
def get_pid(self):
|
||||
@@ -2252,7 +2243,8 @@ def test_actor_reconstruction_without_task(ray_start_regular):
|
||||
os.kill(pid, signal.SIGKILL)
|
||||
# Wait until the actor is reconstructed.
|
||||
assert wait_for_condition(
|
||||
lambda: object_exists(obj_ids[1]), timeout_ms=5000)
|
||||
lambda: ray.worker.global_worker.core_worker.object_exists(obj_ids[1]),
|
||||
timeout_ms=5000)
|
||||
|
||||
|
||||
def test_actor_reconstruction_on_node_failure(ray_start_cluster_head):
|
||||
@@ -2271,10 +2263,10 @@ def test_actor_reconstruction_on_node_failure(ray_start_cluster_head):
|
||||
}),
|
||||
)
|
||||
|
||||
def kill_node(object_store_socket):
|
||||
def kill_node(node_id):
|
||||
node_to_remove = None
|
||||
for node in cluster.worker_nodes:
|
||||
if object_store_socket == node.plasma_store_socket_name:
|
||||
if node_id == node.unique_id:
|
||||
node_to_remove = node
|
||||
cluster.remove_node(node_to_remove)
|
||||
|
||||
@@ -2288,7 +2280,7 @@ def test_actor_reconstruction_on_node_failure(ray_start_cluster_head):
|
||||
return self.value
|
||||
|
||||
def get_object_store_socket(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
actor = MyActor.remote()
|
||||
# Call increase 3 times.
|
||||
@@ -2481,8 +2473,7 @@ def test_checkpointing_on_node_failure(ray_start_cluster_2_nodes,
|
||||
remote_node = [node for node in cluster.worker_nodes]
|
||||
actor_cls = ray.remote(max_reconstructions=1)(ray_checkpointable_actor_cls)
|
||||
actor = actor_cls.remote()
|
||||
while (ray.get(actor.local_plasma.remote()) !=
|
||||
remote_node[0].plasma_store_socket_name):
|
||||
while (ray.get(actor.node_id.remote()) != remote_node[0].unique_id):
|
||||
actor = actor_cls.remote()
|
||||
|
||||
# Call increase several times.
|
||||
@@ -2725,8 +2716,8 @@ def test_ray_wait_dead_actor(ray_start_cluster):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def local_plasma(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
def node_id(self):
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
def ping(self):
|
||||
time.sleep(1)
|
||||
@@ -2743,8 +2734,7 @@ def test_ray_wait_dead_actor(ray_start_cluster):
|
||||
remote_node = cluster.list_all_nodes()[-1]
|
||||
remote_ping_id = None
|
||||
for i, actor in enumerate(actors):
|
||||
if ray.get(actor.local_plasma.remote()
|
||||
) == remote_node.plasma_store_socket_name:
|
||||
if ray.get(actor.node_id.remote()) == remote_node.unique_id:
|
||||
remote_ping_id = ping_ids[i]
|
||||
ray.internal.free([remote_ping_id], local_only=True)
|
||||
cluster.remove_node(remote_node)
|
||||
|
||||
@@ -1538,7 +1538,7 @@ def test_free_objects_multi_node(ray_start_cluster):
|
||||
|
||||
class RawActor(object):
|
||||
def get(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
ActorOnNode0 = ray.remote(resources={"Custom0": 1})(RawActor)
|
||||
ActorOnNode1 = ray.remote(resources={"Custom1": 1})(RawActor)
|
||||
@@ -1585,7 +1585,7 @@ def test_free_objects_multi_node(ray_start_cluster):
|
||||
assert len(l1) == 2
|
||||
assert len(l2) == 1
|
||||
# The deleted object will have the same store with the driver.
|
||||
local_return = ray.worker.global_worker.plasma_client.store_socket_name
|
||||
local_return = ray.worker.global_worker.node.unique_id
|
||||
for object_id in l1:
|
||||
assert ray.get(object_id) != local_return
|
||||
|
||||
@@ -1998,16 +1998,16 @@ def test_zero_cpus_actor(ray_start_cluster):
|
||||
cluster.add_node(num_cpus=2)
|
||||
ray.init(address=cluster.address)
|
||||
|
||||
local_plasma = ray.worker.global_worker.plasma_client.store_socket_name
|
||||
node_id = ray.worker.global_worker.node.unique_id
|
||||
|
||||
@ray.remote
|
||||
class Foo(object):
|
||||
def method(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
# Make sure tasks and actors run on the remote raylet.
|
||||
a = Foo.remote()
|
||||
assert ray.get(a.method.remote()) != local_plasma
|
||||
assert ray.get(a.method.remote()) != node_id
|
||||
|
||||
|
||||
def test_fractional_resources(shutdown_only):
|
||||
@@ -2080,32 +2080,32 @@ def test_multiple_raylets(ray_start_cluster):
|
||||
# This must be run on the zeroth raylet.
|
||||
@ray.remote(num_cpus=11)
|
||||
def run_on_0():
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.plasma_store_socket_name
|
||||
|
||||
# This must be run on the first raylet.
|
||||
@ray.remote(num_gpus=2)
|
||||
def run_on_1():
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.plasma_store_socket_name
|
||||
|
||||
# This must be run on the second raylet.
|
||||
@ray.remote(num_cpus=6, num_gpus=1)
|
||||
def run_on_2():
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.plasma_store_socket_name
|
||||
|
||||
# This can be run anywhere.
|
||||
@ray.remote(num_cpus=0, num_gpus=0)
|
||||
def run_on_0_1_2():
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.plasma_store_socket_name
|
||||
|
||||
# This must be run on the first or second raylet.
|
||||
@ray.remote(num_gpus=1)
|
||||
def run_on_1_2():
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.plasma_store_socket_name
|
||||
|
||||
# This must be run on the zeroth or second raylet.
|
||||
@ray.remote(num_cpus=8)
|
||||
def run_on_0_2():
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.plasma_store_socket_name
|
||||
|
||||
def run_lots_of_tasks():
|
||||
names = []
|
||||
@@ -2196,27 +2196,27 @@ def test_custom_resources(ray_start_cluster):
|
||||
@ray.remote
|
||||
def f():
|
||||
time.sleep(0.001)
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
@ray.remote(resources={"CustomResource": 1})
|
||||
def g():
|
||||
time.sleep(0.001)
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
@ray.remote(resources={"CustomResource": 1})
|
||||
def h():
|
||||
ray.get([f.remote() for _ in range(5)])
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
# The f tasks should be scheduled on both raylets.
|
||||
assert len(set(ray.get([f.remote() for _ in range(50)]))) == 2
|
||||
|
||||
local_plasma = ray.worker.global_worker.plasma_client.store_socket_name
|
||||
node_id = ray.worker.global_worker.node.unique_id
|
||||
|
||||
# The g tasks should be scheduled only on the second raylet.
|
||||
raylet_ids = set(ray.get([g.remote() for _ in range(50)]))
|
||||
assert len(raylet_ids) == 1
|
||||
assert list(raylet_ids)[0] != local_plasma
|
||||
assert list(raylet_ids)[0] != node_id
|
||||
|
||||
# Make sure that resource bookkeeping works when a task that uses a
|
||||
# custom resources gets blocked.
|
||||
@@ -2240,38 +2240,38 @@ def test_two_custom_resources(ray_start_cluster):
|
||||
@ray.remote(resources={"CustomResource1": 1})
|
||||
def f():
|
||||
time.sleep(0.001)
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
@ray.remote(resources={"CustomResource2": 1})
|
||||
def g():
|
||||
time.sleep(0.001)
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
@ray.remote(resources={"CustomResource1": 1, "CustomResource2": 3})
|
||||
def h():
|
||||
time.sleep(0.001)
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
@ray.remote(resources={"CustomResource1": 4})
|
||||
def j():
|
||||
time.sleep(0.001)
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
@ray.remote(resources={"CustomResource3": 1})
|
||||
def k():
|
||||
time.sleep(0.001)
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
# The f and g tasks should be scheduled on both raylets.
|
||||
assert len(set(ray.get([f.remote() for _ in range(50)]))) == 2
|
||||
assert len(set(ray.get([g.remote() for _ in range(50)]))) == 2
|
||||
|
||||
local_plasma = ray.worker.global_worker.plasma_client.store_socket_name
|
||||
node_id = ray.worker.global_worker.node.unique_id
|
||||
|
||||
# The h tasks should be scheduled only on the second raylet.
|
||||
raylet_ids = set(ray.get([h.remote() for _ in range(50)]))
|
||||
assert len(raylet_ids) == 1
|
||||
assert list(raylet_ids)[0] != local_plasma
|
||||
assert list(raylet_ids)[0] != node_id
|
||||
|
||||
# Make sure that tasks with unsatisfied custom resource requirements do
|
||||
# not get scheduled.
|
||||
@@ -2473,7 +2473,7 @@ def test_load_balancing(ray_start_cluster):
|
||||
@ray.remote
|
||||
def f():
|
||||
time.sleep(0.01)
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
attempt_to_load_balance(f, [], 100, num_nodes, 10)
|
||||
attempt_to_load_balance(f, [], 1000, num_nodes, 100)
|
||||
@@ -2491,7 +2491,7 @@ def test_load_balancing_with_dependencies(ray_start_cluster):
|
||||
@ray.remote
|
||||
def f(x):
|
||||
time.sleep(0.010)
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
# This object will be local to one of the raylets. Make sure
|
||||
# this doesn't prevent tasks from being scheduled on other raylets.
|
||||
@@ -2820,8 +2820,7 @@ def test_wait_reconstruction(shutdown_only):
|
||||
x_id = f.remote()
|
||||
ray.wait([x_id])
|
||||
ray.wait([f.remote()])
|
||||
assert not ray.worker.global_worker.plasma_client.contains(
|
||||
ray.pyarrow.plasma.ObjectID(x_id.binary()))
|
||||
assert not ray.worker.global_worker.core_worker.object_exists(x_id)
|
||||
ready_ids, _ = ray.wait([x_id])
|
||||
assert len(ready_ids) == 1
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ from __future__ import print_function
|
||||
|
||||
import json
|
||||
import os
|
||||
import pyarrow.plasma as plasma
|
||||
import pytest
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -767,7 +766,7 @@ def test_parallel_actor_fill_plasma_retry(ray_start_cluster_head, num_actors):
|
||||
"object_store_memory": 10**8
|
||||
}],
|
||||
indirect=True)
|
||||
def test_fill_plasma_exception(ray_start_cluster_head):
|
||||
def test_fill_object_store_exception(ray_start_cluster_head):
|
||||
@ray.remote
|
||||
class LargeMemoryActor(object):
|
||||
def some_expensive_task(self):
|
||||
@@ -782,5 +781,5 @@ def test_fill_plasma_exception(ray_start_cluster_head):
|
||||
# Make sure actor does not die
|
||||
ray.get(actor.test.remote())
|
||||
|
||||
with pytest.raises(plasma.PlasmaStoreFull):
|
||||
with pytest.raises(ray.exceptions.ObjectStoreFullError):
|
||||
ray.put(np.zeros(10**8 + 2, dtype=np.uint8))
|
||||
|
||||
@@ -2,12 +2,11 @@ import numpy as np
|
||||
import unittest
|
||||
|
||||
import ray
|
||||
import pyarrow
|
||||
|
||||
MB = 1024 * 1024
|
||||
|
||||
OBJECT_EVICTED = ray.exceptions.UnreconstructableError
|
||||
OBJECT_TOO_LARGE = pyarrow._plasma.PlasmaStoreFull
|
||||
OBJECT_TOO_LARGE = ray.exceptions.ObjectStoreFullError
|
||||
|
||||
|
||||
@ray.remote
|
||||
@@ -77,7 +76,7 @@ class TestMemoryLimits(unittest.TestCase):
|
||||
print("Raised exception", type(e), e)
|
||||
raise e
|
||||
finally:
|
||||
print(ray.worker.global_worker.plasma_client.debug_string())
|
||||
print(ray.worker.global_worker.dump_object_store_memory_usage())
|
||||
ray.shutdown()
|
||||
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ class TestMemoryScheduling(unittest.TestCase):
|
||||
resources_per_trial={"object_store_memory": 150 * 1024 * 1024},
|
||||
raise_on_failed_trial=False)
|
||||
self.assertTrue(result.trials[0].status, "ERROR")
|
||||
self.assertTrue("PlasmaStoreFull: object does not fit" in
|
||||
self.assertTrue("ObjectStoreFullError: Failed to put" in
|
||||
result.trials[0].error_msg)
|
||||
finally:
|
||||
ray.shutdown()
|
||||
|
||||
@@ -237,8 +237,8 @@ def test_object_transfer_retry(ray_start_cluster):
|
||||
|
||||
x_ids = [f.remote(10**i) for i in [1, 2, 3, 4]]
|
||||
assert not any(
|
||||
ray.worker.global_worker.plasma_client.contains(
|
||||
ray.pyarrow.plasma.ObjectID(x_id.binary())) for x_id in x_ids)
|
||||
ray.worker.global_worker.core_worker.object_exists(x_id)
|
||||
for x_id in x_ids)
|
||||
|
||||
# Get the objects locally to cause them to be transferred. This is the
|
||||
# first time the objects are getting transferred, so it should happen
|
||||
@@ -257,8 +257,8 @@ def test_object_transfer_retry(ray_start_cluster):
|
||||
for _ in range(15):
|
||||
ray.put(x)
|
||||
assert not any(
|
||||
ray.worker.global_worker.plasma_client.contains(
|
||||
ray.pyarrow.plasma.ObjectID(x_id.binary())) for x_id in x_ids)
|
||||
ray.worker.global_worker.core_worker.object_exists(x_id)
|
||||
for x_id in x_ids)
|
||||
|
||||
end_time = time.time()
|
||||
# Make sure that the first time the objects get transferred, it happens
|
||||
@@ -277,8 +277,8 @@ def test_object_transfer_retry(ray_start_cluster):
|
||||
for _ in range(15):
|
||||
ray.put(x)
|
||||
assert not any(
|
||||
ray.worker.global_worker.plasma_client.contains(
|
||||
ray.pyarrow.plasma.ObjectID(x_id.binary())) for x_id in x_ids)
|
||||
ray.worker.global_worker.core_worker.object_exists(x_id)
|
||||
for x_id in x_ids)
|
||||
|
||||
time.sleep(repeated_push_delay)
|
||||
|
||||
|
||||
@@ -281,16 +281,15 @@ def test_signal_on_node_failure(two_node_cluster):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def local_plasma(self):
|
||||
return ray.worker.global_worker.plasma_client.store_socket_name
|
||||
def node_id(self):
|
||||
return ray.worker.global_worker.node.unique_id
|
||||
|
||||
# Place the actor on the remote node.
|
||||
cluster, remote_node = two_node_cluster
|
||||
actor_cls = ray.remote(max_reconstructions=0)(ActorSignal)
|
||||
actor = actor_cls.remote()
|
||||
# Try until we put an actor on a different node.
|
||||
while (ray.get(actor.local_plasma.remote()) !=
|
||||
remote_node.plasma_store_socket_name):
|
||||
while (ray.get(actor.node_id.remote()) != remote_node.unique_id):
|
||||
actor = actor_cls.remote()
|
||||
|
||||
# Kill actor process.
|
||||
|
||||
Reference in New Issue
Block a user