def testShardedFilenames(self): for suffix in '', '.png': shards = dfile.sharded_filenames('prefix@3' + suffix) self.assertEqual(shards, [ 'prefix-00000-of-00003' + suffix, 'prefix-00001-of-00003' + suffix, 'prefix-00002-of-00003' + suffix ])
def examples_shards(mode): """Pick which examples shards to use. Args: mode: Either 'train' or 'eval'. Returns: A list of filenames. Raises: ValueError: If mode is not 'train' or 'eval'. """ if mode == 'train': path = FLAGS.examples_train elif mode == 'eval': path = FLAGS.examples_eval else: raise ValueError('Invalid mode %r' % mode) return dfile.sharded_filenames(path)
def testSharedFilenamesInvalidSpec(self): with self.assertRaisesRegexp(ValueError, r'Invalid shard spec'): dfile.sharded_filenames('prefix@3.@w')