Skip to content

Commit 072f442

Browse files
robertnishiharapcmoritz
authored andcommitted
Update worker.py and services.py to use plasma and the local scheduler. (#19)
* Update worker code and services code to use plasma and the local scheduler. * Cleanups. * Fix bug in which threads were started before the worker mode was set. This caused remote functions to be defined on workers before the worker knew it was in WORKER_MODE. * Fix bug in install-dependencies.sh. * Lengthen timeout in failure_test.py. * Cleanups. * Cleanup services.start_ray_local. * Clean up random name generation. * Cleanups.
1 parent 2068587 commit 072f442

File tree

20 files changed

+623
-1208
lines changed

20 files changed

+623
-1208
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,8 @@ script:
6969
- python src/common/test/test.py
7070
- python src/plasma/test/test.py
7171
- python src/photon/test/test.py
72+
73+
- python test/runtest.py
74+
- python test/array_test.py
75+
- python test/failure_test.py
76+
- python test/microbenchmarks.py

CMakeLists.txt

Lines changed: 0 additions & 147 deletions
This file was deleted.

data/README.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

data/mini.tar

-50 KB
Binary file not shown.

install-dependencies.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ if [[ $platform == "linux" ]]; then
3131
# These commands must be kept in sync with the installation instructions.
3232
sudo apt-get update
3333
sudo apt-get install -y git cmake build-essential autoconf curl libtool python-dev python-numpy python-pip libboost-all-dev unzip graphviz
34-
sudo pip install ipython funcsigs subprocess32 protobuf colorama graphviz
34+
sudo pip install ipython funcsigs subprocess32 protobuf colorama graphviz redis
3535
sudo pip install --upgrade git+git://github.com/cloudpipe/cloudpickle.git@0d225a4695f1f65ae1cbb2e0bbc145e10167cce4 # We use the latest version of cloudpickle because it can serialize named tuples.
3636
elif [[ $platform == "macosx" ]]; then
3737
# These commands must be kept in sync with the installation instructions.
3838
brew install git cmake automake autoconf libtool boost graphviz
3939
sudo easy_install pip
4040
sudo pip install ipython --user
41-
sudo pip install numpy funcsigs subprocess32 protobuf colorama graphviz --ignore-installed six
41+
sudo pip install numpy funcsigs subprocess32 protobuf colorama graphviz redis --ignore-installed six
4242
sudo pip install --upgrade git+git://github.com/cloudpipe/cloudpickle.git@0d225a4695f1f65ae1cbb2e0bbc145e10167cce4 # We use the latest version of cloudpickle because it can serialize named tuples.
4343
fi
4444

lib/python/ray/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
import config
1313
import serialization
14-
from worker import scheduler_info, register_class, visualize_computation_graph, task_info, init, connect, disconnect, get, put, wait, remote, kill_workers, restart_workers_local
14+
from worker import register_class, error_info, init, connect, disconnect, get, put, wait, remote
1515
from worker import Reusable, reusables
16-
from libraylib import SCRIPT_MODE, WORKER_MODE, PYTHON_MODE, SILENT_MODE
17-
from libraylib import ObjectID
18-
import internal
16+
from worker import SCRIPT_MODE, WORKER_MODE, PYTHON_MODE, SILENT_MODE

lib/python/ray/default_worker.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from __future__ import print_function
2+
3+
import sys
4+
import argparse
5+
import numpy as np
6+
7+
import ray
8+
9+
parser = argparse.ArgumentParser(description="Parse addresses for the worker to connect to.")
10+
parser.add_argument("--node-ip-address", required=True, type=str, help="the ip address of the worker's node")
11+
parser.add_argument("--redis-port", required=True, type=int, help="the port to use for Redis")
12+
parser.add_argument("--object-store-name", type=str, help="the object store's name")
13+
parser.add_argument("--object-store-manager-name", type=str, help="the object store manager's name")
14+
parser.add_argument("--local-scheduler-name", type=str, help="the local scheduler's name")
15+
16+
if __name__ == "__main__":
17+
args = parser.parse_args()
18+
address_info = {"node_ip_address": args.node_ip_address,
19+
"redis_port": args.redis_port,
20+
"object_store_name": args.object_store_name,
21+
"object_store_manager_name": args.object_store_manager_name,
22+
"local_scheduler_name": args.local_scheduler_name}
23+
ray.worker.connect(address_info, ray.WORKER_MODE)
24+
25+
ray.worker.main_loop()

lib/python/ray/graph.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

lib/python/ray/internal/__init__.py

Whitespace-only changes.

lib/python/ray/serialization.py

Lines changed: 2 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,9 @@
1+
from __future__ import print_function
2+
13
import numpy as np
24
import pickling
3-
import libraylib as raylib
45
import numbuf
56

6-
def is_argument_serializable(value):
7-
"""Checks if value is a composition of primitive types.
8-
9-
This will return True if the argument is one of the following:
10-
- An int
11-
- A float
12-
- A bool
13-
- None
14-
- A list of length at most 100 whose elements are serializable
15-
- A tuple of length at most 100 whose elements are serializable
16-
- A dict of length at most 100 whose keys and values are serializable
17-
- A string of length at most 100.
18-
- A unicode string of length at most 100.
19-
20-
Args:
21-
value: A Python object.
22-
23-
Returns:
24-
True if the object can be serialized as a composition of primitive types and
25-
False otherwise.
26-
"""
27-
t = type(value)
28-
if t is int or t is float or t is long or t is bool or value is None:
29-
return True
30-
if t is list:
31-
if len(value) <= 100:
32-
for element in value:
33-
if not is_argument_serializable(element):
34-
return False
35-
return True
36-
else:
37-
return False
38-
if t is tuple:
39-
if len(value) <= 100:
40-
for element in value:
41-
if not is_argument_serializable(element):
42-
return False
43-
return True
44-
else:
45-
return False
46-
if t is dict:
47-
if len(value) <= 100:
48-
for k, v in value.iteritems():
49-
if not is_argument_serializable(k) or not is_argument_serializable(v):
50-
return False
51-
return True
52-
else:
53-
return False
54-
if t is str:
55-
return len(value) <= 100
56-
if t is unicode:
57-
return len(value) <= 100
58-
return False
59-
60-
def serialize_argument_if_possible(value):
61-
"""This method serializes arguments that are passed by value.
62-
63-
The result will be deserialized by deserialize_argument.
64-
65-
Returns:
66-
None if value cannot be efficiently serialized or is too big, and otherwise
67-
this returns the serialized value as a string.
68-
"""
69-
if not is_argument_serializable(value):
70-
# The argument is not obviously serializable using __repr__, so we will not
71-
# serialize it.
72-
return None
73-
serialized_value = value.__repr__()
74-
if len(serialized_value) > 1000:
75-
# The argument is too big, so we will not pass it by value.
76-
return None
77-
# Return the serialized argument.
78-
return serialized_value
79-
80-
def deserialize_argument(serialized_value):
81-
"""This method deserializes arguments that are passed by value.
82-
83-
The argument will have been serialized by serialize_argument.
84-
"""
85-
return eval(serialized_value)
86-
877
def check_serializable(cls):
888
"""Throws an exception if Ray cannot serialize this class efficiently.
899

0 commit comments

Comments
 (0)