swarmauri_storage_file 0.3.0.dev3__tar.gz → 0.3.0.dev32__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- swarmauri_storage_file-0.3.0.dev32/PKG-INFO +123 -0
- swarmauri_storage_file-0.3.0.dev32/README.md +100 -0
- {swarmauri_storage_file-0.3.0.dev3 → swarmauri_storage_file-0.3.0.dev32}/pyproject.toml +11 -3
- {swarmauri_storage_file-0.3.0.dev3 → swarmauri_storage_file-0.3.0.dev32}/swarmauri_storage_file/file_storage_adapter.py +6 -0
- swarmauri_storage_file-0.3.0.dev3/PKG-INFO +0 -41
- swarmauri_storage_file-0.3.0.dev3/README.md +0 -20
- {swarmauri_storage_file-0.3.0.dev3 → swarmauri_storage_file-0.3.0.dev32}/LICENSE +0 -0
- {swarmauri_storage_file-0.3.0.dev3 → swarmauri_storage_file-0.3.0.dev32}/swarmauri_storage_file/__init__.py +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swarmauri_storage_file
|
|
3
|
+
Version: 0.3.0.dev32
|
|
4
|
+
Summary: Filesystem storage adapter for Peagen
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: swarmauri,sdk,standards,storage,file
|
|
8
|
+
Author: Jacob Stewart
|
|
9
|
+
Author-email: jacob@swarmauri.com
|
|
10
|
+
Requires-Python: >=3.10,<3.13
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Requires-Dist: swarmauri_base
|
|
20
|
+
Requires-Dist: swarmauri_core
|
|
21
|
+
Requires-Dist: swarmauri_standard
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
<p align="center">
|
|
27
|
+
<a href="https://pypi.org/project/swarmauri_storage_file/">
|
|
28
|
+
<img src="https://img.shields.io/pypi/dm/swarmauri_storage_file" alt="PyPI - Downloads"/></a>
|
|
29
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_storage_file/">
|
|
30
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_storage_file.svg"/></a>
|
|
31
|
+
<a href="https://pypi.org/project/swarmauri_storage_file/">
|
|
32
|
+
<img src="https://img.shields.io/pypi/pyversions/swarmauri_storage_file" alt="PyPI - Python Version"/></a>
|
|
33
|
+
<a href="https://pypi.org/project/swarmauri_storage_file/">
|
|
34
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_storage_file" alt="PyPI - License"/></a>
|
|
35
|
+
<a href="https://pypi.org/project/swarmauri_storage_file/">
|
|
36
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_storage_file?label=swarmauri_storage_file&color=green" alt="PyPI - swarmauri_storage_file"/></a>
|
|
37
|
+
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
# Swarmauri File Storage Adapter
|
|
43
|
+
|
|
44
|
+
Filesystem-based storage adapter for Peagen that stores binary artifacts on the
|
|
45
|
+
local disk.
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- Resolves and prepares the configured ``output_dir`` on instantiation so
|
|
50
|
+
uploads can run without additional filesystem setup.
|
|
51
|
+
- Supports an optional ``prefix`` to scope all keys inside a nested directory
|
|
52
|
+
tree while keeping the same adapter instance.
|
|
53
|
+
- ``upload`` writes files atomically by copying into a temporary file before an
|
|
54
|
+
atomic rename, ensuring partially written data is never observed.
|
|
55
|
+
- ``download`` returns a :class:`io.BytesIO` handle positioned at the start of
|
|
56
|
+
the stored content for immediate consumption by downstream tooling.
|
|
57
|
+
- Convenience helpers such as ``upload_dir``, ``download_dir``, ``iter_prefix``
|
|
58
|
+
and ``from_uri`` mirror the behavior of :class:`pathlib.Path` operations and
|
|
59
|
+
make it easy to bulk transfer artifacts.
|
|
60
|
+
- ``root_uri`` exposes the workspace as a ``file://`` URI which is used when
|
|
61
|
+
constructing the URIs returned by ``upload``.
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
Install the package with your preferred Python packaging tool:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install swarmauri_storage_file
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
poetry add swarmauri_storage_file
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
uv pip install swarmauri_storage_file
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from pathlib import Path
|
|
83
|
+
import io
|
|
84
|
+
|
|
85
|
+
from swarmauri_storage_file import FileStorageAdapter
|
|
86
|
+
|
|
87
|
+
workspace = Path("./artifacts").resolve()
|
|
88
|
+
adapter = FileStorageAdapter(output_dir=workspace)
|
|
89
|
+
|
|
90
|
+
root_uri = adapter.root_uri
|
|
91
|
+
print("Root URI:", root_uri)
|
|
92
|
+
|
|
93
|
+
uri = adapter.upload("example.txt", io.BytesIO(b"hello world"))
|
|
94
|
+
print("Stored at:", uri)
|
|
95
|
+
|
|
96
|
+
downloaded = adapter.download("example.txt").read().decode("utf-8")
|
|
97
|
+
print("Contents:", downloaded)
|
|
98
|
+
|
|
99
|
+
keys = list(adapter.iter_prefix(""))
|
|
100
|
+
print("Keys:", keys)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The snippet above resolves a local workspace, uploads an artifact, reads it
|
|
104
|
+
back as text and inspects the stored keys. URIs returned by ``upload`` reuse
|
|
105
|
+
``root_uri`` (with the relative key appended) so they can be dereferenced by
|
|
106
|
+
tools that understand ``file://`` locations.
|
|
107
|
+
|
|
108
|
+
### Additional helpers
|
|
109
|
+
|
|
110
|
+
- ``upload_dir`` recursively walks a source directory and stores each file
|
|
111
|
+
under an optional destination prefix.
|
|
112
|
+
- ``download_dir`` materializes a stored prefix into a destination directory,
|
|
113
|
+
recreating any nested structure.
|
|
114
|
+
- ``iter_prefix`` yields keys rooted at ``output_dir`` (including any configured
|
|
115
|
+
prefix) which is useful for inventory or cleanup tasks.
|
|
116
|
+
- ``from_uri`` rebuilds an adapter from a ``file://`` URI previously emitted by
|
|
117
|
+
``root_uri`` or ``upload``.
|
|
118
|
+
|
|
119
|
+
## Want to help?
|
|
120
|
+
|
|
121
|
+
If you want to contribute to swarmauri-sdk, read up on our
|
|
122
|
+
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
123
|
+
that will help you get started.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://pypi.org/project/swarmauri_storage_file/">
|
|
5
|
+
<img src="https://img.shields.io/pypi/dm/swarmauri_storage_file" alt="PyPI - Downloads"/></a>
|
|
6
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_storage_file/">
|
|
7
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_storage_file.svg"/></a>
|
|
8
|
+
<a href="https://pypi.org/project/swarmauri_storage_file/">
|
|
9
|
+
<img src="https://img.shields.io/pypi/pyversions/swarmauri_storage_file" alt="PyPI - Python Version"/></a>
|
|
10
|
+
<a href="https://pypi.org/project/swarmauri_storage_file/">
|
|
11
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_storage_file" alt="PyPI - License"/></a>
|
|
12
|
+
<a href="https://pypi.org/project/swarmauri_storage_file/">
|
|
13
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_storage_file?label=swarmauri_storage_file&color=green" alt="PyPI - swarmauri_storage_file"/></a>
|
|
14
|
+
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Swarmauri File Storage Adapter
|
|
20
|
+
|
|
21
|
+
Filesystem-based storage adapter for Peagen that stores binary artifacts on the
|
|
22
|
+
local disk.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- Resolves and prepares the configured ``output_dir`` on instantiation so
|
|
27
|
+
uploads can run without additional filesystem setup.
|
|
28
|
+
- Supports an optional ``prefix`` to scope all keys inside a nested directory
|
|
29
|
+
tree while keeping the same adapter instance.
|
|
30
|
+
- ``upload`` writes files atomically by copying into a temporary file before an
|
|
31
|
+
atomic rename, ensuring partially written data is never observed.
|
|
32
|
+
- ``download`` returns a :class:`io.BytesIO` handle positioned at the start of
|
|
33
|
+
the stored content for immediate consumption by downstream tooling.
|
|
34
|
+
- Convenience helpers such as ``upload_dir``, ``download_dir``, ``iter_prefix``
|
|
35
|
+
and ``from_uri`` mirror the behavior of :class:`pathlib.Path` operations and
|
|
36
|
+
make it easy to bulk transfer artifacts.
|
|
37
|
+
- ``root_uri`` exposes the workspace as a ``file://`` URI which is used when
|
|
38
|
+
constructing the URIs returned by ``upload``.
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
Install the package with your preferred Python packaging tool:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install swarmauri_storage_file
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
poetry add swarmauri_storage_file
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv pip install swarmauri_storage_file
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from pathlib import Path
|
|
60
|
+
import io
|
|
61
|
+
|
|
62
|
+
from swarmauri_storage_file import FileStorageAdapter
|
|
63
|
+
|
|
64
|
+
workspace = Path("./artifacts").resolve()
|
|
65
|
+
adapter = FileStorageAdapter(output_dir=workspace)
|
|
66
|
+
|
|
67
|
+
root_uri = adapter.root_uri
|
|
68
|
+
print("Root URI:", root_uri)
|
|
69
|
+
|
|
70
|
+
uri = adapter.upload("example.txt", io.BytesIO(b"hello world"))
|
|
71
|
+
print("Stored at:", uri)
|
|
72
|
+
|
|
73
|
+
downloaded = adapter.download("example.txt").read().decode("utf-8")
|
|
74
|
+
print("Contents:", downloaded)
|
|
75
|
+
|
|
76
|
+
keys = list(adapter.iter_prefix(""))
|
|
77
|
+
print("Keys:", keys)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The snippet above resolves a local workspace, uploads an artifact, reads it
|
|
81
|
+
back as text and inspects the stored keys. URIs returned by ``upload`` reuse
|
|
82
|
+
``root_uri`` (with the relative key appended) so they can be dereferenced by
|
|
83
|
+
tools that understand ``file://`` locations.
|
|
84
|
+
|
|
85
|
+
### Additional helpers
|
|
86
|
+
|
|
87
|
+
- ``upload_dir`` recursively walks a source directory and stores each file
|
|
88
|
+
under an optional destination prefix.
|
|
89
|
+
- ``download_dir`` materializes a stored prefix into a destination directory,
|
|
90
|
+
recreating any nested structure.
|
|
91
|
+
- ``iter_prefix`` yields keys rooted at ``output_dir`` (including any configured
|
|
92
|
+
prefix) which is useful for inventory or cleanup tasks.
|
|
93
|
+
- ``from_uri`` rebuilds an adapter from a ``file://`` URI previously emitted by
|
|
94
|
+
``root_uri`` or ``upload``.
|
|
95
|
+
|
|
96
|
+
## Want to help?
|
|
97
|
+
|
|
98
|
+
If you want to contribute to swarmauri-sdk, read up on our
|
|
99
|
+
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
100
|
+
that will help you get started.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_storage_file"
|
|
3
|
-
version = "0.3.0.
|
|
3
|
+
version = "0.3.0.dev32"
|
|
4
4
|
authors = [
|
|
5
5
|
{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }
|
|
6
6
|
]
|
|
@@ -16,16 +16,23 @@ classifiers = [
|
|
|
16
16
|
"Programming Language :: Python :: 3.11",
|
|
17
17
|
"Programming Language :: Python :: 3.12",
|
|
18
18
|
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
19
21
|
]
|
|
20
22
|
dependencies = [
|
|
21
|
-
"peagen",
|
|
22
23
|
"swarmauri_core",
|
|
23
24
|
"swarmauri_base",
|
|
24
25
|
"swarmauri_standard",
|
|
25
26
|
]
|
|
27
|
+
keywords = [
|
|
28
|
+
'swarmauri',
|
|
29
|
+
'sdk',
|
|
30
|
+
'standards',
|
|
31
|
+
'storage',
|
|
32
|
+
'file',
|
|
33
|
+
]
|
|
26
34
|
|
|
27
35
|
[tool.uv.sources]
|
|
28
|
-
peagen = { workspace = true }
|
|
29
36
|
swarmauri_core = { workspace = true }
|
|
30
37
|
swarmauri_base = { workspace = true }
|
|
31
38
|
swarmauri_standard = { workspace = true }
|
|
@@ -49,6 +56,7 @@ markers = [
|
|
|
49
56
|
"xfail: Expected failures",
|
|
50
57
|
"acceptance: Acceptance tests",
|
|
51
58
|
"perf: Performance tests that measure execution time and resource usage",
|
|
59
|
+
"example: Example usage tests",
|
|
52
60
|
]
|
|
53
61
|
timeout = 300
|
|
54
62
|
log_cli = true
|
|
@@ -99,6 +99,12 @@ class FileStorageAdapter(StorageAdapterBase):
|
|
|
99
99
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
100
100
|
shutil.copy2(path, target)
|
|
101
101
|
|
|
102
|
+
async def remove_object(self, object_key: str) -> None:
|
|
103
|
+
"""Delete ``object_key`` when it exists."""
|
|
104
|
+
path = self._full_key(object_key)
|
|
105
|
+
if path.exists():
|
|
106
|
+
path.unlink()
|
|
107
|
+
|
|
102
108
|
@classmethod
|
|
103
109
|
def from_uri(cls, uri: str) -> "FileStorageAdapter":
|
|
104
110
|
"""Instantiate the adapter from a ``file://`` URI."""
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: swarmauri_storage_file
|
|
3
|
-
Version: 0.3.0.dev3
|
|
4
|
-
Summary: Filesystem storage adapter for Peagen
|
|
5
|
-
License: Apache-2.0
|
|
6
|
-
Author: Jacob Stewart
|
|
7
|
-
Author-email: jacob@swarmauri.com
|
|
8
|
-
Requires-Python: >=3.10,<3.13
|
|
9
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Classifier: Operating System :: OS Independent
|
|
15
|
-
Requires-Dist: peagen
|
|
16
|
-
Requires-Dist: swarmauri_base
|
|
17
|
-
Requires-Dist: swarmauri_core
|
|
18
|
-
Requires-Dist: swarmauri_standard
|
|
19
|
-
Description-Content-Type: text/markdown
|
|
20
|
-
|
|
21
|
-
# Swarmauri File Storage Adapter
|
|
22
|
-
|
|
23
|
-
Filesystem-based storage adapter for Peagen that stores artifacts on the local disk.
|
|
24
|
-
|
|
25
|
-
## Installation
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
# pip install swarmauri_storage_file (when published)
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Usage
|
|
32
|
-
|
|
33
|
-
```python
|
|
34
|
-
from swarmauri_storage_file import FileStorageAdapter
|
|
35
|
-
import io
|
|
36
|
-
|
|
37
|
-
adapter = FileStorageAdapter(output_dir="/tmp/peagen")
|
|
38
|
-
uri = adapter.upload("example.txt", io.BytesIO(b"hello"))
|
|
39
|
-
print("Stored at", uri)
|
|
40
|
-
```
|
|
41
|
-
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# Swarmauri File Storage Adapter
|
|
2
|
-
|
|
3
|
-
Filesystem-based storage adapter for Peagen that stores artifacts on the local disk.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# pip install swarmauri_storage_file (when published)
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```python
|
|
14
|
-
from swarmauri_storage_file import FileStorageAdapter
|
|
15
|
-
import io
|
|
16
|
-
|
|
17
|
-
adapter = FileStorageAdapter(output_dir="/tmp/peagen")
|
|
18
|
-
uri = adapter.upload("example.txt", io.BytesIO(b"hello"))
|
|
19
|
-
print("Stored at", uri)
|
|
20
|
-
```
|
|
File without changes
|
|
File without changes
|