Skip to main content

hopeit.aws.s3 plugin

This library is part of hopeit.engine:

visit: https://github.com/hopeit-git/hopeit.engine

This library provides a ObjectStorage class to store and retrieve @dataobjects and files from S3 and compatible services as a plugin for the popular hopeit.engine reactive microservices framework.

It supports the prefix setting, which is a prefix to be used for every element (object or file) stored in the S3 bucket. This prefix can be used to organize and categorize stored data within the bucket. Additionally, it supports the partition_dateformat setting, which is a date format string used to prefix file names for partitioning saved files into different subfolders based on the event timestamp (event_ts()). For example, using %Y/%m/%d will store each data object in a folder structure like year/month/day/, providing a way to efficiently organize and retrieve data based on date ranges. These settings can be used together to achieve more granular organization of data within the bucket.

Installation

Python library that provides helpers to store and retrieve @dataobjects and files to S3-compatible services

pip install hopeit.aws.s3

Usage

from hopeit.dataobjects import dataobject, dataclass
from hopeit.aws.s3 import ObjectStorage, ObjectStorageSettings, ConnectionConfig

# Create a connection configuration
conn_config = ConnectionConfig(
    aws_access_key_id="your-access-key-id",
    aws_secret_access_key="your-secret-access-key",
    region_name="your-region-name"
)

# Create settings for ObjectStorage
settings = ObjectStorageSettings(
    bucket="your-bucket-name",
    connection_config=conn_config
)

# Create an ObjectStorage instance
storage = ObjectStorage.with_settings(settings)

# Connect to the ObjectStorage
await storage.connect()

# hopeit.engine data object
@dataobject
@dataclass
class Something:
    key: str
    value: str

something = Something(key="my_key", value="some_value")

# Store a data object
await storage.store(key=something.key, value=something)

# Retrieve a data object
retrieved_object = await storage.get(key=something.key, datatype=Something)
print(retrieved_object)

Example Usage

In the apps/examples/aws-example/ directory, you can find a full example hopeit.engine app that demonstrates the usage of the hopeit.aws.s3 plugin within the hopeit.engine framework. This example showcases how to store and retrieve @dataobjects and files from S3 using the ObjectStorage class.

Metadata

Release files for hopeit.aws.s3 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hopeit.aws.s3 0.3.0
File Size Uploaded
hopeit_aws_s3-0.3.0.tar.gz 8.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hopeit.aws.s3 0.3.0
File Interpreter ABI Platform
hopeit_aws_s3-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / hopeit_aws_s3-0.3.0.tar.gz

Download URL hopeit_aws_s3-0.3.0.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f71d855567fb361aa4c57940c8c82c133409d6806fc39b90f1d3cd1968a64849
BLAKE2b-256 checksum
How to use checksums
137942e0b310b63aebecee8c08bb216320f380654702076b8ee2e6f931728684
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.14

Release files / hopeit_aws_s3-0.3.0-py3-none-any.whl

Download URL hopeit_aws_s3-0.3.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ad82b6686445ddd265b7e2a7d3fa74f6ed2db90662432d50be9d75b0f6e5955
BLAKE2b-256 checksum
How to use checksums
21be73c910432f0e387c5200d7e05171d30c900e071d21611d70f9faca4b3753
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.14

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page