swarmauri_gitfilter_minio 0.3.0.dev4__py3-none-any.whl → 0.3.0.dev34__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.
@@ -1,3 +1,5 @@
1
+ """Expose the :class:`~swarmauri_gitfilter_minio.minio_filter.MinioFilter` plugin."""
2
+
1
3
  from .minio_filter import MinioFilter
2
4
 
3
5
  __all__ = ["MinioFilter"]
@@ -1,3 +1,5 @@
1
+ """Storage adapter and Git filter backed by a MinIO or S3-compatible service."""
2
+
1
3
  from __future__ import annotations
2
4
 
3
5
  import io
@@ -18,7 +20,11 @@ from swarmauri_base.git_filters import GitFilterBase
18
20
 
19
21
  @ComponentBase.register_type(StorageAdapterBase, "MinioFilter")
20
22
  class MinioFilter(StorageAdapterBase, GitFilterBase):
21
- """Simple wrapper around the MinIO client for use with Peagen."""
23
+ """Interact with MinIO for storing Git objects.
24
+
25
+ Provides helpers to upload and download individual files or directory
26
+ trees, allowing Peagen to offload repository data to object storage.
27
+ """
22
28
 
23
29
  def __init__(
24
30
  self,
@@ -31,6 +37,18 @@ class MinioFilter(StorageAdapterBase, GitFilterBase):
31
37
  prefix: str = "",
32
38
  **kwargs,
33
39
  ) -> None:
40
+ """Create a new MinioFilter instance.
41
+
42
+ endpoint (str): Host and port of the MinIO service.
43
+ access_key (SecretStr): Access key credential.
44
+ secret_key (SecretStr): Secret key credential.
45
+ bucket (str): Bucket name to store objects in.
46
+ secure (bool): Use HTTPS when ``True``.
47
+ prefix (str): Optional path prefix inside the bucket.
48
+ **kwargs: Additional options forwarded to ``StorageAdapterBase``.
49
+
50
+ RETURNS (None): This method does not return anything.
51
+ """
34
52
  super().__init__(**kwargs)
35
53
  self._client = Minio(
36
54
  endpoint,
@@ -54,12 +72,24 @@ class MinioFilter(StorageAdapterBase, GitFilterBase):
54
72
 
55
73
  @property
56
74
  def root_uri(self) -> str:
75
+ """Return the root URI for the configured bucket and prefix.
76
+
77
+ RETURNS (str): Base MinIO URI ending with a trailing slash.
78
+ """
57
79
  scheme = "minios" if self._secure else "minio"
58
80
  base = f"{scheme}://{self._endpoint}/{self._bucket}"
59
81
  uri = f"{base}/{self._prefix.rstrip('/')}" if self._prefix else base
60
82
  return uri.rstrip("/") + "/"
61
83
 
62
84
  def upload(self, key: str, data: BinaryIO) -> str:
85
+ """Upload a binary stream to the bucket.
86
+
87
+ key (str): Destination object key.
88
+ data (BinaryIO): File-like object containing the data.
89
+
90
+ RETURNS (str): URI of the stored object.
91
+ RAISES (S3Error): If the upload fails.
92
+ """
63
93
  size: Optional[int] = None
64
94
  try:
65
95
  size = os.fstat(data.fileno()).st_size # type: ignore[attr-defined]
@@ -79,6 +109,13 @@ class MinioFilter(StorageAdapterBase, GitFilterBase):
79
109
  return f"{self.root_uri}{key.lstrip('/')}"
80
110
 
81
111
  def download(self, key: str) -> BinaryIO:
112
+ """Retrieve an object from the bucket.
113
+
114
+ key (str): Object key to fetch.
115
+
116
+ RETURNS (BinaryIO): Buffer containing the object data.
117
+ RAISES (FileNotFoundError): If the object cannot be found.
118
+ """
82
119
  try:
83
120
  resp = self._client.get_object(self._bucket, self._full_key(key))
84
121
  buffer = io.BytesIO(resp.read())
@@ -90,6 +127,13 @@ class MinioFilter(StorageAdapterBase, GitFilterBase):
90
127
  raise FileNotFoundError(f"{self._bucket}/{key}: {exc}") from exc
91
128
 
92
129
  def upload_dir(self, src: str | os.PathLike, *, prefix: str = "") -> None:
130
+ """Upload all files under a directory to the bucket.
131
+
132
+ src (str | os.PathLike): Local directory to walk.
133
+ prefix (str): Optional key prefix to prepend to uploaded objects.
134
+
135
+ RETURNS (None): This method does not return anything.
136
+ """
93
137
  base = Path(src)
94
138
  for path in base.rglob("*"):
95
139
  if path.is_file():
@@ -99,6 +143,12 @@ class MinioFilter(StorageAdapterBase, GitFilterBase):
99
143
  self.upload(key, fh)
100
144
 
101
145
  def iter_prefix(self, prefix: str):
146
+ """Iterate over object keys matching a prefix.
147
+
148
+ prefix (str): Key prefix to match.
149
+
150
+ RETURNS (Iterator[str]): Relative keys under the configured prefix.
151
+ """
102
152
  for obj in self._client.list_objects(
103
153
  self._bucket, prefix=prefix, recursive=True
104
154
  ):
@@ -108,6 +158,13 @@ class MinioFilter(StorageAdapterBase, GitFilterBase):
108
158
  yield key
109
159
 
110
160
  def download_prefix(self, prefix: str, dest_dir: str | os.PathLike) -> None:
161
+ """Download all objects beneath a prefix into a directory.
162
+
163
+ prefix (str): Key prefix to copy from the bucket.
164
+ dest_dir (str | os.PathLike): Local directory to populate.
165
+
166
+ RETURNS (None): This method does not return anything.
167
+ """
111
168
  dest = Path(dest_dir)
112
169
  for rel_key in self.iter_prefix(prefix):
113
170
  target = dest / rel_key
@@ -118,6 +175,12 @@ class MinioFilter(StorageAdapterBase, GitFilterBase):
118
175
 
119
176
  @classmethod
120
177
  def from_uri(cls, uri: str) -> "MinioFilter":
178
+ """Create a MinioFilter from a connection string.
179
+
180
+ uri (str): A URI like ``minio://host:port/bucket/prefix``.
181
+
182
+ RETURNS (MinioFilter): Configured ``MinioFilter`` instance.
183
+ """
121
184
  from urllib.parse import urlparse
122
185
 
123
186
  p = urlparse(uri)
@@ -0,0 +1,119 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarmauri_gitfilter_minio
3
+ Version: 0.3.0.dev34
4
+ Summary: MinIO git filter for Peagen
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: swarmauri,sdk,standards,gitfilter,minio
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: minio
20
+ Requires-Dist: peagen
21
+ Requires-Dist: swarmauri_base
22
+ Requires-Dist: swarmauri_core
23
+ Requires-Dist: swarmauri_standard
24
+ Description-Content-Type: text/markdown
25
+
26
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
27
+
28
+ <p align="center">
29
+ <a href="https://pypi.org/project/swarmauri_gitfilter_minio/">
30
+ <img src="https://img.shields.io/pypi/dm/swarmauri_gitfilter_minio" alt="PyPI - Downloads"/>
31
+ </a>
32
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_gitfilter_minio/">
33
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_gitfilter_minio.svg"/>
34
+ </a>
35
+ <a href="https://pypi.org/project/swarmauri_gitfilter_minio/">
36
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_gitfilter_minio" alt="PyPI - Python Version"/>
37
+ </a>
38
+ <a href="https://pypi.org/project/swarmauri_gitfilter_minio/">
39
+ <img src="https://img.shields.io/pypi/l/swarmauri_gitfilter_minio" alt="PyPI - License"/>
40
+ </a>
41
+ <a href="https://pypi.org/project/swarmauri_gitfilter_minio/">
42
+ <img src="https://img.shields.io/pypi/v/swarmauri_gitfilter_minio?label=swarmauri_gitfilter_minio&color=green" alt="PyPI - swarmauri_gitfilter_minio"/>
43
+ </a>
44
+ </p>
45
+
46
+ ---
47
+
48
+ # Swarmauri Git Filter Minio
49
+
50
+ `swarmauri_gitfilter_minio` packages the `MinioFilter` plugin used by
51
+ [`peagen`](https://pypi.org/project/peagen/) and other Swarmauri tooling to keep
52
+ large Git objects in MinIO (or any S3-compatible) storage instead of the local
53
+ repository. The filter implements both `StorageAdapterBase` and
54
+ `GitFilterBase`, so you can call it directly from Python code or register it as
55
+ a Git clean/smudge filter.
56
+
57
+ ### Highlights
58
+
59
+ - Accepts `minio://` (HTTP) and `minios://` (HTTPS) URIs and automatically
60
+ ensures the referenced bucket exists.
61
+ - Inherits `GitFilterBase`, giving you `clean` and `smudge` helpers that hash
62
+ content, upload it to remote storage, and hydrate it back into your working
63
+ tree on checkout.
64
+ - Provides convenience methods such as `upload_dir`, `iter_prefix`, and
65
+ `download_prefix` for whole directory trees in addition to single-file
66
+ transfers.
67
+ - Surfaces a `root_uri` property that reflects the bucket and optional prefix
68
+ derived from the connection string.
69
+
70
+ ## Installation
71
+
72
+ Choose the workflow that matches your project:
73
+
74
+ ```bash
75
+ # pip
76
+ pip install swarmauri_gitfilter_minio
77
+
78
+ # Poetry
79
+ poetry add swarmauri_gitfilter_minio
80
+
81
+ # uv
82
+ uv add swarmauri_gitfilter_minio
83
+ ```
84
+
85
+ ## Configuration
86
+
87
+ `MinioFilter.from_uri()` consults `peagen.toml` for credentials under
88
+ `[storage.filters.minio]` and falls back to the `MINIO_ACCESS_KEY` and
89
+ `MINIO_SECRET_KEY` environment variables when the configuration is absent. When
90
+ instantiated, the filter lazily creates the bucket identified by the URI and
91
+ stores objects beneath an optional prefix.
92
+
93
+ ## Usage
94
+
95
+ ```python
96
+ from swarmauri_gitfilter_minio import MinioFilter
97
+
98
+ # Create a filter from a connection string. The scheme `minios://` will use
99
+ # HTTPS while `minio://` uses plain HTTP.
100
+ filt = MinioFilter.from_uri("minio://localhost:9000/my-bucket/prefix")
101
+
102
+ # Upload a file and retrieve its URI
103
+ with open("README.md", "rb") as fh:
104
+ uri = filt.upload("docs/README.md", fh)
105
+
106
+ # Download the file back into memory
107
+ buffer = filt.download("docs/README.md")
108
+ data = buffer.read()
109
+ ```
110
+
111
+ `MinioFilter` also exposes helpers such as `upload_dir`, `iter_prefix`, and
112
+ `download_prefix` for working with entire directory trees.
113
+
114
+ ## Want to help?
115
+
116
+ If you want to contribute to swarmauri-sdk, read up on our
117
+ [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
118
+ that will help you get started.
119
+
@@ -0,0 +1,7 @@
1
+ swarmauri_gitfilter_minio/__init__.py,sha256=aF0ytzlFTyZpX6l7bslW11-usfpoBUFcqUM_vCayuDg,504
2
+ swarmauri_gitfilter_minio/minio_filter.py,sha256=xPG275m_jmw_N3y5aZTKuCw3zX9X5EoqQf_u7F4sIBc,7139
3
+ swarmauri_gitfilter_minio-0.3.0.dev34.dist-info/METADATA,sha256=BUkmwhx_qamvtllus8Iqi6UvwugiilImB6UkiOmPA5I,4520
4
+ swarmauri_gitfilter_minio-0.3.0.dev34.dist-info/WHEEL,sha256=kJCRJT_g0adfAJzTx2GUMmS80rTJIVHRCfG0DQgLq3o,88
5
+ swarmauri_gitfilter_minio-0.3.0.dev34.dist-info/entry_points.txt,sha256=crJNwAyvwDDwbBkIBIh87jAxeEIplLE1rJxY_bjnWDs,175
6
+ swarmauri_gitfilter_minio-0.3.0.dev34.dist-info/licenses/LICENSE,sha256=djUXOlCxLVszShEpZXshZ7v33G-2qIC_j9KXpWKZSzQ,11359
7
+ swarmauri_gitfilter_minio-0.3.0.dev34.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.3
2
+ Generator: poetry-core 2.3.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,61 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: swarmauri_gitfilter_minio
3
- Version: 0.3.0.dev4
4
- Summary: MinIO git filter 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: minio
16
- Requires-Dist: peagen
17
- Requires-Dist: swarmauri_base
18
- Requires-Dist: swarmauri_core
19
- Requires-Dist: swarmauri_standard
20
- Description-Content-Type: text/markdown
21
-
22
- ![Swamauri Logo](https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png)
23
-
24
- <p align="center">
25
- <a href="https://pypi.org/project/swarmauri_gitfilter_minio/">
26
- <img src="https://img.shields.io/pypi/dm/swarmauri_gitfilter_minio" alt="PyPI - Downloads"/>
27
- </a>
28
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_gitfilter_minio/">
29
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_gitfilter_minio.svg"/>
30
- </a>
31
- <a href="https://pypi.org/project/swarmauri_gitfilter_minio/">
32
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_gitfilter_minio" alt="PyPI - Python Version"/>
33
- </a>
34
- <a href="https://pypi.org/project/swarmauri_gitfilter_minio/">
35
- <img src="https://img.shields.io/pypi/l/swarmauri_gitfilter_minio" alt="PyPI - License"/>
36
- </a>
37
- <a href="https://pypi.org/project/swarmauri_gitfilter_minio/">
38
- <img src="https://img.shields.io/pypi/v/swarmauri_gitfilter_minio?label=swarmauri_gitfilter_minio&color=green" alt="PyPI - swarmauri_gitfilter_minio"/>
39
- </a>
40
- </p>
41
-
42
- ---
43
-
44
- # Swarmauri Git Filter Minio
45
-
46
- Git filter using MinIO or S3 compatible storage.
47
-
48
- ## Installation
49
-
50
- ```bash
51
- pip install swarmauri_gitfilter_minio
52
- ```
53
-
54
- ## Usage
55
-
56
- ```python
57
- from swarmauri_gitfilter_minio import MinioFilter
58
-
59
- filt = MinioFilter.from_uri("minio://localhost:9000/bucket")
60
- ```
61
-
@@ -1,7 +0,0 @@
1
- swarmauri_gitfilter_minio/__init__.py,sha256=7GtV6gG5uaWAYGV_uVEjLwhz1utJ7R-bRz95IKW1kGc,417
2
- swarmauri_gitfilter_minio/minio_filter.py,sha256=SAVWaZPQHGEH4rd8euGzqokORm1G_R8ChqZzBmcThXU,4810
3
- swarmauri_gitfilter_minio-0.3.0.dev4.dist-info/LICENSE,sha256=djUXOlCxLVszShEpZXshZ7v33G-2qIC_j9KXpWKZSzQ,11359
4
- swarmauri_gitfilter_minio-0.3.0.dev4.dist-info/METADATA,sha256=-jOkINU-me0-Cf2efXCLElfbWljTt_I7umc-K8XUgvs,2190
5
- swarmauri_gitfilter_minio-0.3.0.dev4.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
6
- swarmauri_gitfilter_minio-0.3.0.dev4.dist-info/entry_points.txt,sha256=crJNwAyvwDDwbBkIBIh87jAxeEIplLE1rJxY_bjnWDs,175
7
- swarmauri_gitfilter_minio-0.3.0.dev4.dist-info/RECORD,,