예제 #1
0
 def test_process_auto(self):
   with TempDir() as temp_dir:
     path = temp_dir.create_temp_file('result.gz')
     _write_file_gzip(path, FOO_BAR_RECORD_BASE64)
     with TestPipeline() as p:
       result = (p
                 | Create([path])
                 | ReadAllFromTFRecord(
                     coder=coders.BytesCoder(),
                     compression_type=CompressionTypes.AUTO))
       assert_that(result, equal_to([b'foo', b'bar']))
예제 #2
0
 def test_process_glob(self):
   with TempDir() as temp_dir:
     self._write_glob(temp_dir, 'result')
     glob = temp_dir.get_path() + os.path.sep + '*result'
     with TestPipeline() as p:
       result = (p
                 | Create([glob])
                 | ReadAllFromTFRecord(
                     coder=coders.BytesCoder(),
                     compression_type=CompressionTypes.AUTO))
       assert_that(result, equal_to([b'foo', b'bar'] * 3))
예제 #3
0
  def test_process_multiple_globs(self):
    with TempDir() as temp_dir:
      globs = []
      for i in range(3):
        suffix = 'result' + str(i)
        self._write_glob(temp_dir, suffix)
        globs.append(temp_dir.get_path() + os.path.sep + '*' + suffix)

      with TestPipeline() as p:
        result = (p
                  | Create(globs)
                  | ReadAllFromTFRecord(
                      coder=coders.BytesCoder(),
                      compression_type=CompressionTypes.AUTO))
        assert_that(result, equal_to([b'foo', b'bar'] * 9))