Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core][C++ Worker]Add error message for unsupported Object Ref parameters in C++ Worker #36414

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cpp/include/ray/api/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ class Arguments {
std::vector<TaskArg> *task_args,
InputArgTypes &&arg) {
if constexpr (is_object_ref_v<OriginArgType>) {
PushReferenceArg(task_args, std::forward<InputArgTypes>(arg));
if (RayRuntimeHolder::Instance().Runtime()->IsLocalMode()) {
PushReferenceArg(task_args, std::forward<InputArgTypes>(arg));
} else {
// After the Object Ref parameter is supported, this exception will be deleted.
throw std::invalid_argument(
"At present, the Ray C++ API does not support the passing of "
"`ray::ObjectRef` parameters. Will support later.");
}
} else if constexpr (is_object_ref_v<InputArgTypes>) {
// core_worker submitting task callback will get the value of an ObjectRef arg, but
// local mode we don't call core_worker submit task, so we need get the value of an
Expand Down
11 changes: 11 additions & 0 deletions cpp/src/ray/test/cluster/cluster_mode_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,17 @@ TEST(RayClusterModeTest, RuntimeEnvJobLevelEnvVarsTest) {
ray::Shutdown();
}

TEST(RayClusterModeTest, UnsupportObjectRefTest) {
ray::RayConfig config;
ray::Init(config, cmd_argc, cmd_argv);
ray::ActorHandle<Counter> actor = ray::Actor(RAY_FUNC(Counter::FactoryCreate)).Remote();
auto int_ref = ray::Put(1);
EXPECT_THROW(actor.Task(&Counter::GetIntByObjectRef).Remote(int_ref),
std::invalid_argument);

ray::Shutdown();
}

int main(int argc, char **argv) {
absl::ParseCommandLine(argc, argv);
cmd_argc = argc;
Expand Down
7 changes: 6 additions & 1 deletion cpp/src/ray/test/cluster/counter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ int Counter::Plus1ForActor(ray::ActorHandle<Counter> actor) {
return *actor.Task(&Counter::Plus1).Remote().Get();
}

int Counter::GetIntByObjectRef(ray::ObjectRef<int> object_ref) {
return *object_ref.Get();
}

RAY_REMOTE(RAY_FUNC(Counter::FactoryCreate),
Counter::FactoryCreateException,
RAY_FUNC(Counter::FactoryCreate, int),
Expand All @@ -124,7 +128,8 @@ RAY_REMOTE(RAY_FUNC(Counter::FactoryCreate),
&Counter::CreateNestedChildActor,
&Counter::GetBytes,
&Counter::echoBytes,
&Counter::echoString);
&Counter::echoString,
&Counter::GetIntByObjectRef);

RAY_REMOTE(ActorConcurrentCall::FactoryCreate, &ActorConcurrentCall::CountDown);

Expand Down
2 changes: 2 additions & 0 deletions cpp/src/ray/test/cluster/counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class Counter {
return value == NULL ? "" : std::string(value);
}

int GetIntByObjectRef(ray::ObjectRef<int> object_ref);

private:
int count;
bool is_restared = false;
Expand Down
Loading