Expose log files through global state API. (#641)

* added log_table function and a test

* fixed log_files and added task_profiles

* fixed formatting

* fixed linting errors

* fixes

* removed file

* more fixes

* hopefully fixed

* Small changes.

* Fix linting.

* Fix bug in log monitor.

* Small changes.

* Fix bug in travis.
This commit is contained in:
alanamarzoev
2017-06-08 00:08:10 -07:00
committed by Robert Nishihara
parent fde843a636
commit f0339f3386
3 changed files with 73 additions and 2 deletions
+34
View File
@@ -1407,6 +1407,9 @@ class GlobalStateAPI(unittest.TestCase):
with self.assertRaises(Exception):
ray.global_state.function_table()
with self.assertRaises(Exception):
ray.global_state.log_files()
ray.init()
self.assertEqual(ray.global_state.object_table(), dict())
@@ -1511,6 +1514,37 @@ class GlobalStateAPI(unittest.TestCase):
ray.worker.cleanup()
def testLogFileAPI(self):
ray.init(redirect_output=True)
message = "unique message"
@ray.remote
def f():
print(message)
# The call to sys.stdout.flush() seems to be necessary when using the
# system Python 2.7 on Ubuntu.
sys.stdout.flush()
ray.get(f.remote())
# Make sure that the message appears in the log files.
start_time = time.time()
found_message = False
while time.time() - start_time < 10:
log_files = ray.global_state.log_files()
for ip, innerdict in log_files.items():
for filename, contents in innerdict.items():
contents_str = "".join(contents)
if message in contents_str:
found_message = True
if found_message:
break
time.sleep(0.1)
self.assertEqual(found_message, True)
ray.worker.cleanup()
if __name__ == "__main__":
unittest.main(verbosity=2)