Filesystem storage adapter for Peagen
Project description
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_diron instantiation so uploads can run without additional filesystem setup. - Supports an optional
prefixto scope all keys inside a nested directory tree while keeping the same adapter instance. uploadwrites files atomically by copying into a temporary file before an atomic rename, ensuring partially written data is never observed.downloadreturns a :class:io.BytesIOhandle positioned at the start of the stored content for immediate consumption by downstream tooling.- Convenience helpers such as
upload_dir,download_dir,iter_prefixandfrom_urimirror the behavior of :class:pathlib.Pathoperations and make it easy to bulk transfer artifacts. root_uriexposes the workspace as afile://URI which is used when constructing the URIs returned byupload.
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_dirrecursively walks a source directory and stores each file under an optional destination prefix.download_dirmaterializes a stored prefix into a destination directory, recreating any nested structure.iter_prefixyields keys rooted atoutput_dir(including any configured prefix) which is useful for inventory or cleanup tasks.from_urirebuilds an adapter from afile://URI previously emitted byroot_uriorupload.
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
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 swarmauri_storage_file-0.3.0.dev51.tar.gz.
File metadata
- Download URL: swarmauri_storage_file-0.3.0.dev51.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb8ea76cbdf3a2b7411a04cc5d3eb014373733b90de5f79a12cc59922b1175f0
|
|
| MD5 |
e5e3aa5abb884491e3d2010d7aca0861
|
|
| BLAKE2b-256 |
66a5f783d0ca8714857bea69716721ff868fb6ba33b9b40525bc496400f9b0a9
|
File details
Details for the file swarmauri_storage_file-0.3.0.dev51-py3-none-any.whl.
File metadata
- Download URL: swarmauri_storage_file-0.3.0.dev51-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
134d759e9470328c34dba3a39ab9a0e4a2ea66bcd37ccadfdf64131bb97620c5
|
|
| MD5 |
e27c0afdf2b5c86a424aef3d8559d85d
|
|
| BLAKE2b-256 |
028c19056a7e9386b317a48412f9bff8cdb09ec693f0dad080dc29193a49f21b
|