Skip to content

Commit

Permalink
[C++ worker] support build C++ worker during python setup (ray-projec…
Browse files Browse the repository at this point in the history
  • Loading branch information
SongGuyang authored Jun 29, 2021
1 parent 322b953 commit 41b9a51
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cpp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ genrule(
cp -f -r "$$WORK_DIR/external/boost/boost/utility" "$$BOOST_DIR" &&
cp -f -r $$WORK_DIR/external/boost/boost/*.hpp "$$BOOST_DIR" &&
cp -f $(locations libray_api.so) "$$TEMP_DIR/thirdparty/lib/" &&
cp -f -r "$$WORK_DIR/cpp/include/ray/" "$$TEMP_DIR/thirdparty/include" &&
cp -f -r "$$WORK_DIR/cpp/include/ray" "$$TEMP_DIR/thirdparty/include" &&
echo "$$WORK_DIR" > $@
""",
local = 1,
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/ray/runtime/native_ray_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ray {
namespace api {

NativeRayRuntime::NativeRayRuntime() {
object_store_ = std::unique_ptr<ObjectStore>(new NativeObjectStore(*this));
object_store_ = std::unique_ptr<ObjectStore>(new NativeObjectStore());
task_submitter_ = std::unique_ptr<TaskSubmitter>(new NativeTaskSubmitter());
task_executor_ = std::make_unique<TaskExecutor>(*this);
}
Expand Down
2 changes: 0 additions & 2 deletions cpp/src/ray/runtime/object/native_object_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

namespace ray {
namespace api {
NativeObjectStore::NativeObjectStore(NativeRayRuntime &native_ray_tuntime)
: native_ray_tuntime_(native_ray_tuntime) {}

void NativeObjectStore::PutRaw(std::shared_ptr<msgpack::sbuffer> data,
ObjectID *object_id) {
Expand Down
4 changes: 0 additions & 4 deletions cpp/src/ray/runtime/object/native_object_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ namespace api {

class NativeObjectStore : public ObjectStore {
public:
NativeObjectStore(NativeRayRuntime &native_ray_tuntime);

std::vector<bool> Wait(const std::vector<ObjectID> &ids, int num_objects,
int timeout_ms);

Expand All @@ -29,8 +27,6 @@ class NativeObjectStore : public ObjectStore {

std::vector<std::shared_ptr<msgpack::sbuffer>> GetRaw(const std::vector<ObjectID> &ids,
int timeout_ms);

NativeRayRuntime &native_ray_tuntime_;
};

} // namespace api
Expand Down
2 changes: 1 addition & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Ray provides Python, Java, and *EXPERIMENTAL* C++ API. And Ray uses Tasks (funct
.. code-block:: shell
bazel build //cpp:ray_cpp_pkg
pip install -e python --verbose
bazel build //cpp/example:example
| Option 1: run the example directly with a dynamic library path. It will start a Ray cluster automatically.
Expand Down
11 changes: 7 additions & 4 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def download_pickle5(pickle5_dir):
wzf.close()


def build(build_python, build_java):
def build(build_python, build_java, build_cpp):
if tuple(sys.version_info[:2]) not in SUPPORTED_PYTHONS:
msg = ("Detected Python version {}, which is not supported. "
"Only Python {} are supported.").format(
Expand Down Expand Up @@ -290,6 +290,7 @@ def build(build_python, build_java):

bazel_targets = []
bazel_targets += ["//:ray_pkg"] if build_python else []
bazel_targets += ["//cpp:ray_cpp_pkg"] if build_cpp else []
bazel_targets += ["//java:ray_java_pkg"] if build_java else []
return bazel_invoke(
subprocess.check_call,
Expand Down Expand Up @@ -336,7 +337,7 @@ def find_version(*filepath):


def pip_run(build_ext):
build(True, BUILD_JAVA)
build(True, BUILD_JAVA, True)

files_to_include = list(ray_files)

Expand Down Expand Up @@ -368,7 +369,7 @@ def api_main(program, *args):
parser.add_argument(
"-l",
"--language",
default="python",
default="python,cpp",
type=str,
help="A list of languages to build native libraries. "
"Supported languages include \"python\" and \"java\". "
Expand All @@ -378,12 +379,14 @@ def api_main(program, *args):
result = None

if parsed_args.command == "build":
kwargs = dict(build_python=False, build_java=False)
kwargs = dict(build_python=False, build_java=False, build_cpp=False)
for lang in parsed_args.language.split(","):
if "python" in lang:
kwargs.update(build_python=True)
elif "java" in lang:
kwargs.update(build_java=True)
elif "cpp" in lang:
kwargs.update(build_cpp=True)
else:
raise ValueError("invalid language: {!r}".format(lang))
result = build(**kwargs)
Expand Down

0 comments on commit 41b9a51

Please sign in to comment.