mirror of
https://github.com/wassname/ray.git
synced 2026-08-05 13:21:03 +08:00
[Core] Added support for submission-time task names. (#10449)
* Added support for submission-time task names. * Suggestions from code review: add missing consts Co-authored-by: SangBin Cho <rkooo567@gmail.com> * Add num_returns arg to actor method options docstring example. * Add process name line and proctitle assertion to submission-time task name section of advanced docs. * Add submission-time task name --> proctitle test for Python worker. * Added Python actor options tests for num_returns and name. * Added Java test for submission-time task names. * Add dashboard image to task name docs section. * Move to fstrings. Co-authored-by: SangBin Cho <rkooo567@gmail.com>
This commit is contained in:
co-authored by
SangBin Cho
parent
71274954d1
commit
0c0b0d0a73
@@ -51,7 +51,14 @@ class FunctionDescriptorInterface : public MessageWrapper<rpc::FunctionDescripto
|
||||
virtual std::string ToString() const = 0;
|
||||
|
||||
// A one-word summary of the function call site (e.g., __main__.foo).
|
||||
virtual std::string CallSiteString() const { return ToString(); }
|
||||
virtual std::string CallSiteString() const { return CallString(); }
|
||||
|
||||
// The function or method call, e.g. "foo()" or "Bar.foo()". This does not include the
|
||||
// module/library.
|
||||
virtual std::string CallString() const = 0;
|
||||
|
||||
// The default name for a task that executes this function.
|
||||
virtual std::string DefaultTaskName() const { return CallString() + "()"; }
|
||||
|
||||
template <typename Subtype>
|
||||
Subtype *As() {
|
||||
@@ -79,6 +86,8 @@ class EmptyFunctionDescriptor : public FunctionDescriptorInterface {
|
||||
inline bool operator!=(const EmptyFunctionDescriptor &other) const { return false; }
|
||||
|
||||
virtual std::string ToString() const { return "{type=EmptyFunctionDescriptor}"; }
|
||||
|
||||
virtual std::string CallString() const { return ""; }
|
||||
};
|
||||
|
||||
class JavaFunctionDescriptor : public FunctionDescriptorInterface {
|
||||
@@ -120,6 +129,12 @@ class JavaFunctionDescriptor : public FunctionDescriptorInterface {
|
||||
", signature=" + typed_message_->signature() + "}";
|
||||
}
|
||||
|
||||
virtual std::string CallString() const {
|
||||
const std::string &class_name = typed_message_->class_name();
|
||||
const std::string &function_name = typed_message_->function_name();
|
||||
return class_name.empty() ? function_name : class_name + "." + function_name;
|
||||
}
|
||||
|
||||
const std::string &ClassName() const { return typed_message_->class_name(); }
|
||||
|
||||
const std::string &FunctionName() const { return typed_message_->function_name(); }
|
||||
@@ -174,8 +189,13 @@ class PythonFunctionDescriptor : public FunctionDescriptorInterface {
|
||||
}
|
||||
|
||||
virtual std::string CallSiteString() const {
|
||||
return typed_message_->module_name() + "." + typed_message_->class_name() + "." +
|
||||
typed_message_->function_name();
|
||||
return typed_message_->module_name() + "." + CallString();
|
||||
}
|
||||
|
||||
virtual std::string CallString() const {
|
||||
const std::string &class_name = typed_message_->class_name();
|
||||
const std::string &function_name = typed_message_->function_name();
|
||||
return class_name.empty() ? function_name : class_name + "." + function_name;
|
||||
}
|
||||
|
||||
const std::string &ModuleName() const { return typed_message_->module_name(); }
|
||||
@@ -229,6 +249,12 @@ class CppFunctionDescriptor : public FunctionDescriptorInterface {
|
||||
", exec_function_offset=" + typed_message_->exec_function_offset() + "}";
|
||||
}
|
||||
|
||||
virtual std::string CallString() const {
|
||||
return typed_message_->lib_name() + "+" + typed_message_->function_offset();
|
||||
}
|
||||
|
||||
virtual std::string DefaultTaskName() const { return CallString(); }
|
||||
|
||||
const std::string &LibName() const { return typed_message_->lib_name(); }
|
||||
|
||||
const std::string &FunctionOffset() const { return typed_message_->function_offset(); }
|
||||
|
||||
@@ -192,6 +192,8 @@ bool TaskSpecification::IsDriverTask() const {
|
||||
return message_->type() == TaskType::DRIVER_TASK;
|
||||
}
|
||||
|
||||
const std::string TaskSpecification::GetName() const { return message_->name(); }
|
||||
|
||||
Language TaskSpecification::GetLanguage() const { return message_->language(); }
|
||||
|
||||
bool TaskSpecification::IsNormalTask() const {
|
||||
@@ -299,8 +301,9 @@ std::string TaskSpecification::DebugString() const {
|
||||
// Print function descriptor.
|
||||
stream << FunctionDescriptor()->ToString();
|
||||
|
||||
stream << ", task_id=" << TaskId() << ", job_id=" << JobId()
|
||||
<< ", num_args=" << NumArgs() << ", num_returns=" << NumReturns();
|
||||
stream << ", task_id=" << TaskId() << ", task_name=" << GetName()
|
||||
<< ", job_id=" << JobId() << ", num_args=" << NumArgs()
|
||||
<< ", num_returns=" << NumReturns();
|
||||
|
||||
if (IsActorCreationTask()) {
|
||||
// Print actor creation task spec.
|
||||
|
||||
@@ -135,6 +135,9 @@ class TaskSpecification : public MessageWrapper<rpc::TaskSpec> {
|
||||
|
||||
Language GetLanguage() const;
|
||||
|
||||
// Returns the task's name.
|
||||
const std::string GetName() const;
|
||||
|
||||
/// Whether this task is a normal task.
|
||||
bool IsNormalTask() const;
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class TaskSpecBuilder {
|
||||
///
|
||||
/// \return Reference to the builder object itself.
|
||||
TaskSpecBuilder &SetCommonTaskSpec(
|
||||
const TaskID &task_id, const Language &language,
|
||||
const TaskID &task_id, const std::string name, const Language &language,
|
||||
const ray::FunctionDescriptor &function_descriptor, const JobID &job_id,
|
||||
const TaskID &parent_task_id, uint64_t parent_counter, const TaskID &caller_id,
|
||||
const rpc::Address &caller_address, uint64_t num_returns,
|
||||
@@ -88,6 +88,7 @@ class TaskSpecBuilder {
|
||||
const std::unordered_map<std::string, double> &required_placement_resources,
|
||||
const PlacementGroupID &placement_group_id) {
|
||||
message_->set_type(TaskType::NORMAL_TASK);
|
||||
message_->set_name(name);
|
||||
message_->set_language(language);
|
||||
*message_->mutable_function_descriptor() = function_descriptor->GetMessage();
|
||||
message_->set_job_id(job_id.Binary());
|
||||
|
||||
@@ -54,9 +54,12 @@ class RayFunction {
|
||||
/// Options for all tasks (actor and non-actor) except for actor creation.
|
||||
struct TaskOptions {
|
||||
TaskOptions() {}
|
||||
TaskOptions(int num_returns, std::unordered_map<std::string, double> &resources)
|
||||
: num_returns(num_returns), resources(resources) {}
|
||||
TaskOptions(std::string name, int num_returns,
|
||||
std::unordered_map<std::string, double> &resources)
|
||||
: name(name), num_returns(num_returns), resources(resources) {}
|
||||
|
||||
/// The name of this task.
|
||||
std::string name;
|
||||
/// Number of returns of this task.
|
||||
int num_returns = 1;
|
||||
/// Resources required by this task.
|
||||
|
||||
@@ -32,15 +32,16 @@ const int kInternalHeartbeatMillis = 1000;
|
||||
|
||||
void BuildCommonTaskSpec(
|
||||
ray::TaskSpecBuilder &builder, const JobID &job_id, const TaskID &task_id,
|
||||
const TaskID ¤t_task_id, const int task_index, const TaskID &caller_id,
|
||||
const ray::rpc::Address &address, const ray::RayFunction &function,
|
||||
const std::string name, const TaskID ¤t_task_id, const int task_index,
|
||||
const TaskID &caller_id, const ray::rpc::Address &address,
|
||||
const ray::RayFunction &function,
|
||||
const std::vector<std::unique_ptr<ray::TaskArg>> &args, uint64_t num_returns,
|
||||
const std::unordered_map<std::string, double> &required_resources,
|
||||
const std::unordered_map<std::string, double> &required_placement_resources,
|
||||
std::vector<ObjectID> *return_ids, const ray::PlacementGroupID &placement_group_id) {
|
||||
// Build common task spec.
|
||||
builder.SetCommonTaskSpec(
|
||||
task_id, function.GetLanguage(), function.GetFunctionDescriptor(), job_id,
|
||||
task_id, name, function.GetLanguage(), function.GetFunctionDescriptor(), job_id,
|
||||
current_task_id, task_index, caller_id, address, num_returns, required_resources,
|
||||
required_placement_resources, placement_group_id);
|
||||
// Set task arguments.
|
||||
@@ -1268,8 +1269,11 @@ void CoreWorker::SubmitTask(const RayFunction &function,
|
||||
auto constrained_resources = AddPlacementGroupConstraint(
|
||||
task_options.resources, placement_options.first, placement_options.second);
|
||||
const std::unordered_map<std::string, double> required_resources;
|
||||
auto task_name = task_options.name.empty()
|
||||
? function.GetFunctionDescriptor()->DefaultTaskName()
|
||||
: task_options.name;
|
||||
// TODO(ekl) offload task building onto a thread pool for performance
|
||||
BuildCommonTaskSpec(builder, worker_context_.GetCurrentJobID(), task_id,
|
||||
BuildCommonTaskSpec(builder, worker_context_.GetCurrentJobID(), task_id, task_name,
|
||||
worker_context_.GetCurrentTaskID(), next_task_index, GetCallerId(),
|
||||
rpc_address_, function, args, task_options.num_returns,
|
||||
constrained_resources, required_resources, return_ids,
|
||||
@@ -1310,16 +1314,21 @@ Status CoreWorker::CreateActor(const RayFunction &function,
|
||||
auto new_resource = AddPlacementGroupConstraint(
|
||||
actor_creation_options.resources, actor_creation_options.placement_options.first,
|
||||
actor_creation_options.placement_options.second);
|
||||
BuildCommonTaskSpec(builder, job_id, actor_creation_task_id,
|
||||
const auto actor_name = actor_creation_options.name;
|
||||
const auto task_name =
|
||||
actor_name.empty()
|
||||
? function.GetFunctionDescriptor()->DefaultTaskName()
|
||||
: actor_name + ":" + function.GetFunctionDescriptor()->CallString();
|
||||
BuildCommonTaskSpec(builder, job_id, actor_creation_task_id, task_name,
|
||||
worker_context_.GetCurrentTaskID(), next_task_index, GetCallerId(),
|
||||
rpc_address_, function, args, 1, new_resource,
|
||||
new_placement_resources, &return_ids,
|
||||
actor_creation_options.placement_options.first);
|
||||
builder.SetActorCreationTaskSpec(
|
||||
actor_id, actor_creation_options.max_restarts,
|
||||
actor_creation_options.dynamic_worker_options,
|
||||
actor_creation_options.max_concurrency, actor_creation_options.is_detached,
|
||||
actor_creation_options.name, actor_creation_options.is_asyncio, extension_data);
|
||||
builder.SetActorCreationTaskSpec(actor_id, actor_creation_options.max_restarts,
|
||||
actor_creation_options.dynamic_worker_options,
|
||||
actor_creation_options.max_concurrency,
|
||||
actor_creation_options.is_detached, actor_name,
|
||||
actor_creation_options.is_asyncio, extension_data);
|
||||
|
||||
// Add the actor handle before we submit the actor creation task, since the
|
||||
// actor handle must be in scope by the time the GCS sends the
|
||||
@@ -1340,7 +1349,7 @@ Status CoreWorker::CreateActor(const RayFunction &function,
|
||||
if (task_spec.IsDetachedActor()) {
|
||||
// Since local mode doesn't pass GCS actor management code path,
|
||||
// it just register actor names in memory.
|
||||
local_mode_named_actor_registry_.emplace(actor_creation_options.name, actor_id);
|
||||
local_mode_named_actor_registry_.emplace(actor_name, actor_id);
|
||||
}
|
||||
ExecuteTaskLocalMode(task_spec);
|
||||
} else {
|
||||
@@ -1412,7 +1421,10 @@ void CoreWorker::SubmitActorTask(const ActorID &actor_id, const RayFunction &fun
|
||||
worker_context_.GetCurrentJobID(), worker_context_.GetCurrentTaskID(),
|
||||
next_task_index, actor_handle->GetActorID());
|
||||
const std::unordered_map<std::string, double> required_resources;
|
||||
BuildCommonTaskSpec(builder, actor_handle->CreationJobID(), actor_task_id,
|
||||
const auto task_name = task_options.name.empty()
|
||||
? function.GetFunctionDescriptor()->DefaultTaskName()
|
||||
: task_options.name;
|
||||
BuildCommonTaskSpec(builder, actor_handle->CreationJobID(), actor_task_id, task_name,
|
||||
worker_context_.GetCurrentTaskID(), next_task_index, GetCallerId(),
|
||||
rpc_address_, function, args, num_returns, task_options.resources,
|
||||
required_resources, return_ids, PlacementGroupID::Nil());
|
||||
@@ -1687,8 +1699,9 @@ Status CoreWorker::ExecuteTask(const TaskSpecification &task_spec,
|
||||
CoreWorkerProcess::SetCurrentThreadWorkerId(GetWorkerID());
|
||||
|
||||
status = options_.task_execution_callback(
|
||||
task_type, func, task_spec.GetRequiredResources().GetResourceMap(), args,
|
||||
arg_reference_ids, return_ids, return_objects);
|
||||
task_type, task_spec.GetName(), func,
|
||||
task_spec.GetRequiredResources().GetResourceMap(), args, arg_reference_ids,
|
||||
return_ids, return_objects);
|
||||
|
||||
absl::optional<rpc::Address> caller_address(
|
||||
options_.is_local_mode ? absl::optional<rpc::Address>()
|
||||
@@ -2143,6 +2156,7 @@ void CoreWorker::HandleGetCoreWorkerStats(const rpc::GetCoreWorkerStatsRequest &
|
||||
stats->set_task_queue_length(task_queue_length_);
|
||||
stats->set_num_executed_tasks(num_executed_tasks_);
|
||||
stats->set_num_object_refs_in_scope(reference_counter_->NumObjectIDsInScope());
|
||||
stats->set_current_task_name(current_task_.GetName());
|
||||
stats->set_current_task_func_desc(current_task_.FunctionDescriptor()->ToString());
|
||||
stats->set_ip_address(rpc_address_.ip_address());
|
||||
stats->set_port(rpc_address_.port());
|
||||
|
||||
@@ -57,7 +57,7 @@ struct CoreWorkerOptions {
|
||||
// Callback that must be implemented and provided by the language-specific worker
|
||||
// frontend to execute tasks and return their results.
|
||||
using TaskExecutionCallback = std::function<Status(
|
||||
TaskType task_type, const RayFunction &ray_function,
|
||||
TaskType task_type, const std::string task_name, const RayFunction &ray_function,
|
||||
const std::unordered_map<std::string, double> &required_resources,
|
||||
const std::vector<std::shared_ptr<RayObject>> &args,
|
||||
const std::vector<ObjectID> &arg_reference_ids,
|
||||
|
||||
@@ -105,7 +105,8 @@ JNIEXPORT void JNICALL Java_io_ray_runtime_RayNativeRuntime_nativeInitialize(
|
||||
RayConfig::instance().initialize(raylet_config);
|
||||
|
||||
auto task_execution_callback =
|
||||
[](ray::TaskType task_type, const ray::RayFunction &ray_function,
|
||||
[](ray::TaskType task_type, const std::string task_name,
|
||||
const ray::RayFunction &ray_function,
|
||||
const std::unordered_map<std::string, double> &required_resources,
|
||||
const std::vector<std::shared_ptr<ray::RayObject>> &args,
|
||||
const std::vector<ObjectID> &arg_reference_ids,
|
||||
|
||||
@@ -90,13 +90,18 @@ inline std::unordered_map<std::string, double> ToResources(JNIEnv *env,
|
||||
|
||||
inline ray::TaskOptions ToTaskOptions(JNIEnv *env, jint numReturns, jobject callOptions) {
|
||||
std::unordered_map<std::string, double> resources;
|
||||
std::string name = "";
|
||||
if (callOptions) {
|
||||
jobject java_resources =
|
||||
env->GetObjectField(callOptions, java_base_task_options_resources);
|
||||
resources = ToResources(env, java_resources);
|
||||
auto java_name = (jstring)env->GetObjectField(callOptions, java_call_options_name);
|
||||
if (java_name) {
|
||||
name = JavaStringToNativeString(env, java_name);
|
||||
}
|
||||
}
|
||||
|
||||
ray::TaskOptions task_options{numReturns, resources};
|
||||
ray::TaskOptions task_options{name, numReturns, resources};
|
||||
return task_options;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,9 @@ jfieldID java_function_arg_value;
|
||||
jclass java_base_task_options_class;
|
||||
jfieldID java_base_task_options_resources;
|
||||
|
||||
jclass java_call_options_class;
|
||||
jfieldID java_call_options_name;
|
||||
|
||||
jclass java_actor_creation_options_class;
|
||||
jfieldID java_actor_creation_options_global;
|
||||
jfieldID java_actor_creation_options_name;
|
||||
@@ -198,6 +201,10 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
java_base_task_options_resources =
|
||||
env->GetFieldID(java_base_task_options_class, "resources", "Ljava/util/Map;");
|
||||
|
||||
java_call_options_class = LoadClass(env, "io/ray/api/options/CallOptions");
|
||||
java_call_options_name =
|
||||
env->GetFieldID(java_call_options_class, "name", "Ljava/lang/String;");
|
||||
|
||||
java_placement_group_class =
|
||||
LoadClass(env, "io/ray/runtime/placementgroup/PlacementGroupImpl");
|
||||
java_placement_group_id =
|
||||
|
||||
@@ -128,6 +128,11 @@ extern jclass java_base_task_options_class;
|
||||
/// resources field of BaseTaskOptions class
|
||||
extern jfieldID java_base_task_options_resources;
|
||||
|
||||
/// CallOptions class
|
||||
extern jclass java_call_options_class;
|
||||
/// name field of CallOptions class
|
||||
extern jfieldID java_call_options_name;
|
||||
|
||||
/// ActorCreationOptions class
|
||||
extern jclass java_actor_creation_options_class;
|
||||
/// global field of ActorCreationOptions class
|
||||
|
||||
@@ -226,7 +226,7 @@ bool CoreWorkerTest::WaitForDirectCallActorState(const ActorID &actor_id, bool w
|
||||
int CoreWorkerTest::GetActorPid(const ActorID &actor_id,
|
||||
std::unordered_map<std::string, double> &resources) {
|
||||
std::vector<std::unique_ptr<TaskArg>> args;
|
||||
TaskOptions options{1, resources};
|
||||
TaskOptions options{"", 1, resources};
|
||||
std::vector<ObjectID> return_ids;
|
||||
RayFunction func{Language::PYTHON, ray::FunctionDescriptorBuilder::BuildPython(
|
||||
"GetWorkerPid", "", "", "")};
|
||||
@@ -308,7 +308,7 @@ void CoreWorkerTest::TestActorTask(std::unordered_map<std::string, double> &reso
|
||||
args.emplace_back(new TaskArgByValue(
|
||||
std::make_shared<RayObject>(buffer2, nullptr, std::vector<ObjectID>())));
|
||||
|
||||
TaskOptions options{1, resources};
|
||||
TaskOptions options{"", 1, resources};
|
||||
std::vector<ObjectID> return_ids;
|
||||
RayFunction func(ray::Language::PYTHON, ray::FunctionDescriptorBuilder::BuildPython(
|
||||
"MergeInputArgsAsOutput", "", "", ""));
|
||||
@@ -350,7 +350,7 @@ void CoreWorkerTest::TestActorTask(std::unordered_map<std::string, double> &reso
|
||||
args.emplace_back(new TaskArgByValue(
|
||||
std::make_shared<RayObject>(buffer2, nullptr, std::vector<ObjectID>())));
|
||||
|
||||
TaskOptions options{1, resources};
|
||||
TaskOptions options{"", 1, resources};
|
||||
std::vector<ObjectID> return_ids;
|
||||
RayFunction func(ray::Language::PYTHON, ray::FunctionDescriptorBuilder::BuildPython(
|
||||
"MergeInputArgsAsOutput", "", "", ""));
|
||||
@@ -412,7 +412,7 @@ void CoreWorkerTest::TestActorRestart(
|
||||
args.emplace_back(new TaskArgByValue(
|
||||
std::make_shared<RayObject>(buffer1, nullptr, std::vector<ObjectID>())));
|
||||
|
||||
TaskOptions options{1, resources};
|
||||
TaskOptions options{"", 1, resources};
|
||||
std::vector<ObjectID> return_ids;
|
||||
RayFunction func(ray::Language::PYTHON, ray::FunctionDescriptorBuilder::BuildPython(
|
||||
"MergeInputArgsAsOutput", "", "", ""));
|
||||
@@ -455,7 +455,7 @@ void CoreWorkerTest::TestActorFailure(
|
||||
args.emplace_back(new TaskArgByValue(
|
||||
std::make_shared<RayObject>(buffer1, nullptr, std::vector<ObjectID>())));
|
||||
|
||||
TaskOptions options{1, resources};
|
||||
TaskOptions options{"", 1, resources};
|
||||
std::vector<ObjectID> return_ids;
|
||||
RayFunction func(ray::Language::PYTHON, ray::FunctionDescriptorBuilder::BuildPython(
|
||||
"MergeInputArgsAsOutput", "", "", ""));
|
||||
@@ -539,12 +539,12 @@ TEST_F(ZeroNodeTest, TestTaskSpecPerf) {
|
||||
RAY_LOG(INFO) << "start creating " << num_tasks << " PushTaskRequests";
|
||||
rpc::Address address;
|
||||
for (int i = 0; i < num_tasks; i++) {
|
||||
TaskOptions options{1, resources};
|
||||
TaskOptions options{"", 1, resources};
|
||||
std::vector<ObjectID> return_ids;
|
||||
auto num_returns = options.num_returns;
|
||||
|
||||
TaskSpecBuilder builder;
|
||||
builder.SetCommonTaskSpec(RandomTaskId(), function.GetLanguage(),
|
||||
builder.SetCommonTaskSpec(RandomTaskId(), options.name, function.GetLanguage(),
|
||||
function.GetFunctionDescriptor(), job_id, RandomTaskId(), 0,
|
||||
RandomTaskId(), address, num_returns, resources, resources,
|
||||
PlacementGroupID::Nil());
|
||||
@@ -587,7 +587,7 @@ TEST_F(SingleNodeTest, TestDirectActorTaskSubmissionPerf) {
|
||||
args.emplace_back(new TaskArgByValue(
|
||||
std::make_shared<RayObject>(buffer, nullptr, std::vector<ObjectID>())));
|
||||
|
||||
TaskOptions options{1, resources};
|
||||
TaskOptions options{"", 1, resources};
|
||||
std::vector<ObjectID> return_ids;
|
||||
RayFunction func(ray::Language::PYTHON, ray::FunctionDescriptorBuilder::BuildPython(
|
||||
"MergeInputArgsAsOutput", "", "", ""));
|
||||
|
||||
@@ -324,9 +324,10 @@ TaskSpecification BuildTaskSpec(const std::unordered_map<std::string, double> &r
|
||||
const ray::FunctionDescriptor &function_descriptor) {
|
||||
TaskSpecBuilder builder;
|
||||
rpc::Address empty_address;
|
||||
builder.SetCommonTaskSpec(TaskID::Nil(), Language::PYTHON, function_descriptor,
|
||||
JobID::Nil(), TaskID::Nil(), 0, TaskID::Nil(), empty_address,
|
||||
1, resources, resources, PlacementGroupID::Nil());
|
||||
builder.SetCommonTaskSpec(TaskID::Nil(), "dummy_task", Language::PYTHON,
|
||||
function_descriptor, JobID::Nil(), TaskID::Nil(), 0,
|
||||
TaskID::Nil(), empty_address, 1, resources, resources,
|
||||
PlacementGroupID::Nil());
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ class MockWorker {
|
||||
"", // driver_name
|
||||
"", // stdout_file
|
||||
"", // stderr_file
|
||||
std::bind(&MockWorker::ExecuteTask, this, _1, _2, _3, _4, _5, _6,
|
||||
_7), // task_execution_callback
|
||||
std::bind(&MockWorker::ExecuteTask, this, _1, _2, _3, _4, _5, _6, _7,
|
||||
_8), // task_execution_callback
|
||||
nullptr, // check_signals
|
||||
nullptr, // gc_collect
|
||||
nullptr, // spill_objects
|
||||
@@ -71,7 +71,8 @@ class MockWorker {
|
||||
void RunTaskExecutionLoop() { CoreWorkerProcess::RunTaskExecutionLoop(); }
|
||||
|
||||
private:
|
||||
Status ExecuteTask(TaskType task_type, const RayFunction &ray_function,
|
||||
Status ExecuteTask(TaskType task_type, const std::string task_name,
|
||||
const RayFunction &ray_function,
|
||||
const std::unordered_map<std::string, double> &required_resources,
|
||||
const std::vector<std::shared_ptr<RayObject>> &args,
|
||||
const std::vector<ObjectID> &arg_reference_ids,
|
||||
|
||||
@@ -38,9 +38,10 @@ struct Mocker {
|
||||
auto actor_id = ActorID::Of(job_id, RandomTaskId(), 0);
|
||||
auto task_id = TaskID::ForActorCreationTask(actor_id);
|
||||
auto resource = std::unordered_map<std::string, double>();
|
||||
builder.SetCommonTaskSpec(task_id, Language::PYTHON, empty_descriptor, job_id,
|
||||
TaskID::Nil(), 0, TaskID::Nil(), owner_address, 1, resource,
|
||||
resource, PlacementGroupID::Nil());
|
||||
builder.SetCommonTaskSpec(task_id, name + ":" + empty_descriptor->CallString(),
|
||||
Language::PYTHON, empty_descriptor, job_id, TaskID::Nil(),
|
||||
0, TaskID::Nil(), owner_address, 1, resource, resource,
|
||||
PlacementGroupID::Nil());
|
||||
builder.SetActorCreationTaskSpec(actor_id, max_restarts, {}, 1, detached, name);
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
@@ -150,42 +150,44 @@ message RayException {
|
||||
message TaskSpec {
|
||||
// Type of this task.
|
||||
TaskType type = 1;
|
||||
// Name of this task.
|
||||
string name = 2;
|
||||
// Language of this task.
|
||||
Language language = 2;
|
||||
Language language = 3;
|
||||
// Function descriptor of this task uniquely describe the function to execute.
|
||||
FunctionDescriptor function_descriptor = 3;
|
||||
FunctionDescriptor function_descriptor = 4;
|
||||
// ID of the job that this task belongs to.
|
||||
bytes job_id = 4;
|
||||
bytes job_id = 5;
|
||||
// Task ID of the task.
|
||||
bytes task_id = 5;
|
||||
bytes task_id = 6;
|
||||
// Task ID of the parent task.
|
||||
bytes parent_task_id = 6;
|
||||
bytes parent_task_id = 7;
|
||||
// A count of the number of tasks submitted by the parent task before this one.
|
||||
uint64 parent_counter = 7;
|
||||
uint64 parent_counter = 8;
|
||||
// Task ID of the caller. This is the same as parent_task_id for non-actors.
|
||||
// This is the actor ID (embedded in a nil task ID) for actors.
|
||||
bytes caller_id = 8;
|
||||
bytes caller_id = 9;
|
||||
/// Address of the caller.
|
||||
Address caller_address = 9;
|
||||
Address caller_address = 10;
|
||||
// Task arguments.
|
||||
repeated TaskArg args = 10;
|
||||
repeated TaskArg args = 11;
|
||||
// Number of return objects.
|
||||
uint64 num_returns = 11;
|
||||
uint64 num_returns = 12;
|
||||
// Quantities of the different resources required by this task.
|
||||
map<string, double> required_resources = 12;
|
||||
map<string, double> required_resources = 13;
|
||||
// The resources required for placing this task on a node. If this is empty,
|
||||
// then the placement resources are equal to the required_resources.
|
||||
map<string, double> required_placement_resources = 13;
|
||||
map<string, double> required_placement_resources = 14;
|
||||
// Task specification for an actor creation task.
|
||||
// This field is only valid when `type == ACTOR_CREATION_TASK`.
|
||||
ActorCreationTaskSpec actor_creation_task_spec = 14;
|
||||
ActorCreationTaskSpec actor_creation_task_spec = 15;
|
||||
// Task specification for an actor task.
|
||||
// This field is only valid when `type == ACTOR_TASK`.
|
||||
ActorTaskSpec actor_task_spec = 15;
|
||||
ActorTaskSpec actor_task_spec = 16;
|
||||
// Number of times this task may be retried on worker failure.
|
||||
int32 max_retries = 16;
|
||||
int32 max_retries = 17;
|
||||
// Placement group that is associated with this task.
|
||||
bytes placement_group_id = 17;
|
||||
bytes placement_group_id = 18;
|
||||
}
|
||||
|
||||
message Bundle {
|
||||
@@ -358,34 +360,36 @@ message CoreWorkerStats {
|
||||
int32 num_pending_tasks = 2;
|
||||
// Number of object refs in local scope.
|
||||
int32 num_object_refs_in_scope = 3;
|
||||
// Name of the currently executing task.
|
||||
string current_task_name = 4;
|
||||
// String representation of the function descriptor of the currently executing task.
|
||||
string current_task_func_desc = 4;
|
||||
string current_task_func_desc = 5;
|
||||
// IP address of the core worker.
|
||||
string ip_address = 6;
|
||||
string ip_address = 7;
|
||||
// Port of the core worker.
|
||||
int64 port = 7;
|
||||
int64 port = 8;
|
||||
// Actor ID.
|
||||
bytes actor_id = 8;
|
||||
bytes actor_id = 9;
|
||||
// A map from the resource name (e.g. "CPU") to its allocation.
|
||||
map<string, ResourceAllocations> used_resources = 9;
|
||||
map<string, ResourceAllocations> used_resources = 10;
|
||||
// A string displayed on Dashboard.
|
||||
map<string, string> webui_display = 10;
|
||||
map<string, string> webui_display = 11;
|
||||
// Number of objects that are IN_PLASMA_ERROR in the local memory store.
|
||||
int32 num_in_plasma = 11;
|
||||
int32 num_in_plasma = 12;
|
||||
// Number of objects stored in local memory.
|
||||
int32 num_local_objects = 12;
|
||||
int32 num_local_objects = 13;
|
||||
// Used local object store memory.
|
||||
int64 used_object_store_memory = 13;
|
||||
int64 used_object_store_memory = 14;
|
||||
// Length of the task queue.
|
||||
int32 task_queue_length = 14;
|
||||
int32 task_queue_length = 15;
|
||||
// Number of executed tasks.
|
||||
int32 num_executed_tasks = 15;
|
||||
int32 num_executed_tasks = 16;
|
||||
// Actor constructor.
|
||||
string actor_title = 16;
|
||||
string actor_title = 17;
|
||||
// Local reference table.
|
||||
repeated ObjectRefInfo object_refs = 17;
|
||||
repeated ObjectRefInfo object_refs = 18;
|
||||
// Job ID.
|
||||
bytes job_id = 18;
|
||||
bytes job_id = 19;
|
||||
}
|
||||
|
||||
message MetricPoint {
|
||||
|
||||
@@ -264,7 +264,7 @@ Task CreateTask(const std::unordered_map<std::string, double> &required_resource
|
||||
TaskID id = RandomTaskId();
|
||||
JobID job_id = RandomJobId();
|
||||
rpc::Address address;
|
||||
spec_builder.SetCommonTaskSpec(id, Language::PYTHON,
|
||||
spec_builder.SetCommonTaskSpec(id, "dummy_task", Language::PYTHON,
|
||||
FunctionDescriptorBuilder::BuildPython("", "", "", ""),
|
||||
job_id, TaskID::Nil(), 0, TaskID::Nil(), address, 0,
|
||||
required_resources, {}, PlacementGroupID::Nil());
|
||||
@@ -489,4 +489,4 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
} // namespace raylet
|
||||
} // namespace ray
|
||||
} // namespace ray
|
||||
|
||||
@@ -65,7 +65,7 @@ static inline Task ExampleTask(const std::vector<ObjectID> &arguments,
|
||||
uint64_t num_returns) {
|
||||
TaskSpecBuilder builder;
|
||||
rpc::Address address;
|
||||
builder.SetCommonTaskSpec(RandomTaskId(), Language::PYTHON,
|
||||
builder.SetCommonTaskSpec(RandomTaskId(), "example_task", Language::PYTHON,
|
||||
FunctionDescriptorBuilder::BuildPython("", "", "", ""),
|
||||
JobID::Nil(), RandomTaskId(), 0, RandomTaskId(), address,
|
||||
num_returns, {}, {}, PlacementGroupID::Nil());
|
||||
|
||||
Reference in New Issue
Block a user