Skip to main content

Storage functionality for Mindtrace

Project description

PyPI version License Downloads

Storage Module

This directory contains the storage-related components for the Mindtrace project. It provides abstractions and implementations for interacting with various storage backends, such as Google Cloud Storage (GCS).

Structure

  • mindtrace/storage — Contains the core storage handler implementations and interfaces.
  • pyproject.toml — Build and dependency configuration for the storage package.

Main Components

  • base.py: Defines the abstract StorageHandler interface for storage operations.
  • gcs.py: Implements GCSStorageHandler, a wrapper around Google Cloud Storage APIs for uploading, downloading, listing, and managing objects in GCS buckets.

Google Cloud Storage (GCS) Usage

Usage Example

To use the GCS storage handler:

from mindtrace.storage.gcs import GCSStorageHandler

handler = GCSStorageHandler(
    bucket_name="your-bucket-name",
    project_id="your-gcp-project-id",
    credentials_path="/path/to/service-account.json",  # Optional if using ADC
    create_if_missing=True,
)

# Upload a file
gcs_uri = handler.upload("local_file.txt", "remote/path/in/bucket.txt")

# List objects
print(handler.list_objects(prefix="remote/path/"))

Available GCS APIs

The following methods are available via the GCSStorageHandler for explicit use:

  • upload(local_path, remote_path, metadata=None): Upload a local file to a GCS bucket.
  • download(remote_path, local_path): Download a file from GCS to a local path.
  • delete(remote_path): Delete an object from the GCS bucket.
  • list_objects(prefix="", max_results=None): List objects in the bucket, optionally filtered by prefix.
  • exists(remote_path): Check if an object exists in the bucket.
  • get_presigned_url(remote_path, expiration_minutes=60, method="GET"): Generate a presigned URL for accessing an object.
  • get_object_metadata(remote_path): Retrieve metadata for a specific object.

Notes

  • Ensure you have the required Google Cloud credentials and permissions to access the target bucket.
  • For local development, you can use gcloud auth application-default login to set up default credentials.

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

mindtrace_storage-0.9.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mindtrace_storage-0.9.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file mindtrace_storage-0.9.0.tar.gz.

File metadata

  • Download URL: mindtrace_storage-0.9.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for mindtrace_storage-0.9.0.tar.gz
Algorithm Hash digest
SHA256 ed6572baecd7d5cbb466e80d08d3b65dd0ae8867cb3184cb7c695fe650f9d37d
MD5 03cd94f1c2b58fcb80c5129b6762ffca
BLAKE2b-256 149875cf4fe16baf47f9cd12a5da484f7d2d6e8f6d40f14ea1ad49e02805ccc4

See more details on using hashes here.

File details

Details for the file mindtrace_storage-0.9.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mindtrace_storage-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8d17b758253ffef7a11f24024e3da1dd5e1a33ee7450d73e6705f382c6404cf
MD5 f8d7133df8f2fe6f9cbdd955ac4b7c9b
BLAKE2b-256 11cfc16f52cd1366b1951bd79b0b523bd5536d11bd1b42c4f00893caa389f484

See more details on using hashes here.

Supported by

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