mirror of
https://github.com/wassname/ray.git
synced 2026-08-20 12:40:44 +08:00
change filenames and directory structure to use halo (#81)
This commit is contained in:
committed by
Philipp Moritz
parent
b58eaf84ee
commit
67086f663e
+49
-49
@@ -1,8 +1,8 @@
|
||||
import unittest
|
||||
import orchpy
|
||||
import orchpy.serialization as serialization
|
||||
import orchpy.services as services
|
||||
import orchpy.worker as worker
|
||||
import halo
|
||||
import halo.serialization as serialization
|
||||
import halo.services as services
|
||||
import halo.worker as worker
|
||||
import numpy as np
|
||||
import time
|
||||
import subprocess32 as subprocess
|
||||
@@ -10,7 +10,7 @@ import os
|
||||
|
||||
from google.protobuf.text_format import *
|
||||
|
||||
import orchestra_pb2
|
||||
import halo_pb2
|
||||
import types_pb2
|
||||
|
||||
import test_functions
|
||||
@@ -61,10 +61,10 @@ class SerializationTest(unittest.TestCase):
|
||||
self.numpyTypeTest(w, 'float32')
|
||||
self.numpyTypeTest(w, 'float64')
|
||||
|
||||
ref0 = orchpy.push(0, w)
|
||||
ref1 = orchpy.push(0, w)
|
||||
ref2 = orchpy.push(0, w)
|
||||
ref3 = orchpy.push(0, w)
|
||||
ref0 = halo.push(0, w)
|
||||
ref1 = halo.push(0, w)
|
||||
ref2 = halo.push(0, w)
|
||||
ref3 = halo.push(0, w)
|
||||
a = np.array([[ref0, ref1], [ref2, ref3]])
|
||||
capsule, _ = serialization.serialize(w.handle, a)
|
||||
result = serialization.deserialize(w.handle, capsule)
|
||||
@@ -80,8 +80,8 @@ class ObjStoreTest(unittest.TestCase):
|
||||
|
||||
# pushing and pulling an object shouldn't change it
|
||||
for data in ["h", "h" * 10000, 0, 0.0]:
|
||||
objref = orchpy.push(data, w1)
|
||||
result = orchpy.pull(objref, w1)
|
||||
objref = halo.push(data, w1)
|
||||
result = halo.pull(objref, w1)
|
||||
self.assertEqual(result, data)
|
||||
|
||||
# pushing an object, shipping it to another worker, and pulling it shouldn't change it
|
||||
@@ -134,7 +134,7 @@ class SchedulerTest(unittest.TestCase):
|
||||
|
||||
time.sleep(0.2)
|
||||
|
||||
value_after = orchpy.pull(objref[0], w)
|
||||
value_after = halo.pull(objref[0], w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
time.sleep(0.1)
|
||||
@@ -148,26 +148,26 @@ class WorkerTest(unittest.TestCase):
|
||||
|
||||
for i in range(100):
|
||||
value_before = i * 10 ** 6
|
||||
objref = orchpy.push(value_before, w)
|
||||
value_after = orchpy.pull(objref, w)
|
||||
objref = halo.push(value_before, w)
|
||||
value_after = halo.pull(objref, w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
for i in range(100):
|
||||
value_before = i * 10 ** 6 * 1.0
|
||||
objref = orchpy.push(value_before, w)
|
||||
value_after = orchpy.pull(objref, w)
|
||||
objref = halo.push(value_before, w)
|
||||
value_after = halo.pull(objref, w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
for i in range(100):
|
||||
value_before = "h" * i
|
||||
objref = orchpy.push(value_before, w)
|
||||
value_after = orchpy.pull(objref, w)
|
||||
objref = halo.push(value_before, w)
|
||||
value_after = halo.pull(objref, w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
for i in range(100):
|
||||
value_before = [1] * i
|
||||
objref = orchpy.push(value_before, w)
|
||||
value_after = orchpy.pull(objref, w)
|
||||
objref = halo.push(value_before, w)
|
||||
value_after = halo.pull(objref, w)
|
||||
self.assertEqual(value_before, value_after)
|
||||
|
||||
services.cleanup()
|
||||
@@ -180,11 +180,11 @@ class APITest(unittest.TestCase):
|
||||
[w] = services.start_singlenode_cluster(return_drivers=True, num_workers_per_objstore=3, worker_path=test_path)
|
||||
|
||||
objref = w.submit_task("test_functions.test_alias_f", [])
|
||||
self.assertTrue(np.alltrue(orchpy.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
self.assertTrue(np.alltrue(halo.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
objref = w.submit_task("test_functions.test_alias_g", [])
|
||||
self.assertTrue(np.alltrue(orchpy.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
self.assertTrue(np.alltrue(halo.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
objref = w.submit_task("test_functions.test_alias_h", [])
|
||||
self.assertTrue(np.alltrue(orchpy.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
self.assertTrue(np.alltrue(halo.pull(objref[0], w) == np.ones([3, 4, 5])))
|
||||
|
||||
services.cleanup()
|
||||
|
||||
@@ -193,35 +193,35 @@ class APITest(unittest.TestCase):
|
||||
test_path = os.path.join(test_dir, "testrecv.py")
|
||||
services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=3, worker_path=test_path)
|
||||
x = test_functions.keyword_fct1(1)
|
||||
self.assertEqual(orchpy.pull(x), "1 hello")
|
||||
self.assertEqual(halo.pull(x), "1 hello")
|
||||
x = test_functions.keyword_fct1(1, "hi")
|
||||
self.assertEqual(orchpy.pull(x), "1 hi")
|
||||
self.assertEqual(halo.pull(x), "1 hi")
|
||||
x = test_functions.keyword_fct1(1, b="world")
|
||||
self.assertEqual(orchpy.pull(x), "1 world")
|
||||
self.assertEqual(halo.pull(x), "1 world")
|
||||
|
||||
x = test_functions.keyword_fct2(a="w", b="hi")
|
||||
self.assertEqual(orchpy.pull(x), "w hi")
|
||||
self.assertEqual(halo.pull(x), "w hi")
|
||||
x = test_functions.keyword_fct2(b="hi", a="w")
|
||||
self.assertEqual(orchpy.pull(x), "w hi")
|
||||
self.assertEqual(halo.pull(x), "w hi")
|
||||
x = test_functions.keyword_fct2(a="w")
|
||||
self.assertEqual(orchpy.pull(x), "w world")
|
||||
self.assertEqual(halo.pull(x), "w world")
|
||||
x = test_functions.keyword_fct2(b="hi")
|
||||
self.assertEqual(orchpy.pull(x), "hello hi")
|
||||
self.assertEqual(halo.pull(x), "hello hi")
|
||||
x = test_functions.keyword_fct2("w")
|
||||
self.assertEqual(orchpy.pull(x), "w world")
|
||||
self.assertEqual(halo.pull(x), "w world")
|
||||
x = test_functions.keyword_fct2("w", "hi")
|
||||
self.assertEqual(orchpy.pull(x), "w hi")
|
||||
self.assertEqual(halo.pull(x), "w hi")
|
||||
|
||||
x = test_functions.keyword_fct3(0, 1, c="w", d="hi")
|
||||
self.assertEqual(orchpy.pull(x), "0 1 w hi")
|
||||
self.assertEqual(halo.pull(x), "0 1 w hi")
|
||||
x = test_functions.keyword_fct3(0, 1, d="hi", c="w")
|
||||
self.assertEqual(orchpy.pull(x), "0 1 w hi")
|
||||
self.assertEqual(halo.pull(x), "0 1 w hi")
|
||||
x = test_functions.keyword_fct3(0, 1, c="w")
|
||||
self.assertEqual(orchpy.pull(x), "0 1 w world")
|
||||
self.assertEqual(halo.pull(x), "0 1 w world")
|
||||
x = test_functions.keyword_fct3(0, 1, d="hi")
|
||||
self.assertEqual(orchpy.pull(x), "0 1 hello hi")
|
||||
self.assertEqual(halo.pull(x), "0 1 hello hi")
|
||||
x = test_functions.keyword_fct3(0, 1)
|
||||
self.assertEqual(orchpy.pull(x), "0 1 hello world")
|
||||
self.assertEqual(halo.pull(x), "0 1 hello world")
|
||||
|
||||
services.cleanup()
|
||||
|
||||
@@ -233,48 +233,48 @@ class ReferenceCountingTest(unittest.TestCase):
|
||||
services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=3, worker_path=test_path)
|
||||
|
||||
x = test_functions.test_alias_f()
|
||||
orchpy.pull(x)
|
||||
halo.pull(x)
|
||||
time.sleep(0.1)
|
||||
objref_val = x.val
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val] == 1)
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val] == 1)
|
||||
|
||||
del x
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val] == -1) # -1 indicates deallocated
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val] == -1) # -1 indicates deallocated
|
||||
|
||||
y = test_functions.test_alias_h()
|
||||
orchpy.pull(y)
|
||||
halo.pull(y)
|
||||
time.sleep(0.1)
|
||||
objref_val = y.val
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 0, 0])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 0, 0])
|
||||
|
||||
del y
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
|
||||
z = dist.zeros([dist.BLOCK_SIZE, 2 * dist.BLOCK_SIZE], "float")
|
||||
time.sleep(0.1)
|
||||
objref_val = z.val
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 1, 1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 1, 1])
|
||||
|
||||
del z
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
|
||||
x = single.zeros([10, 10], "float")
|
||||
y = single.zeros([10, 10], "float")
|
||||
z = single.dot(x, y)
|
||||
objref_val = x.val
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 1, 1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [1, 1, 1])
|
||||
|
||||
del x
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, 1, 1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, 1, 1])
|
||||
del y
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, 1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, 1])
|
||||
del z
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(orchpy.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
self.assertTrue(halo.scheduler_info()["reference_counts"][objref_val:(objref_val + 3)] == [-1, -1, -1])
|
||||
|
||||
services.cleanup()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user