Skip to main content

S3-compatible ObjectStorePort adapter for muscles-data

Project description

muscles-data-s3

S3-compatible adapter package for muscles-data.

This package is intentionally separate from muscles-data: the core package owns typed ports and runtime, while this package owns the boto3-backed ObjectStorePort adapter.

Related packages

Install

python -m pip install muscles-data-s3

For local framework development:

PYTHONPATH=../muscles-data/src:src python3 -m pytest -q

Configuration

data:
  resources:
    objects.docs:
      type: s3
      endpoint_url: ${S3_ENDPOINT}
      bucket: documents
      region_name: us-east-1
      prefix: raw
      max_keys: 100

The adapter also supports standard boto3 credential options:

  • aws_access_key_id;
  • aws_secret_access_key;
  • aws_session_token;
  • profile_name;
  • the default boto3 environment/provider chain.

Usage

Register the external factory in the project composition root:

from muscles_data.catalog import DataAdapterCatalog
from muscles_data.config import DataConfig
from muscles_data.ports import ObjectStorePort
from muscles_data.runtime import DataRuntime
from muscles_data_s3 import S3ObjectStoreFactory

catalog = DataAdapterCatalog.with_defaults()
catalog.register(S3ObjectStoreFactory())

runtime = DataRuntime(config=DataConfig.from_raw(config), catalog=catalog)
objects = runtime.require_port("objects.docs", ObjectStorePort)

Then use the narrow port:

objects.put_object("docs/readme.txt", b"hello", content_type="text/plain")
blob = objects.get_object("docs/readme.txt")
items = objects.list_objects(prefix="docs", limit=20)
objects.delete_object("docs/readme.txt")

Backend-specific request options are available without exposing the boto3 client: get_object() accepts range, conditional headers and version/checksum options; list_objects() accepts delimiter and continuation helpers; and delete_object() accepts version and retention options.

If prefix: raw is configured, the public key docs/readme.txt is stored as raw/docs/readme.txt in S3 and returned to port consumers without the configured prefix. This keeps application code independent from bucket layout details.

Capabilities

S3ObjectStoreFactory provides:

  • object_store;
  • healthcheck;
  • native_client only when the resource declares native_client: true.

Native access is an advanced project escape hatch:

from muscles_data import DataCapability

client = runtime.require_resource("objects.docs", DataCapability.NATIVE_CLIENT).native_client()

Use the native client for backend-specific operations such as presigned URLs, multipart upload configuration, bucket policies or lifecycle rules. Keep normal blob reads and writes on ObjectStorePort.

Boundaries

This package owns:

  • lazy boto3 client creation;
  • S3-compatible endpoint and bucket binding;
  • object put/get/list/delete;
  • key normalization and optional prefix mapping;
  • safe inspect() and doctor().

It does not own:

  • document parsing;
  • application storage schemas;
  • lifecycle policies;
  • multipart/streaming abstractions in the MVP;
  • cross-resource transactions.

data.doctor performs head_bucket. data.resources.list and package initialization do not open an S3 connection.

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

muscles_data_s3-0.1.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

muscles_data_s3-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: muscles_data_s3-0.1.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for muscles_data_s3-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c5be773d28958aec0fc173f39c0ca89ec53a9c0aa10b0e20ea475fcd8d6ed553
MD5 b03e1017d583a9f5fedb4cc2dd0f9f11
BLAKE2b-256 d220eb5aca9e5f6e18c3ed8e3cc67c4325d40fdfded5861ca1cef17e1a9e6805

See more details on using hashes here.

Provenance

The following attestation bundles were made for muscles_data_s3-0.1.0.tar.gz:

Publisher: release.yml on butkoden/muscles-data-s3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for muscles_data_s3-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4be86a93274fa72c306b089e9432c9a8e08a74259317fabfe39e31df1e475e9d
MD5 79572da0ef6ccf5e3eaedea8df3ff5d4
BLAKE2b-256 5a53646e67623e3933a9c68ca5d6eb500bd69f9ccc52568b844fe3b0409a83bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for muscles_data_s3-0.1.0-py3-none-any.whl:

Publisher: release.yml on butkoden/muscles-data-s3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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