diff options
author | Jonathan Hseu <jhseu@google.com> | 2018-02-14 12:21:30 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-02-14 12:27:13 -0800 |
commit | 22176cb7af53caa778e4e793172ed4211ed17141 (patch) | |
tree | 8695cc792dac1e1ced4f37d584b529011619a355 /tensorflow/core/util/events_writer.h | |
parent | 71c68c4e9b4b744673ed0b07294c5f0d152686a0 (diff) |
Return Status instead of bool in Init(), Flush(), and Close().
With tf.contrib.summary, a remote worker will be writing summaries. If they just LOG the error, then the user doesn't see them.
PiperOrigin-RevId: 185725556
Diffstat (limited to 'tensorflow/core/util/events_writer.h')
-rw-r--r-- | tensorflow/core/util/events_writer.h | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/tensorflow/core/util/events_writer.h b/tensorflow/core/util/events_writer.h index a1a8cf790d..5dbaf97af4 100644 --- a/tensorflow/core/util/events_writer.h +++ b/tensorflow/core/util/events_writer.h @@ -18,6 +18,8 @@ limitations under the License. #include <memory> #include <string> + +#include "tensorflow/core/lib/core/status.h" #include "tensorflow/core/lib/io/record_writer.h" #include "tensorflow/core/platform/env.h" #include "tensorflow/core/platform/macros.h" @@ -43,7 +45,7 @@ class EventsWriter { // Note that it is not recommended to simultaneously have two // EventWriters writing to the same file_prefix. explicit EventsWriter(const string& file_prefix); - ~EventsWriter() { Close(); } // Autoclose in destructor. + ~EventsWriter(); // Sets the event file filename and opens file for writing. If not called by // user, will be invoked automatically by a call to FileName() or Write*(). @@ -51,11 +53,8 @@ class EventsWriter { // and is open this is a no-op. If on the other hand the file was opened, // but has since disappeared (e.g. deleted by another process), this will open // a new file with a new timestamp in its filename. - bool Init() { return InitWithSuffix(""); } - bool InitWithSuffix(const string& suffix) { - file_suffix_ = suffix; - return InitIfNeeded(); - } + Status Init(); + Status InitWithSuffix(const string& suffix); // Returns the filename for the current events file: // filename_ = [file_prefix_].out.events.[timestamp].[hostname][suffix] @@ -77,12 +76,12 @@ class EventsWriter { // be written too. // Close() calls Flush() and then closes the current events file. // Returns true only if both the flush and the closure were successful. - bool Flush(); - bool Close(); + Status Flush(); + Status Close(); private: - bool FileHasDisappeared(); // True if event_file_path_ does not exist. - bool InitIfNeeded(); + Status FileStillExists(); // OK if event_file_path_ exists. + Status InitIfNeeded(); Env* env_; const string file_prefix_; |