Skip to main content

Filesystem storage adapter for Peagen

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_storage_file


Swarmauri File Storage Adapter

Filesystem-based storage adapter for Peagen that stores binary artifacts on the local disk.

Features

  • Resolves and prepares the configured output_dir on instantiation so uploads can run without additional filesystem setup.
  • Supports an optional prefix to scope all keys inside a nested directory tree while keeping the same adapter instance.
  • upload writes files atomically by copying into a temporary file before an atomic rename, ensuring partially written data is never observed.
  • download returns a :class:io.BytesIO handle positioned at the start of the stored content for immediate consumption by downstream tooling.
  • Convenience helpers such as upload_dir, download_dir, iter_prefix and from_uri mirror the behavior of :class:pathlib.Path operations and make it easy to bulk transfer artifacts.
  • root_uri exposes the workspace as a file:// URI which is used when constructing the URIs returned by upload.

Installation

Install the package with your preferred Python packaging tool:

pip install swarmauri_storage_file
poetry add swarmauri_storage_file
uv pip install swarmauri_storage_file

Usage

from pathlib import Path
import io

from swarmauri_storage_file import FileStorageAdapter

workspace = Path("./artifacts").resolve()
adapter = FileStorageAdapter(output_dir=workspace)

root_uri = adapter.root_uri
print("Root URI:", root_uri)

uri = adapter.upload("example.txt", io.BytesIO(b"hello world"))
print("Stored at:", uri)

downloaded = adapter.download("example.txt").read().decode("utf-8")
print("Contents:", downloaded)

keys = list(adapter.iter_prefix(""))
print("Keys:", keys)

The snippet above resolves a local workspace, uploads an artifact, reads it back as text and inspects the stored keys. URIs returned by upload reuse root_uri (with the relative key appended) so they can be dereferenced by tools that understand file:// locations.

Additional helpers

  • upload_dir recursively walks a source directory and stores each file under an optional destination prefix.
  • download_dir materializes a stored prefix into a destination directory, recreating any nested structure.
  • iter_prefix yields keys rooted at output_dir (including any configured prefix) which is useful for inventory or cleanup tasks.
  • from_uri rebuilds an adapter from a file:// URI previously emitted by root_uri or upload.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

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

swarmauri_storage_file-0.3.0.dev48.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

swarmauri_storage_file-0.3.0.dev48-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_storage_file-0.3.0.dev48.tar.gz.

File metadata

  • Download URL: swarmauri_storage_file-0.3.0.dev48.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_storage_file-0.3.0.dev48.tar.gz
Algorithm Hash digest
SHA256 fe89644f252f974e2f5caea12be103d614ff7e19504b22f569d9035166b4c7a4
MD5 5037205f13c1aed36f524536ef13d1f4
BLAKE2b-256 03c689ba1168a67273d8c302d7b5fdc1bf0b0c6424e1a0c9ff4ca1554fd27913

See more details on using hashes here.

File details

Details for the file swarmauri_storage_file-0.3.0.dev48-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_storage_file-0.3.0.dev48-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_storage_file-0.3.0.dev48-py3-none-any.whl
Algorithm Hash digest
SHA256 d4cc0e0e455f39b5992d24af9c6c994106396604a84e22915e01369ba0187e21
MD5 61748571f7b29b7cc48e2b03d0a05ede
BLAKE2b-256 e70ebaccdd639948a90e65066760dfac84b20b007b3a693e60b1981aaa6a4e9c

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