Skip to main content

GCS io utility functions

Project description

gcp-io

codecov

This library provides an easy interface to do some common I/O tasks on Google Cloud Storage (GCS). Those include:

  • Reading/writing an image file from and to GCS.
  • Reading/writing a video file from and to GCS.
  • Reading/writing a yaml file from and to GCS.
  • Uploading/downloading a file from and to GCS.
  • Checking md5 checksum of a file.
  • Checking if a file exists in GCS.
  • Listing directories in GCS.

Installation

pip install git+https://github.com/kiwicampus/gcp-io.git@main

or with poetry

poetry add git+https://github.com/kiwicampus/gcp-io.git@main

Usage

from gcp_io import GCPInterface

# this will try to load credentials from environment variable 
# GOOGLE_APPLICATION_CREDENTIALS or from gsutil if installed
interface = GCPInterface()

# this will try to load credentials from a .json file
interface = GCPInterface("/key/to/credentials.json")

# this will be authenticated directly using a storage.Client object
from google.cloud import storage
interface = GCPInterface(storage.Client())

# Use its methods comfortably
image = interface.read_image("gs://bucket/path/to/image.jpg")
interface.write_image("gs://bucket/path/to/image.jpg", image)

Contributing

Feel free to send PRs if you want to implement something or to propose changes. For that remember to run the tests and if implementing something new to make the proper tests and coverage.

Running the tests

Because of the nature of this library you'll need to be authenticated to google cloud. Our test bucket is public so anyone authenticated could run the tests. For this purpose you need to set the GOOGLE_APPLICATION_CREDENTIALS environment variable to your .json authentification file. Also you need to install pytest and pytest-cov. After that just run:

pytest test

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

gcp_io_util-0.1.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

gcp_io_util-0.1.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file gcp_io_util-0.1.1.tar.gz.

File metadata

  • Download URL: gcp_io_util-0.1.1.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.8.3 Linux/6.8.0-76060800daily20240311-generic

File hashes

Hashes for gcp_io_util-0.1.1.tar.gz
Algorithm Hash digest
SHA256 315a96516d4b80c66153ec22e06095b63395cd6faf2b2afda642caad9eaaca31
MD5 803eb24f167dd6a63a1fc4082cf4ae8a
BLAKE2b-256 3d76b815fe93f402de3d3a50454fa51b59508efa45aa6586487cc6725f24b2b7

See more details on using hashes here.

File details

Details for the file gcp_io_util-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: gcp_io_util-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.8.3 Linux/6.8.0-76060800daily20240311-generic

File hashes

Hashes for gcp_io_util-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3133e8c1493c4511219792375ebf076514adba06afc5187bd81cb8695f691091
MD5 d6a702192bccd20c7157bd45f6733669
BLAKE2b-256 1cc40b56c69ebde68f751e8f712359c2969bf389bc28f18d85df828ff6cdfe51

See more details on using hashes here.

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