message: [hdf5] extend tests to cover grouped data
diff: @@ -62,6 +62,43 @@ def test_hdf5():
  shutil.rmtree(runpath)
  +def test_hdf5_grouped():
  + """test_hdf5 with grouped data: https://github.com/tensorflow/io/issues/1161"""
  +
  + def create_datasets(runpath, cnt=10):
  + os.makedirs(runpath, exist_ok=True)
  + for i in range(cnt):
  + f = h5py.File("{}/file_{}.h5".format(runpath, i), "w")
  + total_samples = np.random.randint(50000, 100000)
  + grp = f.create_group("sample_group")
  + grp.create_dataset("features", data=np.random.random((total_samples, 60)))
  + grp.create_dataset("targets", data=np.random.random((total_samples, 3)))
  + f.close()
  +
  + runpath = tempfile.mkdtemp()
  + create_datasets(runpath)
  +
  + for i in range(2):
  + cnt = 0
  + for p in glob.glob("{}/*.h5".format(runpath)):
  + try:
  + features = tfio.IODataset.from_hdf5(p, "/sample_group/features")
  + targets = tfio.IODataset.from_hdf5(p, "/sample_group/targets")
  + dataset = tf.data.Dataset.zip((features, targets))
  +
  + for t in dataset:
  + cnt += t[0].shape[0]
  +
  + except Exception as e:
  + print("Failed going through {}".format(p))
  + raise e
  + print("Success going through {}".format(p))
  +
  + print("Iterated {} items".format(cnt))
  +
  + shutil.rmtree(runpath)
  +
  +
  def test_hdf5_graph():
  """test_hdf5_graph: GitHub issue 898"""
  