From ac65f1031e6568cc5d3393a9d96f4810cbbabcae Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Sun, 19 Jun 2016 22:01:31 -0700 Subject: [PATCH] rename test_path -> worker_path (#128) --- examples/imagenet/driver.py | 4 ++-- examples/lbfgs/driver.py | 5 ++--- lib/python/ray/services.py | 4 ++-- test/arrays_test.py | 15 ++++++--------- test/datasets_test.py | 7 +++---- test/microbenchmarks.py | 5 ++--- test/runtest.py | 30 ++++++++++++------------------ 7 files changed, 29 insertions(+), 41 deletions(-) diff --git a/examples/imagenet/driver.py b/examples/imagenet/driver.py index cc25bfe58..ee54ee221 100644 --- a/examples/imagenet/driver.py +++ b/examples/imagenet/driver.py @@ -15,8 +15,8 @@ parser.add_argument("--drop-ipython", default=False, type=bool, help="Drop into if __name__ == "__main__": args = parser.parse_args() - test_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "worker.py") - services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=5, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "worker.py") + services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=5, worker_path=worker_path) s3 = boto3.resource("s3") imagenet_bucket = s3.Bucket(args.s3_bucket) diff --git a/examples/lbfgs/driver.py b/examples/lbfgs/driver.py index 701dd94c0..b5b719012 100644 --- a/examples/lbfgs/driver.py +++ b/examples/lbfgs/driver.py @@ -19,9 +19,8 @@ num_batches = mnist.train.num_examples / batch_size batches = [mnist.train.next_batch(batch_size) for _ in range(num_batches)] if __name__ == "__main__": - test_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "worker.py") - test_path = os.path.join("worker.py") - services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=16, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "worker.py") + services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=16, worker_path=worker_path) x_batches = [ray.push(batches[i][0]) for i in range(num_batches)] y_batches = [ray.push(batches[i][1]) for i in range(num_batches)] diff --git a/lib/python/ray/services.py b/lib/python/ray/services.py index bd35bc14b..828fe3801 100644 --- a/lib/python/ray/services.py +++ b/lib/python/ray/services.py @@ -77,9 +77,9 @@ def start_objstore(scheduler_address, objstore_address): p = subprocess.Popen([os.path.join(_services_path, "objstore"), scheduler_address, objstore_address, "--log-file-name", objstore_log_filename]) all_processes.append((p, objstore_address)) -def start_worker(test_path, scheduler_address, objstore_address, worker_address): +def start_worker(worker_path, scheduler_address, objstore_address, worker_address): p = subprocess.Popen(["python", - test_path, + worker_path, "--scheduler-address=" + scheduler_address, "--objstore-address=" + objstore_address, "--worker-address=" + worker_address]) diff --git a/test/arrays_test.py b/test/arrays_test.py index 695c1672b..0f9775cda 100644 --- a/test/arrays_test.py +++ b/test/arrays_test.py @@ -14,9 +14,8 @@ import ray.arrays.distributed as da class ArraysSingleTest(unittest.TestCase): def testMethods(self): - test_dir = os.path.dirname(os.path.abspath(__file__)) - test_path = os.path.join(test_dir, "test_worker.py") - services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=1, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_worker.py") + services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=1, worker_path=worker_path) # test eye ref = ra.eye(3) @@ -60,9 +59,8 @@ class ArraysDistTest(unittest.TestCase): services.cleanup() def testAssemble(self): - test_dir = os.path.dirname(os.path.abspath(__file__)) - test_path = os.path.join(test_dir, "test_worker.py") - services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=1, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_worker.py") + services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=1, worker_path=worker_path) a = ra.ones([da.BLOCK_SIZE, da.BLOCK_SIZE]) b = ra.zeros([da.BLOCK_SIZE, da.BLOCK_SIZE]) @@ -73,9 +71,8 @@ class ArraysDistTest(unittest.TestCase): services.cleanup() def testMethods(self): - test_dir = os.path.dirname(os.path.abspath(__file__)) - test_path = os.path.join(test_dir, "test_worker.py") - services.start_singlenode_cluster(return_drivers=False, num_objstores=2, num_workers_per_objstore=5, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_worker.py") + services.start_singlenode_cluster(return_drivers=False, num_objstores=2, num_workers_per_objstore=5, worker_path=worker_path) x = da.zeros([9, 25, 51], "float") y = da.assemble(x) diff --git a/test/datasets_test.py b/test/datasets_test.py index fb0391bbd..8871a65dc 100644 --- a/test/datasets_test.py +++ b/test/datasets_test.py @@ -8,11 +8,10 @@ import ray.datasets.imagenet as imagenet class ImageNetTest(unittest.TestCase): def testImageNetLoading(self): - test_dir = os.path.dirname(os.path.abspath(__file__)) - test_path = os.path.join(test_dir, "test_worker.py") - services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=5, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_worker.py") + services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=5, worker_path=worker_path) - chunk_name = os.path.join(test_dir, "..", "data", "mini.tar") + chunk_name = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../data/mini.tar") tar = tarfile.open(chunk_name, mode= "r") chunk = imagenet.load_chunk(tar, size=(256, 256)) self.assertEqual(chunk.shape, (2, 256, 256, 3)) diff --git a/test/microbenchmarks.py b/test/microbenchmarks.py index 0755d9eda..03d34eaf3 100644 --- a/test/microbenchmarks.py +++ b/test/microbenchmarks.py @@ -10,9 +10,8 @@ import test_functions class MicroBenchmarkTest(unittest.TestCase): def testTiming(self): - test_dir = os.path.dirname(os.path.abspath(__file__)) - test_path = os.path.join(test_dir, "test_worker.py") - services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=3, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_worker.py") + services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=3, worker_path=worker_path) # measure the time required to submit a remote task to the scheduler elapsed_times = [] diff --git a/test/runtest.py b/test/runtest.py index 9d3b67ed6..df1ff0d52 100644 --- a/test/runtest.py +++ b/test/runtest.py @@ -126,9 +126,8 @@ class ObjStoreTest(unittest.TestCase): class SchedulerTest(unittest.TestCase): def testRemoteTask(self): - test_dir = os.path.dirname(os.path.abspath(__file__)) - test_path = os.path.join(test_dir, "test_worker.py") - [w] = services.start_singlenode_cluster(return_drivers=True, num_workers_per_objstore=1, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_worker.py") + [w] = services.start_singlenode_cluster(return_drivers=True, num_workers_per_objstore=1, worker_path=worker_path) value_before = "test_string" objref = w.submit_task("test_functions.print_string", [value_before]) @@ -176,9 +175,8 @@ class WorkerTest(unittest.TestCase): class APITest(unittest.TestCase): def testObjRefAliasing(self): - test_dir = os.path.dirname(os.path.abspath(__file__)) - test_path = os.path.join(test_dir, "test_worker.py") - [w] = services.start_singlenode_cluster(return_drivers=True, num_workers_per_objstore=3, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_worker.py") + [w] = services.start_singlenode_cluster(return_drivers=True, num_workers_per_objstore=3, worker_path=worker_path) objref = w.submit_task("test_functions.test_alias_f", []) self.assertTrue(np.alltrue(ray.pull(objref[0], w) == np.ones([3, 4, 5]))) @@ -190,9 +188,8 @@ class APITest(unittest.TestCase): services.cleanup() def testKeywordArgs(self): - test_dir = os.path.dirname(os.path.abspath(__file__)) - test_path = os.path.join(test_dir, "test_worker.py") - services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=1, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_worker.py") + services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=1, worker_path=worker_path) x = test_functions.keyword_fct1(1) self.assertEqual(ray.pull(x), "1 hello") @@ -228,9 +225,8 @@ class APITest(unittest.TestCase): services.cleanup() def testVariableNumberOfArgs(self): - test_dir = os.path.dirname(os.path.abspath(__file__)) - test_path = os.path.join(test_dir, "test_worker.py") - services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=1, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_worker.py") + services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=1, worker_path=worker_path) x = test_functions.varargs_fct1(0, 1, 2) self.assertEqual(ray.pull(x), "0 1 2") @@ -244,9 +240,8 @@ class APITest(unittest.TestCase): class TaskStatusTest(unittest.TestCase): def testFailedTask(self): - test_dir = os.path.dirname(os.path.abspath(__file__)) - test_path = os.path.join(test_dir, "test_worker.py") - services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=3, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_worker.py") + services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=3, worker_path=worker_path) test_functions.test_alias_f() test_functions.throw_exception_fct() test_functions.throw_exception_fct() @@ -264,9 +259,8 @@ class TaskStatusTest(unittest.TestCase): class ReferenceCountingTest(unittest.TestCase): def testDeallocation(self): - test_dir = os.path.dirname(os.path.abspath(__file__)) - test_path = os.path.join(test_dir, "test_worker.py") - services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=3, worker_path=test_path) + worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_worker.py") + services.start_singlenode_cluster(return_drivers=False, num_workers_per_objstore=3, worker_path=worker_path) x = test_functions.test_alias_f() ray.pull(x)