Skip to content

Commit 22791b1

Browse files
A. Unique TensorFlowertensorflower-gardener
authored andcommitted
Don't load events until all runs have been added.
This means that the runs will show up in TensorBoard even though they won't have events yet (since we still only load from one event at a time). This requires us to disable the activation checking logic in EventAccumulator. Change: 123252077
1 parent 5c145f0 commit 22791b1

4 files changed

Lines changed: 4 additions & 53 deletions

File tree

‎tensorflow/python/summary/event_accumulator.py‎

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ class EventAccumulator(object):
114114
`Accumulator.Scalars(tag)`) allow for the retrieval of all data
115115
associated with that tag.
116116
117-
Before usage, the `EventAccumulator` must be activated via `Reload()`. This
118-
method synchronosly loads all of the data written so far.
117+
The `Reload()` method synchronously loads all of the data written so far.
119118
120119
Histograms, audio, and images are very large, so storing all of them is not
121120
recommended.
@@ -175,7 +174,6 @@ def __init__(self,
175174
self._compression_bps = compression_bps
176175
self.purge_orphaned_data = purge_orphaned_data
177176

178-
self._activated = False
179177
self.most_recent_step = -1
180178
self.most_recent_wall_time = -1
181179
self.file_version = None
@@ -188,12 +186,10 @@ def Reload(self):
188186
"""Loads all events added since the last call to `Reload`.
189187
190188
If `Reload` was never called, loads all events in the file.
191-
Calling `Reload` activates the `EventAccumulator`.
192189
193190
Returns:
194191
The `EventAccumulator`.
195192
"""
196-
self._activated = True
197193
with self._generator_mutex:
198194
for event in self._generator.Load():
199195
if event.HasField('file_version'):
@@ -232,13 +228,9 @@ def Reload(self):
232228
def Tags(self):
233229
"""Return all tags found in the value stream.
234230
235-
Raises:
236-
RuntimeError: If the `EventAccumulator` has not been activated.
237-
238231
Returns:
239232
A `{tagType: ['list', 'of', 'tags']}` dictionary.
240233
"""
241-
self._VerifyActivated()
242234
return {IMAGES: self._images.Keys(),
243235
AUDIO: self._audio.Keys(),
244236
HISTOGRAMS: self._histograms.Keys(),
@@ -255,25 +247,21 @@ def Scalars(self, tag):
255247
256248
Raises:
257249
KeyError: If the tag is not found.
258-
RuntimeError: If the `EventAccumulator` has not been activated.
259250
260251
Returns:
261252
An array of `ScalarEvent`s.
262253
"""
263-
self._VerifyActivated()
264254
return self._scalars.Items(tag)
265255

266256
def Graph(self):
267257
"""Return the graph definition, if there is one.
268258
269259
Raises:
270260
ValueError: If there is no graph for this run.
271-
RuntimeError: If the `EventAccumulator` has not been activated.
272261
273262
Returns:
274263
The `graph_def` proto.
275264
"""
276-
self._VerifyActivated()
277265
if self._graph is None:
278266
raise ValueError('There is no graph in this EventAccumulator')
279267
graph = graph_pb2.GraphDef()
@@ -288,12 +276,10 @@ def RunMetadata(self, tag):
288276
289277
Raises:
290278
ValueError: If the tag is not found.
291-
RuntimeError: If the `EventAccumulator` has not been activated.
292279
293280
Returns:
294281
The metadata in form of `RunMetadata` proto.
295282
"""
296-
self._VerifyActivated()
297283
if tag not in self._tagged_metadata:
298284
raise ValueError('There is no run metadata with this tag name')
299285

@@ -309,12 +295,10 @@ def Histograms(self, tag):
309295
310296
Raises:
311297
KeyError: If the tag is not found.
312-
RuntimeError: If the `EventAccumulator` has not been activated.
313298
314299
Returns:
315300
An array of `HistogramEvent`s.
316301
"""
317-
self._VerifyActivated()
318302
return self._histograms.Items(tag)
319303

320304
def CompressedHistograms(self, tag):
@@ -325,12 +309,10 @@ def CompressedHistograms(self, tag):
325309
326310
Raises:
327311
KeyError: If the tag is not found.
328-
RuntimeError: If the `EventAccumulator` has not been activated.
329312
330313
Returns:
331314
An array of `CompressedHistogramEvent`s.
332315
"""
333-
self._VerifyActivated()
334316
return self._compressed_histograms.Items(tag)
335317

336318
def Images(self, tag):
@@ -341,12 +323,10 @@ def Images(self, tag):
341323
342324
Raises:
343325
KeyError: If the tag is not found.
344-
RuntimeError: If the `EventAccumulator` has not been activated.
345326
346327
Returns:
347328
An array of `ImageEvent`s.
348329
"""
349-
self._VerifyActivated()
350330
return self._images.Items(tag)
351331

352332
def Audio(self, tag):
@@ -357,12 +337,10 @@ def Audio(self, tag):
357337
358338
Raises:
359339
KeyError: If the tag is not found.
360-
RuntimeError: If the `EventAccumulator` has not been activated.
361340
362341
Returns:
363342
An array of `AudioEvent`s.
364343
"""
365-
self._VerifyActivated()
366344
return self._audio.Items(tag)
367345

368346
def _MaybePurgeOrphanedData(self, event):
@@ -599,10 +577,6 @@ def _ExpiredPerTag(value):
599577
event.wall_time, *expired_per_type)
600578
logging.warn(purge_msg)
601579

602-
def _VerifyActivated(self):
603-
if not self._activated:
604-
raise RuntimeError('Accumulator must be activated before it may be used.')
605-
606580

607581
def _GetPurgeMessage(most_recent_step, most_recent_wall_time, event_step,
608582
event_wall_time, num_expired_scalars, num_expired_histos,

‎tensorflow/python/summary/event_accumulator_test.py‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -456,18 +456,6 @@ def testAudio(self):
456456
self.assertEqual(acc.Audio('snd1'), [snd1])
457457
self.assertEqual(acc.Audio('snd2'), [snd2])
458458

459-
def testActivation(self):
460-
gen = _EventGenerator()
461-
acc = ea.EventAccumulator(gen)
462-
self.assertFalse(acc._activated)
463-
with self.assertRaises(RuntimeError):
464-
acc.Tags()
465-
with self.assertRaises(RuntimeError):
466-
acc.Scalars('s1')
467-
acc.Reload()
468-
self.assertTrue(acc._activated)
469-
acc._activated = False
470-
471459
def testKeyError(self):
472460
gen = _EventGenerator()
473461
acc = ea.EventAccumulator(gen)

‎tensorflow/python/summary/event_multiplexer.py‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ def AddRun(self, path, name=None):
113113
accumulator.
114114
115115
If `Reload` has been called, it will `Reload` the newly created
116-
accumulators. This maintains the invariant that once the Multiplexer was
117-
activated, all of its accumulators are active.
116+
accumulators.
118117
119118
Args:
120119
path: Path to the event files (or event directory) for given run.
@@ -199,7 +198,6 @@ def Scalars(self, run, tag):
199198
Raises:
200199
KeyError: If the run is not found, or the tag is not available for
201200
the given run.
202-
RuntimeError: If the run's `EventAccumulator` has not been activated.
203201
204202
Returns:
205203
An array of `event_accumulator.ScalarEvents`.
@@ -216,7 +214,6 @@ def Graph(self, run):
216214
Raises:
217215
KeyError: If the run is not found.
218216
ValueError: If the run does not have an associated graph.
219-
RuntimeError: If the run's EventAccumulator has not been activated.
220217
221218
Returns:
222219
The `graph_def` protobuf data structure.
@@ -234,7 +231,6 @@ def RunMetadata(self, run, tag):
234231
Raises:
235232
KeyError: If the run is not found, or the tag is not available for the
236233
given run.
237-
RuntimeError: If the run's EventAccumulator has not been activated.
238234
239235
Returns:
240236
The metadata in the form of `RunMetadata` protobuf data structure.
@@ -252,7 +248,6 @@ def Histograms(self, run, tag):
252248
Raises:
253249
KeyError: If the run is not found, or the tag is not available for
254250
the given run.
255-
RuntimeError: If the run's `EventAccumulator` has not been activated.
256251
257252
Returns:
258253
An array of `event_accumulator.HistogramEvents`.
@@ -270,7 +265,6 @@ def CompressedHistograms(self, run, tag):
270265
Raises:
271266
KeyError: If the run is not found, or the tag is not available for
272267
the given run.
273-
RuntimeError: If the run's EventAccumulator has not been activated.
274268
275269
Returns:
276270
An array of `event_accumulator.CompressedHistogramEvents`.
@@ -288,7 +282,6 @@ def Images(self, run, tag):
288282
Raises:
289283
KeyError: If the run is not found, or the tag is not available for
290284
the given run.
291-
RuntimeError: If the run's `EventAccumulator` has not been activated.
292285
293286
Returns:
294287
An array of `event_accumulator.ImageEvents`.
@@ -306,7 +299,6 @@ def Audio(self, run, tag):
306299
Raises:
307300
KeyError: If the run is not found, or the tag is not available for
308301
the given run.
309-
RuntimeError: If the run's `EventAccumulator` has not been activated.
310302
311303
Returns:
312304
An array of `event_accumulator.AudioEvents`.

‎tensorflow/tensorboard/backend/server.py‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,9 @@ def StartMultiplexerReloadingThread(multiplexer, path_to_run, load_interval):
120120
121121
Returns:
122122
A started `threading.Thread` that reloads the multiplexer.
123-
124123
"""
125-
# Ensure the Multiplexer initializes in a loaded state before it adds runs
126-
# So it can handle HTTP requests while runs are loading
127-
multiplexer.Reload()
128-
124+
# We don't call multiplexer.Reload() here because that would make
125+
# AddRunsFromDirectory block until the runs have all loaded.
129126
for path in path_to_run.keys():
130127
if gcs.IsGCSPath(path):
131128
gcs.CheckIsSupported()

0 commit comments

Comments
 (0)