Skip to main content

Streaming read/writes to Google Storage blobs with ascynchronous buffering.

Project description

gs-chunked-io: Streams for Google Storage

gs-chunked-io provides transparently chunked io streams for google storage objects. Writable streams are managed as multipart objects, composed when the stream is closed.

IO opperations are concurrent by default. The number of concurrent threads can be adjusted using the threads parameter, or disabled entirely with threads=None.

import gs_chunked_io as gscio
from google.cloud.storage import Client

client = Client()
bucket = client.bucket("my-bucket")
blob = bucket.get_blob("my-key)

# Readable stream:
with gscio.Reader(blob) as fh:
    fh.read(size)

# Writable stream:
with gscio.Writer("my_new_key", bucket) as fh:
    fh.write(data)

# Process blob in chunks:
for chunk in gscio.for_each_chunk(blob):
    my_chunk_processor(chunk)

# Multipart copy with processing:
dst_bucket = client.bucket("my_dest_bucket")
with gscio.Writer("my_dest_key", dst_bucket) as writer:
    for chunk in gscio.for_each_chunk(blob)
	    process_my_chunk(chunk)
	    writer(chunk)

# Extract .tar.gz on the fly:
import gzip
import tarfile
with gscio.AsyncReader(blob) as fh:
    gzip_reader = gzip.GzipFile(fileobj=fh)
    tf = tarfile.TarFile(fileobj=gzip_reader)
    for tarinfo in tf:
        process_my_tarinfo(tarinfo)

Installation

pip install gs-chunked-io

Links

Project home page GitHub
Package distribution PyPI

Bugs

Please report bugs, issues, feature requests, etc. on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gs-chunked-io-0.4.2.tar.gz (8.5 kB view details)

Uploaded Source

File details

Details for the file gs-chunked-io-0.4.2.tar.gz.

File metadata

  • Download URL: gs-chunked-io-0.4.2.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

File hashes

Hashes for gs-chunked-io-0.4.2.tar.gz
Algorithm Hash digest
SHA256 b3c5ac6b0d1444e3d9fa8748ef1c7edaceb45abbcae14497b825cf73275f8e3e
MD5 2da0f839cc5440d17e9b929adb69f2f8
BLAKE2b-256 f75a7e8bd5e8625da1767738e2d87264738c6e3e59327bcd43e6b8a1fbcdcb92

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page