Esempio n. 1
0
 def setup(self):
     self.client = gcsio.GcsIO()
Esempio n. 2
0
 def test_num_retries(self):
     # BEAM-7424: update num_retries accordingly if storage_client is
     # regenerated.
     self.assertEqual(gcsio.GcsIO().client.num_retries, 20)
Esempio n. 3
0
 def test_retry_func(self):
     # BEAM-7667: update retry_func accordingly if storage_client is
     # regenerated.
     self.assertIsNotNone(gcsio.GcsIO().client.retry_func)
Esempio n. 4
0
 def setUp(self):
     self.client = FakeGcsClient()
     self.gcs = gcsio.GcsIO(self.client)
Esempio n. 5
0
def gcs_list(gcs_dir):
    """Lists all files in a GCS directory."""
    gcs = gcsio.GcsIO()
    return gcs.list_prefix(gcs_dir)
Esempio n. 6
0
def get_file_size(fpath):
    fs = FileSystems.get_filesystem(fpath)
    if type(fs) == GCSFileSystem:
        return gcsio.GcsIO().size(fpath)
    else:
        return FileIO(fpath, "rb").size()
Esempio n. 7
0
def open_file_write(fpath):
    fs = FileSystems.get_filesystem(fpath)
    if type(fs) == GCSFileSystem:
        return gcsio.GcsIO().open(fpath, mode='w')
    else:
        return FileSystems.create(fpath)
Esempio n. 8
0
def open_file_read(fpath):
    fs = FileSystems.get_filesystem(fpath)
    if type(fs) == GCSFileSystem:
        return gcsio.GcsIO().open(fpath)
    else:
        return FileSystems.open(fpath)