From 11a28834fa7ecf74fd9ebcd2b793caba21246cf1 Mon Sep 17 00:00:00 2001 From: adoda Date: Fri, 1 Mar 2019 18:15:48 +0800 Subject: [PATCH] [tune] Reduce the times for flushing json object to file (#4198) ## What do these changes do? When we write one result using JsonLogger, it will call 'flush' many times, which may cost a lot of time when writing to a remote distributed filesystem. ## Related issue number #4197 --- python/ray/tune/logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ray/tune/logger.py b/python/ray/tune/logger.py index 6a6f766e2..7f4bddac8 100644 --- a/python/ray/tune/logger.py +++ b/python/ray/tune/logger.py @@ -90,10 +90,10 @@ class JsonLogger(Logger): def on_result(self, result): json.dump(result, self, cls=_SafeFallbackEncoder) self.write("\n") + self.local_out.flush() def write(self, b): self.local_out.write(b) - self.local_out.flush() def flush(self): self.local_out.flush()