Skip to main content

Hopeit Engine Azure Blob Storage Toolkit

Project description

hopeit.azure.blob-storage 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 Azure Blob Storage 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 Azure Blob Storage 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 Azure Blob Storage compatible services

pip install hopeit.azure.blob-storage

Usage

from hopeit.dataobjects import dataobject, dataclass
from hopeit.azure.blob_storage import ObjectStorage, ObjectStorageSettings, ConnectionConfig

# Set a connection configuration
conn_config = ConnectionConfig(
    connection_string="__AZURE_CONNECTION_STRING__",
    use_identity=False,
)

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

# Create an ObjectStorage instance
storage = await ObjectStorage.with_settings(settings).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/azure-example/ directory, you can find a full example hopeit.engine app that demonstrates the usage of the hopeit.azure.blob-storage plugin within the hopeit.engine framework. This example showcases how to store and retrieve @dataobjects and files from Azure Blob Storage using the ObjectStorage class.

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

hopeit_azure_blob_storage-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

hopeit_azure_blob_storage-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file hopeit_azure_blob_storage-0.1.0.tar.gz.

File metadata

File hashes

Hashes for hopeit_azure_blob_storage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2a7265b43ce22fedff55c8d80bf19c50e9a83f60433ba420d070ada01797f52
MD5 9550627cddd38f0e3673d2b52d7ed439
BLAKE2b-256 faaf9c37a891996cfb51dd5380ac4872e8debdf132887ba37eeeeb03dba77c41

See more details on using hashes here.

File details

Details for the file hopeit_azure_blob_storage-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hopeit_azure_blob_storage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4344fa802ea46f7cac6163d6f62f3ac13916d52c1b9ec45b5623fa5c02c8d44e
MD5 f487ec8ec3f73aceac068907dc87ffb8
BLAKE2b-256 6c9c1c0dd1b0613a6c3912fccf6ac5323942f168da1d1489330fb68b09355a4b

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