swarmauri_gitfilter_s3fs 0.3.0.dev45__py3-none-any.whl → 0.11.0.dev1__py3-none-any.whl
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_gitfilter_s3fs/s3fs_filter.py +17 -10
- {swarmauri_gitfilter_s3fs-0.3.0.dev45.dist-info → swarmauri_gitfilter_s3fs-0.11.0.dev1.dist-info}/METADATA +24 -26
- swarmauri_gitfilter_s3fs-0.11.0.dev1.dist-info/RECORD +7 -0
- {swarmauri_gitfilter_s3fs-0.3.0.dev45.dist-info → swarmauri_gitfilter_s3fs-0.11.0.dev1.dist-info}/WHEEL +1 -1
- swarmauri_gitfilter_s3fs-0.3.0.dev45.dist-info/RECORD +0 -7
- {swarmauri_gitfilter_s3fs-0.3.0.dev45.dist-info → swarmauri_gitfilter_s3fs-0.11.0.dev1.dist-info}/entry_points.txt +0 -0
- {swarmauri_gitfilter_s3fs-0.3.0.dev45.dist-info → swarmauri_gitfilter_s3fs-0.11.0.dev1.dist-info}/licenses/LICENSE +0 -0
|
@@ -31,10 +31,14 @@ class S3FSFilter(StorageAdapterBase, GitFilterBase):
|
|
|
31
31
|
) -> None:
|
|
32
32
|
super().__init__(**kwargs)
|
|
33
33
|
self._bucket = bucket
|
|
34
|
-
self._prefix =
|
|
34
|
+
self._prefix = self.normalize_prefix(prefix)
|
|
35
35
|
|
|
36
36
|
k = key.get_secret_value() if isinstance(key, SecretStr) else key
|
|
37
|
-
s =
|
|
37
|
+
s = (
|
|
38
|
+
secret.get_secret_value()
|
|
39
|
+
if isinstance(secret, SecretStr)
|
|
40
|
+
else secret
|
|
41
|
+
)
|
|
38
42
|
client_kwargs: dict[str, str] = {}
|
|
39
43
|
if endpoint_url:
|
|
40
44
|
client_kwargs["endpoint_url"] = endpoint_url
|
|
@@ -49,9 +53,7 @@ class S3FSFilter(StorageAdapterBase, GitFilterBase):
|
|
|
49
53
|
)
|
|
50
54
|
|
|
51
55
|
def _full_key(self, key: str) -> str:
|
|
52
|
-
key =
|
|
53
|
-
if self._prefix:
|
|
54
|
-
key = f"{self._prefix.rstrip('/')}/{key}"
|
|
56
|
+
key = self.compose_key(self._prefix, key, allow_empty=True)
|
|
55
57
|
return f"{self._bucket}/{key}"
|
|
56
58
|
|
|
57
59
|
@property
|
|
@@ -61,10 +63,11 @@ class S3FSFilter(StorageAdapterBase, GitFilterBase):
|
|
|
61
63
|
return uri.rstrip("/") + "/"
|
|
62
64
|
|
|
63
65
|
def upload(self, key: str, data: BinaryIO) -> str:
|
|
66
|
+
normalized_key = self.normalize_key(key)
|
|
64
67
|
dest = self._full_key(key)
|
|
65
68
|
with self._fs.open(dest, "wb") as fh:
|
|
66
69
|
shutil.copyfileobj(data, fh)
|
|
67
|
-
return f"{self.root_uri}{
|
|
70
|
+
return f"{self.root_uri}{normalized_key}"
|
|
68
71
|
|
|
69
72
|
def download(self, key: str) -> BinaryIO:
|
|
70
73
|
src = self._full_key(key)
|
|
@@ -75,7 +78,7 @@ class S3FSFilter(StorageAdapterBase, GitFilterBase):
|
|
|
75
78
|
for path in base.rglob("*"):
|
|
76
79
|
if path.is_file():
|
|
77
80
|
rel = path.relative_to(base).as_posix()
|
|
78
|
-
key =
|
|
81
|
+
key = self.compose_key(prefix, rel)
|
|
79
82
|
with path.open("rb") as fh:
|
|
80
83
|
self.upload(key, fh)
|
|
81
84
|
|
|
@@ -87,10 +90,12 @@ class S3FSFilter(StorageAdapterBase, GitFilterBase):
|
|
|
87
90
|
rel = rel[len(self._prefix.rstrip("/")) + 1 :]
|
|
88
91
|
yield rel
|
|
89
92
|
|
|
90
|
-
def download_prefix(
|
|
93
|
+
def download_prefix(
|
|
94
|
+
self, prefix: str, dest_dir: str | os.PathLike
|
|
95
|
+
) -> None:
|
|
91
96
|
dest = Path(dest_dir)
|
|
92
97
|
for rel_key in self.iter_prefix(prefix):
|
|
93
|
-
target = dest
|
|
98
|
+
target = self.download_target_for_key(dest, rel_key)
|
|
94
99
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
95
100
|
data = self.download(rel_key)
|
|
96
101
|
with target.open("wb") as fh:
|
|
@@ -112,7 +117,9 @@ class S3FSFilter(StorageAdapterBase, GitFilterBase):
|
|
|
112
117
|
|
|
113
118
|
key = s3_cfg.get("key") or os.getenv("AWS_ACCESS_KEY_ID", "")
|
|
114
119
|
secret = s3_cfg.get("secret") or os.getenv("AWS_SECRET_ACCESS_KEY", "")
|
|
115
|
-
endpoint_url = s3_cfg.get("endpoint_url") or os.getenv(
|
|
120
|
+
endpoint_url = s3_cfg.get("endpoint_url") or os.getenv(
|
|
121
|
+
"AWS_ENDPOINT_URL"
|
|
122
|
+
)
|
|
116
123
|
region = s3_cfg.get("region") or os.getenv("AWS_REGION")
|
|
117
124
|
|
|
118
125
|
return cls(
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: swarmauri_gitfilter_s3fs
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0.dev1
|
|
4
4
|
Summary: S3 git filter for Peagen using s3fs
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Keywords: swarmauri,sdk,standards,gitfilter,s3fs
|
|
8
8
|
Author: Jacob Stewart
|
|
9
9
|
Author-email: jacob@swarmauri.com
|
|
10
|
-
Requires-Python: >=3.10,<3.
|
|
10
|
+
Requires-Python: >=3.10,<3.15
|
|
11
11
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
12
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
14
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
-
Classifier:
|
|
17
|
-
Classifier: Programming Language :: Python
|
|
18
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
21
|
Requires-Dist: peagen
|
|
20
22
|
Requires-Dist: s3fs
|
|
21
23
|
Requires-Dist: swarmauri_base
|
|
@@ -23,27 +25,21 @@ Requires-Dist: swarmauri_core
|
|
|
23
25
|
Requires-Dist: swarmauri_standard
|
|
24
26
|
Description-Content-Type: text/markdown
|
|
25
27
|
|
|
26
|
-

|
|
27
29
|
|
|
28
30
|
<p align="center">
|
|
29
|
-
<a href="https://
|
|
30
|
-
<img src="https://
|
|
31
|
-
</a>
|
|
31
|
+
<a href="https://pepy.tech/project/swarmauri_gitfilter_s3fs/">
|
|
32
|
+
<img src="https://static.pepy.tech/badge/swarmauri_gitfilter_s3fs/month" alt="PyPI - Downloads"/></a>
|
|
32
33
|
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_gitfilter_s3fs/">
|
|
33
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_gitfilter_s3fs.svg"
|
|
34
|
-
</a>
|
|
34
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_gitfilter_s3fs.svg"/></a>
|
|
35
35
|
<a href="https://pypi.org/project/swarmauri_gitfilter_s3fs/">
|
|
36
|
-
<img src="https://img.shields.io/
|
|
37
|
-
</a>
|
|
36
|
+
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
38
37
|
<a href="https://pypi.org/project/swarmauri_gitfilter_s3fs/">
|
|
39
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_gitfilter_s3fs" alt="PyPI - License"
|
|
40
|
-
</a>
|
|
38
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_gitfilter_s3fs" alt="PyPI - License"/></a>
|
|
41
39
|
<a href="https://pypi.org/project/swarmauri_gitfilter_s3fs/">
|
|
42
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_gitfilter_s3fs?label=swarmauri_gitfilter_s3fs&color=green" alt="PyPI - swarmauri_gitfilter_s3fs"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
---
|
|
40
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_gitfilter_s3fs?label=swarmauri_gitfilter_s3fs&color=green" alt="PyPI - swarmauri_gitfilter_s3fs"/></a>
|
|
41
|
+
<a href="https://discord.gg/N4UpBuQv8T">
|
|
42
|
+
<img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
|
|
47
43
|
|
|
48
44
|
# Swarmauri Git Filter S3FS
|
|
49
45
|
|
|
@@ -86,13 +82,13 @@ uv pip install swarmauri_gitfilter_s3fs
|
|
|
86
82
|
Create the filter by supplying your bucket name and optional connection
|
|
87
83
|
parameters:
|
|
88
84
|
|
|
89
|
-
- ``bucket``
|
|
90
|
-
- ``prefix``
|
|
91
|
-
- ``key`` / ``secret``
|
|
85
|
+
- ``bucket`` ? Target bucket name (required).
|
|
86
|
+
- ``prefix`` ? Optional key prefix to scope uploads.
|
|
87
|
+
- ``key`` / ``secret`` ? Credentials for the S3 endpoint. ``SecretStr``
|
|
92
88
|
instances are supported.
|
|
93
|
-
- ``endpoint_url``
|
|
89
|
+
- ``endpoint_url`` ? Custom S3-compatible endpoint (useful for MinIO or
|
|
94
90
|
LocalStack).
|
|
95
|
-
- ``region_name``
|
|
91
|
+
- ``region_name`` ? Region for the endpoint.
|
|
96
92
|
|
|
97
93
|
When using :meth:`S3FSFilter.from_uri`, the URI sets the ``bucket`` and
|
|
98
94
|
``prefix`` while credentials are loaded from ``peagen.toml`` at
|
|
@@ -131,7 +127,7 @@ with patch("swarmauri_gitfilter_s3fs.s3fs_filter.s3fs.S3FileSystem") as fs_cls:
|
|
|
131
127
|
assert buffer.getvalue() == b"model-weights"
|
|
132
128
|
```
|
|
133
129
|
|
|
134
|
-
In a production workflow you do not need to patch ``s3fs``
|
|
130
|
+
In a production workflow you do not need to patch ``s3fs`` ? instantiate the
|
|
135
131
|
filter with your credentials and bucket, then use ``clean``/``smudge`` or
|
|
136
132
|
``upload``/``download`` to move artifacts between git and S3.
|
|
137
133
|
|
|
@@ -140,3 +136,5 @@ filter with your credentials and bucket, then use ``clean``/``smudge`` or
|
|
|
140
136
|
If you want to contribute to swarmauri-sdk, read up on our
|
|
141
137
|
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
142
138
|
that will help you get started.
|
|
139
|
+
|
|
140
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
swarmauri_gitfilter_s3fs/__init__.py,sha256=qCTB0mBQ9_G86H4jhyOskqU1ExQc-5k6PD9nrqDiwWE,413
|
|
2
|
+
swarmauri_gitfilter_s3fs/s3fs_filter.py,sha256=0OfB591L6C3N7qc8K1zBm1bx1-UbiVGQ-Ea1y63pjAc,4362
|
|
3
|
+
swarmauri_gitfilter_s3fs-0.11.0.dev1.dist-info/METADATA,sha256=0b9Zwp1QDOm0CDJnYMDhF_GxiAJLoQ0p_q49esiGZ0I,5680
|
|
4
|
+
swarmauri_gitfilter_s3fs-0.11.0.dev1.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
|
|
5
|
+
swarmauri_gitfilter_s3fs-0.11.0.dev1.dist-info/entry_points.txt,sha256=HkWix2d-C6c2ByB7GdU-sQAzgAT_Lg9yEe07RgdIfCU,165
|
|
6
|
+
swarmauri_gitfilter_s3fs-0.11.0.dev1.dist-info/licenses/LICENSE,sha256=djUXOlCxLVszShEpZXshZ7v33G-2qIC_j9KXpWKZSzQ,11359
|
|
7
|
+
swarmauri_gitfilter_s3fs-0.11.0.dev1.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
swarmauri_gitfilter_s3fs/__init__.py,sha256=qCTB0mBQ9_G86H4jhyOskqU1ExQc-5k6PD9nrqDiwWE,413
|
|
2
|
-
swarmauri_gitfilter_s3fs/s3fs_filter.py,sha256=G7tfTERStoe4PtFbnH2oeEkBaJHeqPKkoRHl-6uRq5k,4250
|
|
3
|
-
swarmauri_gitfilter_s3fs-0.3.0.dev45.dist-info/METADATA,sha256=HeqcfDOaJIjqlzV01G_gt0sdjGT4YlEJTuw9J1-Q5jE,5435
|
|
4
|
-
swarmauri_gitfilter_s3fs-0.3.0.dev45.dist-info/WHEEL,sha256=kJCRJT_g0adfAJzTx2GUMmS80rTJIVHRCfG0DQgLq3o,88
|
|
5
|
-
swarmauri_gitfilter_s3fs-0.3.0.dev45.dist-info/entry_points.txt,sha256=HkWix2d-C6c2ByB7GdU-sQAzgAT_Lg9yEe07RgdIfCU,165
|
|
6
|
-
swarmauri_gitfilter_s3fs-0.3.0.dev45.dist-info/licenses/LICENSE,sha256=djUXOlCxLVszShEpZXshZ7v33G-2qIC_j9KXpWKZSzQ,11359
|
|
7
|
-
swarmauri_gitfilter_s3fs-0.3.0.dev45.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|