aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/summary/event_multiplexer.py
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/python/summary/event_multiplexer.py')
-rw-r--r--tensorflow/python/summary/event_multiplexer.py52
1 files changed, 37 insertions, 15 deletions
diff --git a/tensorflow/python/summary/event_multiplexer.py b/tensorflow/python/summary/event_multiplexer.py
index d7abea0ab0..a3ce42afb1 100644
--- a/tensorflow/python/summary/event_multiplexer.py
+++ b/tensorflow/python/summary/event_multiplexer.py
@@ -1,3 +1,18 @@
+# Copyright 2015 Google Inc. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==============================================================================
+
"""Provides an interface for working with multiple event files."""
from __future__ import absolute_import
@@ -128,15 +143,13 @@ class EventMultiplexer(object):
return self
def AddRunsFromDirectory(self, path, name=None):
- """Load runs from a directory; recursively walks subdirectories.
+ """Load runs from a directory, assuming each subdirectory is a run.
If path doesn't exist, no-op. This ensures that it is safe to call
`AddRunsFromDirectory` multiple times, even before the directory is made.
- If path is a directory, load event files in the directory (if any exist) and
- recursively call AddRunsFromDirectory on any subdirectories. This mean you
- can call AddRunsFromDirectory at the root of a tree of event logs and
- TensorBoard will load them all.
+ If the directory contains TensorFlow event files, it is itself treated as a
+ run.
If the `EventMultiplexer` is already loaded or autoupdating, this will cause
the newly created accumulators to also `Reload()` or `AutoUpdate()`.
@@ -158,16 +171,25 @@ class EventMultiplexer(object):
if not gfile.Exists(path):
return # Maybe it hasn't been created yet, fail silently to retry later
if not gfile.IsDirectory(path):
- raise ValueError('AddRunsFromDirectory: path exists and is not a '
- 'directory, %s' % path)
-
- for (subdir, _, files) in os.walk(path):
- if list(filter(event_accumulator.IsTensorFlowEventsFile, files)):
- logging.info('Adding events from directory %s', subdir)
- rpath = os.path.relpath(subdir, path)
- subname = os.path.join(name, rpath) if name else rpath
- self.AddRun(subdir, name=subname)
-
+ raise ValueError('Path exists and is not a directory, %s' % path)
+ paths = gfile.ListDirectory(path)
+ is_directory = lambda x: gfile.IsDirectory(os.path.join(path, x))
+ subdirectories = filter(is_directory, paths)
+ for s in subdirectories:
+ if name:
+ subname = '/'.join([name, s])
+ else:
+ subname = s
+ self.AddRun(os.path.join(path, s), subname)
+
+ if list(filter(event_accumulator.IsTensorFlowEventsFile, paths)):
+ directory_name = os.path.split(path)[1]
+ logging.info('Directory %s has event files; loading', directory_name)
+ if name:
+ dname = name
+ else:
+ dname = directory_name
+ self.AddRun(path, dname)
return self
def Reload(self):