mirror of
https://github.com/wassname/ray.git
synced 2026-07-09 01:19:27 +08:00
Compute task IDs and object IDs deterministically. (#31)
* Put infrastructure in place to compute task IDs and object IDs. * Fix version number for common library. * Compute task IDs and object IDs deterministically. * Address Stephanie's comments. * Update task documentation. * Fix formatting. * Add more tests and checks. * Fix formatting. * Enable DCHECKs and change CHECKs to DCHECKs.
This commit is contained in:
committed by
Philipp Moritz
parent
90f88af902
commit
194bdb1d96
@@ -477,7 +477,14 @@ class Worker(object):
|
||||
args_for_photon.append(put(arg))
|
||||
|
||||
# Submit the task to Photon.
|
||||
task = photon.Task(photon.ObjectID(function_id.id()), args_for_photon, self.num_return_vals[function_id.id()])
|
||||
task = photon.Task(photon.ObjectID(function_id.id()),
|
||||
args_for_photon,
|
||||
self.num_return_vals[function_id.id()],
|
||||
self.current_task_id,
|
||||
self.task_index)
|
||||
# Increment the worker's task index to track how many tasks have been
|
||||
# submitted by the current task so far.
|
||||
self.task_index += 1
|
||||
self.photon_client.submit(task)
|
||||
|
||||
return task.returns()
|
||||
@@ -832,6 +839,11 @@ def connect(address_info, mode=WORKER_MODE, worker=global_worker):
|
||||
worker.redis_client.rpush("Workers", worker.worker_id)
|
||||
else:
|
||||
raise Exception("This code should be unreachable.")
|
||||
# If this is a driver, set the current task ID to a specific fixed value and
|
||||
# set the task index to 0.
|
||||
if mode in [SCRIPT_MODE, SILENT_MODE]:
|
||||
worker.current_task_id = photon.ObjectID("".join(chr(i) for i in range(20)))
|
||||
worker.task_index = 0
|
||||
# If this is a worker, then start a thread to import exports from the driver.
|
||||
if mode == WORKER_MODE:
|
||||
t = threading.Thread(target=import_thread, args=(worker,))
|
||||
@@ -1038,6 +1050,8 @@ def main_loop(worker=global_worker):
|
||||
After the task executes, the worker resets any reusable variables that were
|
||||
accessed by the task.
|
||||
"""
|
||||
worker.current_task_id = task.task_id()
|
||||
worker.task_index = 0
|
||||
function_id = task.function_id()
|
||||
args = task.arguments()
|
||||
return_object_ids = task.returns()
|
||||
|
||||
Reference in New Issue
Block a user