Storage functionality for Mindtrace
Project description
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
StorageHandlerinterface 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 loginto set up default credentials.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mindtrace_storage-0.6.0.tar.gz.
File metadata
- Download URL: mindtrace_storage-0.6.0.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b62771fff2be46e825cd8908756b74f3290f591bcf5a2f2696f0ce9ce0f73b93
|
|
| MD5 |
41ed03e1bec9b5865162b8f04a70c346
|
|
| BLAKE2b-256 |
ffe424de3da0d623081bf644ccfd06fa8ae1ef44d1da044d516ecbc94d880062
|
File details
Details for the file mindtrace_storage-0.6.0-py3-none-any.whl.
File metadata
- Download URL: mindtrace_storage-0.6.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97dce4cd66acd449cd5e1045f442aa3bb2c7dbfbe008b588075bd9072951c2b5
|
|
| MD5 |
2b56c553b30bef907f1ba12e53e9105b
|
|
| BLAKE2b-256 |
58b4c1c2c013d63f2964018a5569b1a5210372d064b1184e3fbfc4dc73fc51cf
|