mirror of
https://github.com/wassname/ray.git
synced 2026-08-13 12:30:18 +08:00
Automatically add relevant directories to Python paths of workers (#380)
* Make ray.init set python paths of workers. * Decouple starting cluster from copying user source code * also add current directory to path * Add comments about deallocation. * Add test for new code path.
This commit is contained in:
committed by
Philipp Moritz
parent
7246013008
commit
e06311d415
@@ -351,6 +351,23 @@ class APITest(unittest.TestCase):
|
||||
|
||||
ray.worker.cleanup()
|
||||
|
||||
def testRunningFunctionOnAllWorkers(self):
|
||||
ray.init(start_ray_local=True, num_workers=1)
|
||||
|
||||
def f():
|
||||
sys.path.append("fake_directory")
|
||||
ray.worker.global_worker.run_function_on_all_workers(f)
|
||||
@ray.remote([], [list])
|
||||
def get_path():
|
||||
return sys.path
|
||||
self.assertEqual("fake_directory", ray.get(get_path.remote())[-1])
|
||||
def f():
|
||||
sys.path.pop(-1)
|
||||
ray.worker.global_worker.run_function_on_all_workers(f)
|
||||
self.assertTrue("fake_directory" not in ray.get(get_path.remote()))
|
||||
|
||||
ray.worker.cleanup()
|
||||
|
||||
def check_get_deallocated(data):
|
||||
x = ray.put(data)
|
||||
ray.get(x)
|
||||
|
||||
Reference in New Issue
Block a user