-
Notifications
You must be signed in to change notification settings - Fork 733
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix ray and add more test Signed-off-by: Jieru Hong <[email protected]> * modify raycontext and move test file to func Signed-off-by: Jieru Hong <[email protected]> * modify process and add sc.stop in the end Signed-off-by: Jieru Hong <[email protected]> * delete one repeat and check PEP8 Signed-off-by: Jieru Hong <[email protected]> * change file name and remove some useless code Signed-off-by: Jieru Hong <[email protected]> * rename test yarn reinit file Signed-off-by: Jieru Hong <[email protected]> * ignore test reinit raycontext Signed-off-by: Jieru Hong <[email protected]>
- Loading branch information
1 parent
5444e3d
commit 4d9f1eb
Showing
7 changed files
with
135 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
pyzoo/test/zoo/ray/integration/test_yarn_reinit_raycontext.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# | ||
# Copyright 2018 Analytics Zoo Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
from unittest import TestCase | ||
|
||
import numpy as np | ||
import psutil | ||
import pytest | ||
import ray | ||
import time | ||
|
||
from zoo import init_spark_on_yarn | ||
from zoo.ray.util.raycontext import RayContext | ||
|
||
np.random.seed(1337) # for reproducibility | ||
|
||
|
||
@ray.remote | ||
class TestRay(): | ||
def hostname(self): | ||
import socket | ||
return socket.gethostname() | ||
|
||
|
||
node_num = 4 | ||
sc = init_spark_on_yarn( | ||
hadoop_conf="/opt/work/hadoop-2.7.2/etc/hadoop/", | ||
conda_name="rayexample", | ||
num_executor=node_num, | ||
executor_cores=28, | ||
executor_memory="10g", | ||
driver_memory="2g", | ||
driver_cores=4, | ||
extra_executor_memory_for_ray="30g") | ||
ray_ctx = RayContext(sc=sc, object_store_memory="2g") | ||
ray_ctx.init() | ||
actors = [TestRay.remote() for i in range(0, node_num)] | ||
print([ray.get(actor.hostname.remote()) for actor in actors]) | ||
ray_ctx.stop() | ||
# repeat | ||
ray_ctx = RayContext(sc=sc, object_store_memory="1g") | ||
ray_ctx.init() | ||
actors = [TestRay.remote() for i in range(0, node_num)] | ||
print([ray.get(actor.hostname.remote()) for actor in actors]) | ||
ray_ctx.stop() | ||
|
||
sc.stop() | ||
time.sleep(3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# | ||
# Copyright 2018 Analytics Zoo Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
from unittest import TestCase | ||
|
||
import numpy as np | ||
import psutil | ||
import pytest | ||
import ray | ||
import time | ||
|
||
from zoo import init_spark_on_local | ||
from zoo.ray.util.raycontext import RayContext | ||
|
||
np.random.seed(1337) # for reproducibility | ||
|
||
|
||
@ray.remote | ||
class TestRay(): | ||
def hostname(self): | ||
import socket | ||
return socket.gethostname() | ||
|
||
|
||
class TestUtil(TestCase): | ||
|
||
def test_local(self): | ||
node_num = 4 | ||
sc = init_spark_on_local(cores=node_num) | ||
ray_ctx = RayContext(sc=sc, object_store_memory="1g") | ||
ray_ctx.init() | ||
actors = [TestRay.remote() for i in range(0, node_num)] | ||
print([ray.get(actor.hostname.remote()) for actor in actors]) | ||
ray_ctx.stop() | ||
time.sleep(3) | ||
# repeat | ||
print("-------------------first repeat begin!------------------") | ||
ray_ctx = RayContext(sc=sc, object_store_memory="1g") | ||
ray_ctx.init() | ||
actors = [TestRay.remote() for i in range(0, node_num)] | ||
print([ray.get(actor.hostname.remote()) for actor in actors]) | ||
ray_ctx.stop() | ||
sc.stop() | ||
time.sleep(3) | ||
for process_info in ray_ctx.ray_processesMonitor.process_infos: | ||
for pid in process_info.pids: | ||
assert not psutil.pid_exists(pid) | ||
|
||
if __name__ == "__main__": | ||
pytest.main([__file__]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters