Add 8 comments for event_multiplexer tests. (#9629)
* Add 8 comments for event_multiplexer tests. * small fixes
This commit is contained in:
parent
39200b037b
commit
1414cc83d9
@ -124,16 +124,19 @@ class EventMultiplexerTest(test_util.TensorFlowTestCase):
|
|||||||
self.stubs.CleanUp()
|
self.stubs.CleanUp()
|
||||||
|
|
||||||
def testEmptyLoader(self):
|
def testEmptyLoader(self):
|
||||||
|
"""Tests empty EventMultiplexer creation."""
|
||||||
x = event_multiplexer.EventMultiplexer()
|
x = event_multiplexer.EventMultiplexer()
|
||||||
self.assertEqual(x.Runs(), {})
|
self.assertEqual(x.Runs(), {})
|
||||||
|
|
||||||
def testRunNamesRespected(self):
|
def testRunNamesRespected(self):
|
||||||
|
"""Tests two EventAccumulators inserted/accessed in EventMultiplexer."""
|
||||||
x = event_multiplexer.EventMultiplexer({'run1': 'path1', 'run2': 'path2'})
|
x = event_multiplexer.EventMultiplexer({'run1': 'path1', 'run2': 'path2'})
|
||||||
self.assertItemsEqual(sorted(x.Runs().keys()), ['run1', 'run2'])
|
self.assertItemsEqual(sorted(x.Runs().keys()), ['run1', 'run2'])
|
||||||
self.assertEqual(x._GetAccumulator('run1')._path, 'path1')
|
self.assertEqual(x._GetAccumulator('run1')._path, 'path1')
|
||||||
self.assertEqual(x._GetAccumulator('run2')._path, 'path2')
|
self.assertEqual(x._GetAccumulator('run2')._path, 'path2')
|
||||||
|
|
||||||
def testReload(self):
|
def testReload(self):
|
||||||
|
"""EventAccumulators should Reload after EventMultiplexer call it."""
|
||||||
x = event_multiplexer.EventMultiplexer({'run1': 'path1', 'run2': 'path2'})
|
x = event_multiplexer.EventMultiplexer({'run1': 'path1', 'run2': 'path2'})
|
||||||
self.assertFalse(x._GetAccumulator('run1').reload_called)
|
self.assertFalse(x._GetAccumulator('run1').reload_called)
|
||||||
self.assertFalse(x._GetAccumulator('run2').reload_called)
|
self.assertFalse(x._GetAccumulator('run2').reload_called)
|
||||||
@ -142,6 +145,7 @@ class EventMultiplexerTest(test_util.TensorFlowTestCase):
|
|||||||
self.assertTrue(x._GetAccumulator('run2').reload_called)
|
self.assertTrue(x._GetAccumulator('run2').reload_called)
|
||||||
|
|
||||||
def testScalars(self):
|
def testScalars(self):
|
||||||
|
"""Tests Scalars function returns suitable values."""
|
||||||
x = event_multiplexer.EventMultiplexer({'run1': 'path1', 'run2': 'path2'})
|
x = event_multiplexer.EventMultiplexer({'run1': 'path1', 'run2': 'path2'})
|
||||||
|
|
||||||
run1_actual = x.Scalars('run1', 'sv1')
|
run1_actual = x.Scalars('run1', 'sv1')
|
||||||
@ -150,6 +154,7 @@ class EventMultiplexerTest(test_util.TensorFlowTestCase):
|
|||||||
self.assertEqual(run1_expected, run1_actual)
|
self.assertEqual(run1_expected, run1_actual)
|
||||||
|
|
||||||
def testHealthPills(self):
|
def testHealthPills(self):
|
||||||
|
"""Tests HealthPills() returns events associated with run1/Add."""
|
||||||
self.stubs.Set(event_accumulator, 'EventAccumulator',
|
self.stubs.Set(event_accumulator, 'EventAccumulator',
|
||||||
functools.partial(
|
functools.partial(
|
||||||
_GetFakeAccumulator,
|
_GetFakeAccumulator,
|
||||||
@ -172,11 +177,13 @@ class EventMultiplexerTest(test_util.TensorFlowTestCase):
|
|||||||
self.assertItemsEqual(['Add'], x.GetOpsWithHealthPills('run1'))
|
self.assertItemsEqual(['Add'], x.GetOpsWithHealthPills('run1'))
|
||||||
|
|
||||||
def testExceptions(self):
|
def testExceptions(self):
|
||||||
|
"""KeyError should be raised when accessing non-existing keys."""
|
||||||
x = event_multiplexer.EventMultiplexer({'run1': 'path1', 'run2': 'path2'})
|
x = event_multiplexer.EventMultiplexer({'run1': 'path1', 'run2': 'path2'})
|
||||||
with self.assertRaises(KeyError):
|
with self.assertRaises(KeyError):
|
||||||
x.Scalars('sv1', 'xxx')
|
x.Scalars('sv1', 'xxx')
|
||||||
|
|
||||||
def testInitialization(self):
|
def testInitialization(self):
|
||||||
|
"""Tests EventMultiplexer is created properly with its params."""
|
||||||
x = event_multiplexer.EventMultiplexer()
|
x = event_multiplexer.EventMultiplexer()
|
||||||
self.assertEqual(x.Runs(), {})
|
self.assertEqual(x.Runs(), {})
|
||||||
x = event_multiplexer.EventMultiplexer({'run1': 'path1', 'run2': 'path2'})
|
x = event_multiplexer.EventMultiplexer({'run1': 'path1', 'run2': 'path2'})
|
||||||
@ -185,6 +192,14 @@ class EventMultiplexerTest(test_util.TensorFlowTestCase):
|
|||||||
self.assertEqual(x._GetAccumulator('run2')._path, 'path2')
|
self.assertEqual(x._GetAccumulator('run2')._path, 'path2')
|
||||||
|
|
||||||
def testAddRunsFromDirectory(self):
|
def testAddRunsFromDirectory(self):
|
||||||
|
"""Tests AddRunsFromDirectory function.
|
||||||
|
|
||||||
|
Tests the following scenarios:
|
||||||
|
- When the directory does not exist.
|
||||||
|
- When the directory is empty.
|
||||||
|
- When the directory has empty subdirectory.
|
||||||
|
- Contains proper EventAccumulators after adding events.
|
||||||
|
"""
|
||||||
x = event_multiplexer.EventMultiplexer()
|
x = event_multiplexer.EventMultiplexer()
|
||||||
tmpdir = self.get_temp_dir()
|
tmpdir = self.get_temp_dir()
|
||||||
join = os.path.join
|
join = os.path.join
|
||||||
|
Loading…
Reference in New Issue
Block a user