mirror of
https://github.com/wassname/ray.git
synced 2026-07-27 11:26:41 +08:00
Changed ray.select() to ray.wait() and its functionality (#426)
* Re-implemented select, changed name to wait * Changed tests for select to tests for wait * Updated the hyperopt example to match wait * Small fixes and improve example readme. * Make tests pass.
This commit is contained in:
+3
-3
@@ -892,7 +892,7 @@ static PyObject* request_object(PyObject* self, PyObject* args) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* ray_select(PyObject* self, PyObject* args) {
|
||||
static PyObject* wait(PyObject* self, PyObject* args) {
|
||||
Worker* worker;
|
||||
PyObject* objectids;
|
||||
if (!PyArg_ParseTuple(args, "O&O", &PyObjectToWorker, &worker, &objectids)) {
|
||||
@@ -904,7 +904,7 @@ static PyObject* ray_select(PyObject* self, PyObject* args) {
|
||||
PyObjectToObjectID(PyList_GetItem(objectids, i), &objectid);
|
||||
objectids_vec.push_back(objectid);
|
||||
}
|
||||
std::vector<int> indices = worker->select(objectids_vec);
|
||||
std::vector<int> indices = worker->wait(objectids_vec);
|
||||
PyObject* result = PyList_New(indices.size());
|
||||
for (size_t i = 0; i < indices.size(); ++i) {
|
||||
PyList_SetItem(result, i, PyInt_FromLong(indices[i]));
|
||||
@@ -1081,7 +1081,7 @@ static PyMethodDef RayLibMethods[] = {
|
||||
{ "add_contained_objectids", add_contained_objectids, METH_VARARGS, "notify the scheduler about the object IDs contained in a remote object" },
|
||||
{ "get_objectid", get_objectid, METH_VARARGS, "register a new object reference with the scheduler" },
|
||||
{ "request_object" , request_object, METH_VARARGS, "request an object to be delivered to the local object store" },
|
||||
{ "ray_select" , ray_select, METH_VARARGS, "checks the scheduler to see if a object can be gotten" },
|
||||
{ "wait" , wait, METH_VARARGS, "checks the scheduler to see if a object can be gotten" },
|
||||
{ "alias_objectids", alias_objectids, METH_VARARGS, "make two objectids refer to the same object" },
|
||||
{ "wait_for_next_message", wait_for_next_message, METH_VARARGS, "get next message from scheduler (blocking)" },
|
||||
{ "submit_task", submit_task, METH_VARARGS, "call a remote function" },
|
||||
|
||||
+1
-1
@@ -594,7 +594,7 @@ Status SchedulerService::ExportReusableVariable(ServerContext* context, const Ex
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
Status SchedulerService::Select(ServerContext* context, const SelectRequest* request, SelectReply* reply) {
|
||||
Status SchedulerService::Wait(ServerContext* context, const WaitRequest* request, WaitReply* reply) {
|
||||
auto objtable = GET(objtable_);
|
||||
for (int i = 0; i < request->objectids_size(); ++i) {
|
||||
ObjectID objectid = request->objectids(i);
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ public:
|
||||
Status ExportRemoteFunction(ServerContext* context, const ExportRemoteFunctionRequest* request, AckReply* reply) override;
|
||||
Status ExportReusableVariable(ServerContext* context, const ExportReusableVariableRequest* request, AckReply* reply) override;
|
||||
Status NotifyFailure(ServerContext*, const NotifyFailureRequest* request, AckReply* reply) override;
|
||||
Status Select(ServerContext*, const SelectRequest* request, SelectReply* reply) override;
|
||||
Status Wait(ServerContext*, const WaitRequest* request, WaitReply* reply) override;
|
||||
|
||||
#ifdef NDEBUG
|
||||
// If we've disabled assertions, then just use regular SynchronizedPtr to skip lock checking.
|
||||
|
||||
+4
-4
@@ -409,15 +409,15 @@ void Worker::task_info(ClientContext &context, TaskInfoRequest &request, TaskInf
|
||||
RAY_CHECK_GRPC(scheduler_stub_->TaskInfo(&context, request, &reply));
|
||||
}
|
||||
|
||||
std::vector<int> Worker::select(std::vector<ObjectID>& objectids) {
|
||||
std::vector<int> Worker::wait(std::vector<ObjectID>& objectids) {
|
||||
RAY_CHECK(connected_, "Attempted to test if object was ready but failed.");
|
||||
ClientContext context;
|
||||
SelectRequest request;
|
||||
SelectReply reply;
|
||||
WaitRequest request;
|
||||
WaitReply reply;
|
||||
for (int i = 0; i < objectids.size(); ++i) {
|
||||
request.add_objectids(objectids[i]);
|
||||
}
|
||||
RAY_CHECK_GRPC(scheduler_stub_->Select(&context, request, &reply));
|
||||
RAY_CHECK_GRPC(scheduler_stub_->Wait(&context, request, &reply));
|
||||
std::vector<int> result;
|
||||
for (int i = 0; i < reply.indices_size(); ++i) {
|
||||
result.push_back(reply.indices(i));
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ class Worker {
|
||||
// get task statuses from scheduler
|
||||
void task_info(ClientContext &context, TaskInfoRequest &request, TaskInfoReply &reply);
|
||||
// gets indices of available objects
|
||||
std::vector<int> select(std::vector<ObjectID>& objectids);
|
||||
std::vector<int> wait(std::vector<ObjectID>& objectids);
|
||||
// Export a function to be run on all workers.
|
||||
void run_function_on_all_workers(const std::string& function);
|
||||
// export function to workers
|
||||
|
||||
Reference in New Issue
Block a user