mirror of
https://github.com/wassname/ray.git
synced 2026-09-11 12:43:20 +08:00
Prototype distributed actor handles (#1137)
* Add actor handle ID to the task spec * Local scheduler dispatches actor tasks according to a task counter per handle * Fix python test * Allow passing actor handles into tasks. Not completely working yet. Also this is very messy. * Fixes, should be roughly working now. * Refactor actor handle wrapper * Fix __init__ tests * Terminate actor when the original handle goes out of scope * TODO and a couple test cases * Make tests for unsupported cases * Fix Python mode tests * Linting. * Cache actor definitions that occur before ray.init() is called. * Fix export actor class * Deterministically compute actor handle ID * Fix __getattribute__ * Fix string encoding for python3 * doc * Add comment and assertion.
This commit is contained in:
committed by
Robert Nishihara
parent
2f45ac9e95
commit
af47737bd5
@@ -14,7 +14,8 @@ static inline TaskSpec *example_task_spec_with_args(int64_t num_args,
|
||||
TaskID parent_task_id = globally_unique_id();
|
||||
FunctionID func_id = globally_unique_id();
|
||||
TaskSpec_start_construct(g_task_builder, NIL_ID, parent_task_id, 0,
|
||||
NIL_ACTOR_ID, 0, false, func_id, num_returns);
|
||||
NIL_ACTOR_ID, NIL_ACTOR_ID, 0, false, func_id,
|
||||
num_returns);
|
||||
for (int64_t i = 0; i < num_args; ++i) {
|
||||
ObjectID arg_id;
|
||||
if (arg_ids == NULL) {
|
||||
|
||||
@@ -15,8 +15,8 @@ TEST task_test(void) {
|
||||
TaskID parent_task_id = globally_unique_id();
|
||||
FunctionID func_id = globally_unique_id();
|
||||
TaskBuilder *builder = make_task_builder();
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID, 0,
|
||||
false, func_id, 2);
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID,
|
||||
NIL_ACTOR_ID, 0, false, func_id, 2);
|
||||
|
||||
UniqueID arg1 = globally_unique_id();
|
||||
TaskSpec_args_add_ref(builder, arg1);
|
||||
@@ -54,16 +54,16 @@ TEST deterministic_ids_test(void) {
|
||||
uint8_t *arg2 = (uint8_t *) "hello world";
|
||||
|
||||
/* Construct a first task. */
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID, 0,
|
||||
false, func_id, 3);
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID,
|
||||
NIL_ACTOR_ID, 0, false, func_id, 3);
|
||||
TaskSpec_args_add_ref(builder, arg1);
|
||||
TaskSpec_args_add_val(builder, arg2, 11);
|
||||
int64_t size1;
|
||||
TaskSpec *spec1 = TaskSpec_finish_construct(builder, &size1);
|
||||
|
||||
/* Construct a second identical task. */
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID, 0,
|
||||
false, func_id, 3);
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID,
|
||||
NIL_ACTOR_ID, 0, false, func_id, 3);
|
||||
TaskSpec_args_add_ref(builder, arg1);
|
||||
TaskSpec_args_add_val(builder, arg2, 11);
|
||||
int64_t size2;
|
||||
@@ -83,39 +83,39 @@ TEST deterministic_ids_test(void) {
|
||||
|
||||
/* Construct a task with a different parent task ID. */
|
||||
TaskSpec_start_construct(builder, NIL_ID, globally_unique_id(), 0,
|
||||
NIL_ACTOR_ID, 0, false, func_id, 3);
|
||||
NIL_ACTOR_ID, NIL_ACTOR_ID, 0, false, func_id, 3);
|
||||
TaskSpec_args_add_ref(builder, arg1);
|
||||
TaskSpec_args_add_val(builder, arg2, 11);
|
||||
int64_t size3;
|
||||
TaskSpec *spec3 = TaskSpec_finish_construct(builder, &size3);
|
||||
|
||||
/* Construct a task with a different parent counter. */
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 1, NIL_ACTOR_ID, 0,
|
||||
false, func_id, 3);
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 1, NIL_ACTOR_ID,
|
||||
NIL_ACTOR_ID, 0, false, func_id, 3);
|
||||
TaskSpec_args_add_ref(builder, arg1);
|
||||
TaskSpec_args_add_val(builder, arg2, 11);
|
||||
int64_t size4;
|
||||
TaskSpec *spec4 = TaskSpec_finish_construct(builder, &size4);
|
||||
|
||||
/* Construct a task with a different function ID. */
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID, 0,
|
||||
false, globally_unique_id(), 3);
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID,
|
||||
NIL_ACTOR_ID, 0, false, globally_unique_id(), 3);
|
||||
TaskSpec_args_add_ref(builder, arg1);
|
||||
TaskSpec_args_add_val(builder, arg2, 11);
|
||||
int64_t size5;
|
||||
TaskSpec *spec5 = TaskSpec_finish_construct(builder, &size5);
|
||||
|
||||
/* Construct a task with a different object ID argument. */
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID, 0,
|
||||
false, func_id, 3);
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID,
|
||||
NIL_ACTOR_ID, 0, false, func_id, 3);
|
||||
TaskSpec_args_add_ref(builder, globally_unique_id());
|
||||
TaskSpec_args_add_val(builder, arg2, 11);
|
||||
int64_t size6;
|
||||
TaskSpec *spec6 = TaskSpec_finish_construct(builder, &size6);
|
||||
|
||||
/* Construct a task with a different value argument. */
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID, 0,
|
||||
false, func_id, 3);
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID,
|
||||
NIL_ACTOR_ID, 0, false, func_id, 3);
|
||||
TaskSpec_args_add_ref(builder, arg1);
|
||||
TaskSpec_args_add_val(builder, (uint8_t *) "hello_world", 11);
|
||||
int64_t size7;
|
||||
@@ -159,8 +159,8 @@ TEST send_task(void) {
|
||||
TaskBuilder *builder = make_task_builder();
|
||||
TaskID parent_task_id = globally_unique_id();
|
||||
FunctionID func_id = globally_unique_id();
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID, 0,
|
||||
false, func_id, 2);
|
||||
TaskSpec_start_construct(builder, NIL_ID, parent_task_id, 0, NIL_ACTOR_ID,
|
||||
NIL_ACTOR_ID, 0, false, func_id, 2);
|
||||
TaskSpec_args_add_ref(builder, globally_unique_id());
|
||||
TaskSpec_args_add_val(builder, (uint8_t *) "Hello", 5);
|
||||
TaskSpec_args_add_val(builder, (uint8_t *) "World", 5);
|
||||
|
||||
Reference in New Issue
Block a user