swarmauri_storage_github_release 0.3.0.dev4__tar.gz → 0.3.0.dev24__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.
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarmauri_storage_github_release
3
+ Version: 0.3.0.dev24
4
+ Summary: GitHub Release storage adapter for Peagen
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: swarmauri,sdk,standards,storage,github,release
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: PyGithub
20
+ Requires-Dist: swarmauri_base
21
+ Requires-Dist: swarmauri_core
22
+ Requires-Dist: swarmauri_standard
23
+ Description-Content-Type: text/markdown
24
+
25
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
26
+
27
+ <p align="center">
28
+ <a href="https://pypi.org/project/swarmauri_storage_github_release/">
29
+ <img src="https://img.shields.io/pypi/dm/swarmauri_storage_github_release" alt="PyPI - Downloads"/></a>
30
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_storage_github_release/">
31
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_storage_github_release.svg"/></a>
32
+ <a href="https://pypi.org/project/swarmauri_storage_github_release/">
33
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_storage_github_release" alt="PyPI - Python Version"/></a>
34
+ <a href="https://pypi.org/project/swarmauri_storage_github_release/">
35
+ <img src="https://img.shields.io/pypi/l/swarmauri_storage_github_release" alt="PyPI - License"/></a>
36
+ <a href="https://pypi.org/project/swarmauri_storage_github_release/">
37
+ <img src="https://img.shields.io/pypi/v/swarmauri_storage_github_release?label=swarmauri_storage_github_release&color=green" alt="PyPI - swarmauri_storage_github_release"/></a>
38
+
39
+ </p>
40
+
41
+ ---
42
+
43
+ # Swarmauri GitHub Release Storage Adapter
44
+
45
+ Stores and retrieves artifacts as assets on a GitHub release. The adapter is
46
+ designed to plug directly into the Swarmauri/Peagen storage interfaces while
47
+ still being usable as a standalone utility.
48
+
49
+ ## Features
50
+
51
+ - **Automatic release management** – a release is created on-demand when the
52
+ requested tag does not already exist.
53
+ - **`ghrel://` addressing** – the adapter exposes a `root_uri` and returns
54
+ fully-qualified URIs (e.g. `ghrel://org/repo/tag/path`) from `upload` calls.
55
+ - **Prefix-aware paths** – supply an optional `prefix` to group related assets
56
+ underneath a pseudo-directory on the release.
57
+ - **Bulk helpers** – use `upload_dir` and `download_dir` to synchronise entire
58
+ directories, or `iter_prefix` to discover stored assets.
59
+ - **Configuration friendly** – `GithubReleaseStorageAdapter.from_uri` reads
60
+ credentials from the `GITHUB_TOKEN` environment variable for simple
61
+ environment-driven configuration in workflows.
62
+
63
+ ## Requirements
64
+
65
+ - A GitHub personal access token (PAT) or GitHub App token with sufficient
66
+ permissions to view, create and manage releases on the target repository.
67
+ - Network access to the GitHub REST API (provided by `PyGithub`).
68
+ - Python 3.10 through 3.12.
69
+
70
+ ## Installation
71
+
72
+ ### Install uv (optional)
73
+
74
+ ```bash
75
+ curl -LsSf https://astral.sh/uv/install.sh | sh
76
+ ```
77
+
78
+ ### Add the package with uv
79
+
80
+ ```bash
81
+ uv add swarmauri_storage_github_release
82
+ ```
83
+
84
+ ### Add with Poetry
85
+
86
+ ```bash
87
+ poetry add swarmauri_storage_github_release
88
+ ```
89
+
90
+ ### Install with pip
91
+
92
+ ```bash
93
+ pip install swarmauri_storage_github_release
94
+ ```
95
+
96
+ ## Usage
97
+
98
+ ```python
99
+ from io import BytesIO
100
+
101
+ from pydantic import SecretStr
102
+
103
+ from swarmauri_storage_github_release import GithubReleaseStorageAdapter
104
+
105
+ adapter = GithubReleaseStorageAdapter(
106
+ token=SecretStr("ghp_example-token"),
107
+ org="example-org",
108
+ repo="example-repo",
109
+ tag="v1.0.0",
110
+ prefix="artifacts",
111
+ release_name="Example release",
112
+ message="Artifacts published by our workflow.",
113
+ )
114
+
115
+ print(adapter.root_uri)
116
+
117
+ uri = adapter.upload("artifact.txt", BytesIO(b"important payload"))
118
+ downloaded_payload = adapter.download("artifact.txt").read()
119
+ assets = list(adapter.iter_prefix(""))
120
+
121
+ print(uri)
122
+ print(downloaded_payload)
123
+ print(assets)
124
+ ```
125
+
126
+ The code above demonstrates:
127
+
128
+ - `SecretStr` support for securely passing tokens.
129
+ - Automatic release creation when the `v1.0.0` tag does not exist.
130
+ - Prefix-aware uploads that produce the URI
131
+ `ghrel://example-org/example-repo/v1.0.0/artifacts/artifacts/artifact.txt`
132
+ (the asset key itself contains the prefix, so it appears in the base URI and
133
+ the returned asset key).
134
+ - Round-tripping an asset and enumerating stored keys via `iter_prefix`.
135
+
136
+ ## Working with directories
137
+
138
+ Use the bulk helper methods to synchronise entire directory trees:
139
+
140
+ ```python
141
+ adapter.upload_dir("dist", prefix="binaries")
142
+ adapter.download_dir("binaries", "./downloads")
143
+ ```
144
+
145
+ Both helpers respect the adapter-level prefix and will mirror nested folders.
146
+
147
+ ## Using `ghrel://` URIs and configuration
148
+
149
+ The `from_uri` class method creates adapters from an address such as:
150
+
151
+ ```python
152
+ adapter = GithubReleaseStorageAdapter.from_uri(
153
+ "ghrel://example-org/example-repo/v1.0.0/artifacts",
154
+ )
155
+ ```
156
+
157
+ When invoked this way the adapter builds an unauthenticated client
158
+ (`token=""`).
159
+
160
+ Any prefix encoded in the URI is respected, and the resulting instance exposes
161
+ the same API shown above. For private repositories or higher rate limits,
162
+ instantiate the adapter directly and provide a token.
163
+
164
+ ### Controlling release metadata
165
+
166
+ The constructor accepts additional keyword arguments to fine tune release
167
+ creation, including `release_name`, `message`, `draft`, and `prerelease`. These
168
+ parameters map directly to GitHub's release settings, allowing you to reuse the
169
+ adapter for production, staging, or nightly build workflows.
170
+
171
+ ## Want to help?
172
+
173
+ If you want to contribute to swarmauri-sdk, read up on our
174
+ [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
175
+ that will help you get started.
@@ -0,0 +1,151 @@
1
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
2
+
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/swarmauri_storage_github_release/">
5
+ <img src="https://img.shields.io/pypi/dm/swarmauri_storage_github_release" alt="PyPI - Downloads"/></a>
6
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_storage_github_release/">
7
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_storage_github_release.svg"/></a>
8
+ <a href="https://pypi.org/project/swarmauri_storage_github_release/">
9
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_storage_github_release" alt="PyPI - Python Version"/></a>
10
+ <a href="https://pypi.org/project/swarmauri_storage_github_release/">
11
+ <img src="https://img.shields.io/pypi/l/swarmauri_storage_github_release" alt="PyPI - License"/></a>
12
+ <a href="https://pypi.org/project/swarmauri_storage_github_release/">
13
+ <img src="https://img.shields.io/pypi/v/swarmauri_storage_github_release?label=swarmauri_storage_github_release&color=green" alt="PyPI - swarmauri_storage_github_release"/></a>
14
+
15
+ </p>
16
+
17
+ ---
18
+
19
+ # Swarmauri GitHub Release Storage Adapter
20
+
21
+ Stores and retrieves artifacts as assets on a GitHub release. The adapter is
22
+ designed to plug directly into the Swarmauri/Peagen storage interfaces while
23
+ still being usable as a standalone utility.
24
+
25
+ ## Features
26
+
27
+ - **Automatic release management** – a release is created on-demand when the
28
+ requested tag does not already exist.
29
+ - **`ghrel://` addressing** – the adapter exposes a `root_uri` and returns
30
+ fully-qualified URIs (e.g. `ghrel://org/repo/tag/path`) from `upload` calls.
31
+ - **Prefix-aware paths** – supply an optional `prefix` to group related assets
32
+ underneath a pseudo-directory on the release.
33
+ - **Bulk helpers** – use `upload_dir` and `download_dir` to synchronise entire
34
+ directories, or `iter_prefix` to discover stored assets.
35
+ - **Configuration friendly** – `GithubReleaseStorageAdapter.from_uri` reads
36
+ credentials from the `GITHUB_TOKEN` environment variable for simple
37
+ environment-driven configuration in workflows.
38
+
39
+ ## Requirements
40
+
41
+ - A GitHub personal access token (PAT) or GitHub App token with sufficient
42
+ permissions to view, create and manage releases on the target repository.
43
+ - Network access to the GitHub REST API (provided by `PyGithub`).
44
+ - Python 3.10 through 3.12.
45
+
46
+ ## Installation
47
+
48
+ ### Install uv (optional)
49
+
50
+ ```bash
51
+ curl -LsSf https://astral.sh/uv/install.sh | sh
52
+ ```
53
+
54
+ ### Add the package with uv
55
+
56
+ ```bash
57
+ uv add swarmauri_storage_github_release
58
+ ```
59
+
60
+ ### Add with Poetry
61
+
62
+ ```bash
63
+ poetry add swarmauri_storage_github_release
64
+ ```
65
+
66
+ ### Install with pip
67
+
68
+ ```bash
69
+ pip install swarmauri_storage_github_release
70
+ ```
71
+
72
+ ## Usage
73
+
74
+ ```python
75
+ from io import BytesIO
76
+
77
+ from pydantic import SecretStr
78
+
79
+ from swarmauri_storage_github_release import GithubReleaseStorageAdapter
80
+
81
+ adapter = GithubReleaseStorageAdapter(
82
+ token=SecretStr("ghp_example-token"),
83
+ org="example-org",
84
+ repo="example-repo",
85
+ tag="v1.0.0",
86
+ prefix="artifacts",
87
+ release_name="Example release",
88
+ message="Artifacts published by our workflow.",
89
+ )
90
+
91
+ print(adapter.root_uri)
92
+
93
+ uri = adapter.upload("artifact.txt", BytesIO(b"important payload"))
94
+ downloaded_payload = adapter.download("artifact.txt").read()
95
+ assets = list(adapter.iter_prefix(""))
96
+
97
+ print(uri)
98
+ print(downloaded_payload)
99
+ print(assets)
100
+ ```
101
+
102
+ The code above demonstrates:
103
+
104
+ - `SecretStr` support for securely passing tokens.
105
+ - Automatic release creation when the `v1.0.0` tag does not exist.
106
+ - Prefix-aware uploads that produce the URI
107
+ `ghrel://example-org/example-repo/v1.0.0/artifacts/artifacts/artifact.txt`
108
+ (the asset key itself contains the prefix, so it appears in the base URI and
109
+ the returned asset key).
110
+ - Round-tripping an asset and enumerating stored keys via `iter_prefix`.
111
+
112
+ ## Working with directories
113
+
114
+ Use the bulk helper methods to synchronise entire directory trees:
115
+
116
+ ```python
117
+ adapter.upload_dir("dist", prefix="binaries")
118
+ adapter.download_dir("binaries", "./downloads")
119
+ ```
120
+
121
+ Both helpers respect the adapter-level prefix and will mirror nested folders.
122
+
123
+ ## Using `ghrel://` URIs and configuration
124
+
125
+ The `from_uri` class method creates adapters from an address such as:
126
+
127
+ ```python
128
+ adapter = GithubReleaseStorageAdapter.from_uri(
129
+ "ghrel://example-org/example-repo/v1.0.0/artifacts",
130
+ )
131
+ ```
132
+
133
+ When invoked this way the adapter builds an unauthenticated client
134
+ (`token=""`).
135
+
136
+ Any prefix encoded in the URI is respected, and the resulting instance exposes
137
+ the same API shown above. For private repositories or higher rate limits,
138
+ instantiate the adapter directly and provide a token.
139
+
140
+ ### Controlling release metadata
141
+
142
+ The constructor accepts additional keyword arguments to fine tune release
143
+ creation, including `release_name`, `message`, `draft`, and `prerelease`. These
144
+ parameters map directly to GitHub's release settings, allowing you to reuse the
145
+ adapter for production, staging, or nightly build workflows.
146
+
147
+ ## Want to help?
148
+
149
+ If you want to contribute to swarmauri-sdk, read up on our
150
+ [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
151
+ that will help you get started.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "swarmauri_storage_github_release"
3
- version = "0.3.0.dev4"
3
+ version = "0.3.0.dev24"
4
4
  authors = [
5
5
  { name = "Jacob Stewart", email = "jacob@swarmauri.com" }
6
6
  ]
@@ -16,17 +16,25 @@ 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
  "PyGithub",
23
24
  "swarmauri_core",
24
25
  "swarmauri_base",
25
26
  "swarmauri_standard",
26
27
  ]
28
+ keywords = [
29
+ 'swarmauri',
30
+ 'sdk',
31
+ 'standards',
32
+ 'storage',
33
+ 'github',
34
+ 'release',
35
+ ]
27
36
 
28
37
  [tool.uv.sources]
29
- peagen = { workspace = true }
30
38
  swarmauri_core = { workspace = true }
31
39
  swarmauri_base = { workspace = true }
32
40
  swarmauri_standard = { workspace = true }
@@ -44,6 +52,7 @@ markers = [
44
52
  "unit: Unit tests",
45
53
  "i9n: Integration tests",
46
54
  "r8n: Regression tests",
55
+ "example: Documentation examples",
47
56
  "timeout: mark test to timeout after X seconds",
48
57
  "xpass: Expected passes",
49
58
  "xfail: Expected failures",
@@ -14,7 +14,6 @@ from typing import BinaryIO, Optional
14
14
  from swarmauri_base.ComponentBase import ComponentBase
15
15
  from swarmauri_base.storage import StorageAdapterBase
16
16
 
17
- from peagen._utils.config_loader import load_peagen_toml
18
17
  from github import Github, UnknownObjectException
19
18
 
20
19
 
@@ -144,16 +143,34 @@ class GithubReleaseStorageAdapter(StorageAdapterBase):
144
143
  def download_dir(self, prefix: str, dest_dir: str | os.PathLike) -> None:
145
144
  """Download all assets under *prefix* into *dest_dir*."""
146
145
  dest = Path(dest_dir)
146
+ base = prefix.strip("/")
147
147
  for rel_key in self.iter_prefix(prefix):
148
- target = dest / rel_key
148
+ rel = rel_key
149
+ if base:
150
+ rel = (
151
+ rel_key[len(base) :].lstrip("/")
152
+ if rel_key.startswith(base)
153
+ else rel
154
+ )
155
+ if not rel:
156
+ continue
157
+ target = dest / rel
149
158
  target.parent.mkdir(parents=True, exist_ok=True)
150
159
  data = self.download(rel_key)
151
160
  with target.open("wb") as fh:
152
161
  shutil.copyfileobj(data, fh)
153
162
 
163
+ async def remove_object(self, object_key: str) -> None:
164
+ """Delete an asset when present in the release."""
165
+ key = self._full_key(object_key)
166
+ for asset in self._release.get_assets():
167
+ if asset.name == key:
168
+ asset.delete_asset()
169
+ return
170
+
154
171
  # --------------------------------------------------------------------- class
155
172
  @classmethod
156
- def from_uri(cls, uri: str) -> "GithubReleaseStorageAdapter":
173
+ def from_uri(cls, uri: str, token) -> "GithubReleaseStorageAdapter":
157
174
  from urllib.parse import urlparse
158
175
 
159
176
  p = urlparse(uri)
@@ -161,11 +178,6 @@ class GithubReleaseStorageAdapter(StorageAdapterBase):
161
178
  repo, tag, *rest = p.path.lstrip("/").split("/", 2)
162
179
  prefix = rest[0] if rest else ""
163
180
 
164
- cfg = load_peagen_toml()
165
- gh_cfg = cfg.get("storage", {}).get("adapters", {}).get("gh_release", {})
166
-
167
- token = gh_cfg.get("token") or os.getenv("GITHUB_TOKEN", "")
168
-
169
181
  return cls(
170
182
  token=token,
171
183
  org=org,
@@ -1,48 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: swarmauri_storage_github_release
3
- Version: 0.3.0.dev4
4
- Summary: GitHub Release 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: PyGithub
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
- # Swarmauri GitHub Release Storage Adapter
23
-
24
- Stores artifacts as assets on a GitHub release for use with Peagen.
25
-
26
- ## Installation
27
-
28
- ```bash
29
- # pip install swarmauri_storage_github_release (when published)
30
- ```
31
-
32
- ## Usage
33
-
34
- ```python
35
- from swarmauri_storage_github_release import GithubReleaseStorageAdapter
36
- from pydantic import SecretStr
37
- import io
38
-
39
- adapter = GithubReleaseStorageAdapter(
40
- token=SecretStr("ghp_..."),
41
- org="my-org",
42
- repo="my-repo",
43
- tag="v1.0.0",
44
- )
45
- uri = adapter.upload("artifact.txt", io.BytesIO(b"data"))
46
- print(uri)
47
- ```
48
-
@@ -1,26 +0,0 @@
1
- # Swarmauri GitHub Release Storage Adapter
2
-
3
- Stores artifacts as assets on a GitHub release for use with Peagen.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- # pip install swarmauri_storage_github_release (when published)
9
- ```
10
-
11
- ## Usage
12
-
13
- ```python
14
- from swarmauri_storage_github_release import GithubReleaseStorageAdapter
15
- from pydantic import SecretStr
16
- import io
17
-
18
- adapter = GithubReleaseStorageAdapter(
19
- token=SecretStr("ghp_..."),
20
- org="my-org",
21
- repo="my-repo",
22
- tag="v1.0.0",
23
- )
24
- uri = adapter.upload("artifact.txt", io.BytesIO(b"data"))
25
- print(uri)
26
- ```