Updated task_profiles function to avoid future repetitive parsing. (#691)

* Updated task_profiles function to avoid future repetitive parsing.

* Fix indentation.

* Fixed according to comments.

* Included updated test for task_profiles function.

* Simplify test.

* Fix indentation.

* Fix.
This commit is contained in:
alanamarzoev
2017-06-22 19:21:18 -07:00
committed by Robert Nishihara
parent 2d636d9278
commit e16df6da9a
2 changed files with 44 additions and 34 deletions
+8 -21
View File
@@ -1581,33 +1581,20 @@ class GlobalStateAPI(unittest.TestCase):
# Make sure the event log has the correct number of events.
start_time = time.time()
while time.time() - start_time < 10:
profiles, events = ray.global_state.task_profiles()
profiles = ray.global_state.task_profiles()
if len(profiles) == num_calls:
break
time.sleep(0.1)
self.assertEqual(len(profiles), num_calls)
self.assertEqual(len(events), 0)
# Make sure that each entry is properly formatted.
for task_id in profiles:
events_list = profiles[task_id]
# Make sure that the task was not executed more than once.
self.assertEqual(len(events_list), 1)
events = events_list[0]
for event in events:
found_exec = False
found_store = False
found_get = False
for event in events:
if event[1] == "ray:task:execute":
found_exec = True
if event[1] == "ray:task:get_arguments":
found_get = True
if event[1] == "ray:task:store_outputs":
found_store = True
self.assertTrue(found_exec)
self.assertTrue(found_store)
self.assertTrue(found_get)
for task_id, data in profiles.items():
self.assertIn("execute_start", data)
self.assertIn("execute_end", data)
self.assertIn("get_arguments_start", data)
self.assertIn("get_arguments_end", data)
self.assertIn("store_outputs_start", data)
self.assertIn("store_outputs_end", data)
ray.worker.cleanup()