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
This commit is contained in:
parent
5c145f0e3c
commit
22791b144c
@ -114,8 +114,7 @@ class EventAccumulator(object):
|
|||||||
`Accumulator.Scalars(tag)`) allow for the retrieval of all data
|
`Accumulator.Scalars(tag)`) allow for the retrieval of all data
|
||||||
associated with that tag.
|
associated with that tag.
|
||||||
|
|
||||||
Before usage, the `EventAccumulator` must be activated via `Reload()`. This
|
The `Reload()` method synchronously loads all of the data written so far.
|
||||||
method synchronosly loads all of the data written so far.
|
|
||||||
|
|
||||||
Histograms, audio, and images are very large, so storing all of them is not
|
Histograms, audio, and images are very large, so storing all of them is not
|
||||||
recommended.
|
recommended.
|
||||||
@ -175,7 +174,6 @@ class EventAccumulator(object):
|
|||||||
self._compression_bps = compression_bps
|
self._compression_bps = compression_bps
|
||||||
self.purge_orphaned_data = purge_orphaned_data
|
self.purge_orphaned_data = purge_orphaned_data
|
||||||
|
|
||||||
self._activated = False
|
|
||||||
self.most_recent_step = -1
|
self.most_recent_step = -1
|
||||||
self.most_recent_wall_time = -1
|
self.most_recent_wall_time = -1
|
||||||
self.file_version = None
|
self.file_version = None
|
||||||
@ -188,12 +186,10 @@ class EventAccumulator(object):
|
|||||||
"""Loads all events added since the last call to `Reload`.
|
"""Loads all events added since the last call to `Reload`.
|
||||||
|
|
||||||
If `Reload` was never called, loads all events in the file.
|
If `Reload` was never called, loads all events in the file.
|
||||||
Calling `Reload` activates the `EventAccumulator`.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The `EventAccumulator`.
|
The `EventAccumulator`.
|
||||||
"""
|
"""
|
||||||
self._activated = True
|
|
||||||
with self._generator_mutex:
|
with self._generator_mutex:
|
||||||
for event in self._generator.Load():
|
for event in self._generator.Load():
|
||||||
if event.HasField('file_version'):
|
if event.HasField('file_version'):
|
||||||
@ -232,13 +228,9 @@ class EventAccumulator(object):
|
|||||||
def Tags(self):
|
def Tags(self):
|
||||||
"""Return all tags found in the value stream.
|
"""Return all tags found in the value stream.
|
||||||
|
|
||||||
Raises:
|
|
||||||
RuntimeError: If the `EventAccumulator` has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A `{tagType: ['list', 'of', 'tags']}` dictionary.
|
A `{tagType: ['list', 'of', 'tags']}` dictionary.
|
||||||
"""
|
"""
|
||||||
self._VerifyActivated()
|
|
||||||
return {IMAGES: self._images.Keys(),
|
return {IMAGES: self._images.Keys(),
|
||||||
AUDIO: self._audio.Keys(),
|
AUDIO: self._audio.Keys(),
|
||||||
HISTOGRAMS: self._histograms.Keys(),
|
HISTOGRAMS: self._histograms.Keys(),
|
||||||
@ -255,12 +247,10 @@ class EventAccumulator(object):
|
|||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
KeyError: If the tag is not found.
|
KeyError: If the tag is not found.
|
||||||
RuntimeError: If the `EventAccumulator` has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
An array of `ScalarEvent`s.
|
An array of `ScalarEvent`s.
|
||||||
"""
|
"""
|
||||||
self._VerifyActivated()
|
|
||||||
return self._scalars.Items(tag)
|
return self._scalars.Items(tag)
|
||||||
|
|
||||||
def Graph(self):
|
def Graph(self):
|
||||||
@ -268,12 +258,10 @@ class EventAccumulator(object):
|
|||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: If there is no graph for this run.
|
ValueError: If there is no graph for this run.
|
||||||
RuntimeError: If the `EventAccumulator` has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The `graph_def` proto.
|
The `graph_def` proto.
|
||||||
"""
|
"""
|
||||||
self._VerifyActivated()
|
|
||||||
if self._graph is None:
|
if self._graph is None:
|
||||||
raise ValueError('There is no graph in this EventAccumulator')
|
raise ValueError('There is no graph in this EventAccumulator')
|
||||||
graph = graph_pb2.GraphDef()
|
graph = graph_pb2.GraphDef()
|
||||||
@ -288,12 +276,10 @@ class EventAccumulator(object):
|
|||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: If the tag is not found.
|
ValueError: If the tag is not found.
|
||||||
RuntimeError: If the `EventAccumulator` has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The metadata in form of `RunMetadata` proto.
|
The metadata in form of `RunMetadata` proto.
|
||||||
"""
|
"""
|
||||||
self._VerifyActivated()
|
|
||||||
if tag not in self._tagged_metadata:
|
if tag not in self._tagged_metadata:
|
||||||
raise ValueError('There is no run metadata with this tag name')
|
raise ValueError('There is no run metadata with this tag name')
|
||||||
|
|
||||||
@ -309,12 +295,10 @@ class EventAccumulator(object):
|
|||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
KeyError: If the tag is not found.
|
KeyError: If the tag is not found.
|
||||||
RuntimeError: If the `EventAccumulator` has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
An array of `HistogramEvent`s.
|
An array of `HistogramEvent`s.
|
||||||
"""
|
"""
|
||||||
self._VerifyActivated()
|
|
||||||
return self._histograms.Items(tag)
|
return self._histograms.Items(tag)
|
||||||
|
|
||||||
def CompressedHistograms(self, tag):
|
def CompressedHistograms(self, tag):
|
||||||
@ -325,12 +309,10 @@ class EventAccumulator(object):
|
|||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
KeyError: If the tag is not found.
|
KeyError: If the tag is not found.
|
||||||
RuntimeError: If the `EventAccumulator` has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
An array of `CompressedHistogramEvent`s.
|
An array of `CompressedHistogramEvent`s.
|
||||||
"""
|
"""
|
||||||
self._VerifyActivated()
|
|
||||||
return self._compressed_histograms.Items(tag)
|
return self._compressed_histograms.Items(tag)
|
||||||
|
|
||||||
def Images(self, tag):
|
def Images(self, tag):
|
||||||
@ -341,12 +323,10 @@ class EventAccumulator(object):
|
|||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
KeyError: If the tag is not found.
|
KeyError: If the tag is not found.
|
||||||
RuntimeError: If the `EventAccumulator` has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
An array of `ImageEvent`s.
|
An array of `ImageEvent`s.
|
||||||
"""
|
"""
|
||||||
self._VerifyActivated()
|
|
||||||
return self._images.Items(tag)
|
return self._images.Items(tag)
|
||||||
|
|
||||||
def Audio(self, tag):
|
def Audio(self, tag):
|
||||||
@ -357,12 +337,10 @@ class EventAccumulator(object):
|
|||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
KeyError: If the tag is not found.
|
KeyError: If the tag is not found.
|
||||||
RuntimeError: If the `EventAccumulator` has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
An array of `AudioEvent`s.
|
An array of `AudioEvent`s.
|
||||||
"""
|
"""
|
||||||
self._VerifyActivated()
|
|
||||||
return self._audio.Items(tag)
|
return self._audio.Items(tag)
|
||||||
|
|
||||||
def _MaybePurgeOrphanedData(self, event):
|
def _MaybePurgeOrphanedData(self, event):
|
||||||
@ -599,10 +577,6 @@ class EventAccumulator(object):
|
|||||||
event.wall_time, *expired_per_type)
|
event.wall_time, *expired_per_type)
|
||||||
logging.warn(purge_msg)
|
logging.warn(purge_msg)
|
||||||
|
|
||||||
def _VerifyActivated(self):
|
|
||||||
if not self._activated:
|
|
||||||
raise RuntimeError('Accumulator must be activated before it may be used.')
|
|
||||||
|
|
||||||
|
|
||||||
def _GetPurgeMessage(most_recent_step, most_recent_wall_time, event_step,
|
def _GetPurgeMessage(most_recent_step, most_recent_wall_time, event_step,
|
||||||
event_wall_time, num_expired_scalars, num_expired_histos,
|
event_wall_time, num_expired_scalars, num_expired_histos,
|
||||||
|
@ -456,18 +456,6 @@ class MockingEventAccumulatorTest(EventAccumulatorTest):
|
|||||||
self.assertEqual(acc.Audio('snd1'), [snd1])
|
self.assertEqual(acc.Audio('snd1'), [snd1])
|
||||||
self.assertEqual(acc.Audio('snd2'), [snd2])
|
self.assertEqual(acc.Audio('snd2'), [snd2])
|
||||||
|
|
||||||
def testActivation(self):
|
|
||||||
gen = _EventGenerator()
|
|
||||||
acc = ea.EventAccumulator(gen)
|
|
||||||
self.assertFalse(acc._activated)
|
|
||||||
with self.assertRaises(RuntimeError):
|
|
||||||
acc.Tags()
|
|
||||||
with self.assertRaises(RuntimeError):
|
|
||||||
acc.Scalars('s1')
|
|
||||||
acc.Reload()
|
|
||||||
self.assertTrue(acc._activated)
|
|
||||||
acc._activated = False
|
|
||||||
|
|
||||||
def testKeyError(self):
|
def testKeyError(self):
|
||||||
gen = _EventGenerator()
|
gen = _EventGenerator()
|
||||||
acc = ea.EventAccumulator(gen)
|
acc = ea.EventAccumulator(gen)
|
||||||
|
@ -113,8 +113,7 @@ class EventMultiplexer(object):
|
|||||||
accumulator.
|
accumulator.
|
||||||
|
|
||||||
If `Reload` has been called, it will `Reload` the newly created
|
If `Reload` has been called, it will `Reload` the newly created
|
||||||
accumulators. This maintains the invariant that once the Multiplexer was
|
accumulators.
|
||||||
activated, all of its accumulators are active.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
path: Path to the event files (or event directory) for given run.
|
path: Path to the event files (or event directory) for given run.
|
||||||
@ -199,7 +198,6 @@ class EventMultiplexer(object):
|
|||||||
Raises:
|
Raises:
|
||||||
KeyError: If the run is not found, or the tag is not available for
|
KeyError: If the run is not found, or the tag is not available for
|
||||||
the given run.
|
the given run.
|
||||||
RuntimeError: If the run's `EventAccumulator` has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
An array of `event_accumulator.ScalarEvents`.
|
An array of `event_accumulator.ScalarEvents`.
|
||||||
@ -216,7 +214,6 @@ class EventMultiplexer(object):
|
|||||||
Raises:
|
Raises:
|
||||||
KeyError: If the run is not found.
|
KeyError: If the run is not found.
|
||||||
ValueError: If the run does not have an associated graph.
|
ValueError: If the run does not have an associated graph.
|
||||||
RuntimeError: If the run's EventAccumulator has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The `graph_def` protobuf data structure.
|
The `graph_def` protobuf data structure.
|
||||||
@ -234,7 +231,6 @@ class EventMultiplexer(object):
|
|||||||
Raises:
|
Raises:
|
||||||
KeyError: If the run is not found, or the tag is not available for the
|
KeyError: If the run is not found, or the tag is not available for the
|
||||||
given run.
|
given run.
|
||||||
RuntimeError: If the run's EventAccumulator has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The metadata in the form of `RunMetadata` protobuf data structure.
|
The metadata in the form of `RunMetadata` protobuf data structure.
|
||||||
@ -252,7 +248,6 @@ class EventMultiplexer(object):
|
|||||||
Raises:
|
Raises:
|
||||||
KeyError: If the run is not found, or the tag is not available for
|
KeyError: If the run is not found, or the tag is not available for
|
||||||
the given run.
|
the given run.
|
||||||
RuntimeError: If the run's `EventAccumulator` has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
An array of `event_accumulator.HistogramEvents`.
|
An array of `event_accumulator.HistogramEvents`.
|
||||||
@ -270,7 +265,6 @@ class EventMultiplexer(object):
|
|||||||
Raises:
|
Raises:
|
||||||
KeyError: If the run is not found, or the tag is not available for
|
KeyError: If the run is not found, or the tag is not available for
|
||||||
the given run.
|
the given run.
|
||||||
RuntimeError: If the run's EventAccumulator has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
An array of `event_accumulator.CompressedHistogramEvents`.
|
An array of `event_accumulator.CompressedHistogramEvents`.
|
||||||
@ -288,7 +282,6 @@ class EventMultiplexer(object):
|
|||||||
Raises:
|
Raises:
|
||||||
KeyError: If the run is not found, or the tag is not available for
|
KeyError: If the run is not found, or the tag is not available for
|
||||||
the given run.
|
the given run.
|
||||||
RuntimeError: If the run's `EventAccumulator` has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
An array of `event_accumulator.ImageEvents`.
|
An array of `event_accumulator.ImageEvents`.
|
||||||
@ -306,7 +299,6 @@ class EventMultiplexer(object):
|
|||||||
Raises:
|
Raises:
|
||||||
KeyError: If the run is not found, or the tag is not available for
|
KeyError: If the run is not found, or the tag is not available for
|
||||||
the given run.
|
the given run.
|
||||||
RuntimeError: If the run's `EventAccumulator` has not been activated.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
An array of `event_accumulator.AudioEvents`.
|
An array of `event_accumulator.AudioEvents`.
|
||||||
|
@ -120,12 +120,9 @@ def StartMultiplexerReloadingThread(multiplexer, path_to_run, load_interval):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A started `threading.Thread` that reloads the multiplexer.
|
A started `threading.Thread` that reloads the multiplexer.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Ensure the Multiplexer initializes in a loaded state before it adds runs
|
# We don't call multiplexer.Reload() here because that would make
|
||||||
# So it can handle HTTP requests while runs are loading
|
# AddRunsFromDirectory block until the runs have all loaded.
|
||||||
multiplexer.Reload()
|
|
||||||
|
|
||||||
for path in path_to_run.keys():
|
for path in path_to_run.keys():
|
||||||
if gcs.IsGCSPath(path):
|
if gcs.IsGCSPath(path):
|
||||||
gcs.CheckIsSupported()
|
gcs.CheckIsSupported()
|
||||||
|
Loading…
Reference in New Issue
Block a user