sartre 0.1.0__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.
- sartre-0.1.0/LICENSE +202 -0
- sartre-0.1.0/NOTICE +10 -0
- sartre-0.1.0/PKG-INFO +204 -0
- sartre-0.1.0/README.md +168 -0
- sartre-0.1.0/pyproject.toml +99 -0
- sartre-0.1.0/pyproject.toml.orig +101 -0
- sartre-0.1.0/src/sartre/__init__.py +109 -0
- sartre-0.1.0/src/sartre/_sql.py +353 -0
- sartre-0.1.0/src/sartre/cli/__init__.py +20 -0
- sartre-0.1.0/src/sartre/cli/app.py +305 -0
- sartre-0.1.0/src/sartre/cli/config.py +193 -0
- sartre-0.1.0/src/sartre/cli/duration.py +45 -0
- sartre-0.1.0/src/sartre/cli/errors.py +9 -0
- sartre-0.1.0/src/sartre/cli/ops.py +225 -0
- sartre-0.1.0/src/sartre/cli/refs.py +89 -0
- sartre-0.1.0/src/sartre/cloud.py +38 -0
- sartre-0.1.0/src/sartre/errors.py +35 -0
- sartre-0.1.0/src/sartre/fs.py +117 -0
- sartre-0.1.0/src/sartre/hashing.py +100 -0
- sartre-0.1.0/src/sartre/local.py +31 -0
- sartre-0.1.0/src/sartre/memory.py +242 -0
- sartre-0.1.0/src/sartre/model.py +104 -0
- sartre-0.1.0/src/sartre/paths.py +95 -0
- sartre-0.1.0/src/sartre/ports.py +314 -0
- sartre-0.1.0/src/sartre/postgres.py +49 -0
- sartre-0.1.0/src/sartre/py.typed +0 -0
- sartre-0.1.0/src/sartre/repository.py +419 -0
- sartre-0.1.0/src/sartre/s3.py +406 -0
- sartre-0.1.0/src/sartre/sqlite.py +47 -0
- sartre-0.1.0/src/sartre/store.py +292 -0
sartre-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
sartre-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Sartre — Simple ARTifact REpository
|
|
2
|
+
Copyright 2026 Vic Putz
|
|
3
|
+
|
|
4
|
+
This product includes software developed by Vic Putz and contributors.
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License.
|
|
8
|
+
You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
sartre-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sartre
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Sartre: Simple ARTifact REpository — a content-addressed versioned binary artifact repository (manifest plane + blob plane).
|
|
5
|
+
Keywords: artifact-repository,content-addressed,versioning,blob-store,model-registry,data-versioning,fsspec
|
|
6
|
+
Author: Vic Putz
|
|
7
|
+
Author-email: Vic Putz <vputz@protonmail.com>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: NOTICE
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Software Development :: Version Control
|
|
18
|
+
Classifier: Topic :: System :: Archiving
|
|
19
|
+
Classifier: Topic :: Database
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Dist: fsspec>=2024.0
|
|
22
|
+
Requires-Dist: typer>=0.12 ; extra == 'cli'
|
|
23
|
+
Requires-Dist: gcsfs>=2024.0 ; extra == 'gcs'
|
|
24
|
+
Requires-Dist: psycopg[binary]>=3.1 ; extra == 'postgres'
|
|
25
|
+
Requires-Dist: boto3>=1.34 ; extra == 's3'
|
|
26
|
+
Requires-Dist: s3fs>=2024.0 ; extra == 's3'
|
|
27
|
+
Requires-Python: >=3.12
|
|
28
|
+
Project-URL: Homepage, https://github.com/vputz/sartre
|
|
29
|
+
Project-URL: Repository, https://github.com/vputz/sartre
|
|
30
|
+
Project-URL: Issues, https://github.com/vputz/sartre/issues
|
|
31
|
+
Provides-Extra: cli
|
|
32
|
+
Provides-Extra: gcs
|
|
33
|
+
Provides-Extra: postgres
|
|
34
|
+
Provides-Extra: s3
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# sartre
|
|
38
|
+
|
|
39
|
+
**S**imple **ART**ifact **RE**pository — a generic, content-addressed
|
|
40
|
+
**versioned binary artifact repository** for Python.
|
|
41
|
+
|
|
42
|
+
> "Hell is other people's artifact repositories" — Jean-Paul Sartre
|
|
43
|
+
|
|
44
|
+
Publish a tree of files as an immutable, content-addressed **version**; move
|
|
45
|
+
mutable **pointers** (`head`, or named aliases like `stable`/`prod`) at it; fetch
|
|
46
|
+
any version back — lazily, verified, and deduplicated by content hash. Every
|
|
47
|
+
change records **who** made it and **why**.
|
|
48
|
+
|
|
49
|
+
Two cleanly separated planes:
|
|
50
|
+
|
|
51
|
+
- **Manifest plane** (`Registry`) — a transactional metadata store mapping
|
|
52
|
+
`(name, env, version, path) → content_hash`, plus mutable pointers
|
|
53
|
+
(`Head`/`Alias`/`Pin`) that resolve to immutable versions. Backed by SQLite
|
|
54
|
+
(local) or Postgres (shared).
|
|
55
|
+
- **Blob plane** (`Store`) — a dumb content-addressed object store holding
|
|
56
|
+
immutable bytes keyed by their own hash, over any [fsspec](https://filesystem-spec.readthedocs.io/)
|
|
57
|
+
filesystem (local disk, S3, GCS, …). Dedup is structural; GC is mark-and-sweep.
|
|
58
|
+
|
|
59
|
+
A `Version` is the hash of its manifest entries, so identical content is stored
|
|
60
|
+
once and promotes across environments for free. Reads never materialize a whole
|
|
61
|
+
blob into memory, so multi-hundred-megabyte artifacts stream.
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install sartre # library core (fsspec only)
|
|
67
|
+
pip install "sartre[cli]" # + the `sartre` command line
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
| Extra | Pulls in | For |
|
|
71
|
+
| ---------- | ---------------------------- | ------------------------------------- |
|
|
72
|
+
| `cli` | `typer` | the `sartre` command-line tool |
|
|
73
|
+
| `postgres` | `psycopg` | a shared Postgres manifest plane |
|
|
74
|
+
| `s3` | `boto3`, `s3fs` | S3 blob storage |
|
|
75
|
+
| `gcs` | `gcsfs` | Google Cloud Storage blob storage |
|
|
76
|
+
|
|
77
|
+
Requires Python 3.12+. The package ships type information (PEP 561 `py.typed`).
|
|
78
|
+
|
|
79
|
+
## Quickstart — command line
|
|
80
|
+
|
|
81
|
+
A local repository is just a directory (`registry.db` + `blobs/`):
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# publish a directory as a new version, attributing who and why
|
|
85
|
+
sartre --repo ./repo publish models/prod ./checkpoint --as alice -m "initial train"
|
|
86
|
+
# → sha256:554b7a…
|
|
87
|
+
|
|
88
|
+
# ...change the files, publish again — a new version, head advances
|
|
89
|
+
sartre --repo ./repo publish models/prod ./checkpoint --as alice -m "retrain on Q3"
|
|
90
|
+
|
|
91
|
+
# promote a specific version to a named pointer (compare-and-swap safe)
|
|
92
|
+
sartre --repo ./repo point models/prod:stable sha256:554b7a… --as bob -m "passed eval"
|
|
93
|
+
|
|
94
|
+
sartre --repo ./repo show models/prod # version, author, reason, entries
|
|
95
|
+
sartre --repo ./repo log models/prod # commit history with author + reason
|
|
96
|
+
sartre --repo ./repo history models/prod # who moved which pointer, from → to, why
|
|
97
|
+
sartre --repo ./repo ls models/prod:stable # list a version's files (no download)
|
|
98
|
+
sartre --repo ./repo cat models/prod cfg.json # stream one file (verified) to stdout
|
|
99
|
+
sartre --repo ./repo checkout models/prod ./out # materialize the whole tree
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Reference grammar: `name/env` (head) · `name/env:alias` · `name/env@sha256:…` (pin).
|
|
103
|
+
Add `--json` to any command for machine-readable output. `head`/`ls` are bare for
|
|
104
|
+
scripting. Point a command at a shared repo with `--registry <dsn> --blobs <url>`,
|
|
105
|
+
`$SARTRE_REPO`, or a profile in `~/.config/sartre/config.toml`.
|
|
106
|
+
|
|
107
|
+
## Quickstart — library
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from pathlib import Path
|
|
111
|
+
from sartre import open_local, Coordinate, Alias
|
|
112
|
+
|
|
113
|
+
repo = open_local("./repo") # SQLite + local blobs; reopen to recover
|
|
114
|
+
coord = Coordinate("models", "prod")
|
|
115
|
+
|
|
116
|
+
# publish a mapping of logical path -> bytes (or Path); returns the version id
|
|
117
|
+
version = repo.publish(
|
|
118
|
+
coord,
|
|
119
|
+
{"w/model.bin": b"...weights...", "cfg.json": b"{}"},
|
|
120
|
+
actor="alice",
|
|
121
|
+
reason="initial train",
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
# resolve a pointer to an immutable snapshot (manifest only — no blob bytes yet)
|
|
125
|
+
snap = repo.resolve(coord) # head by default
|
|
126
|
+
print(snap.version, [e.path for e in snap.entries])
|
|
127
|
+
|
|
128
|
+
# materialize bytes lazily, verified and content-cached
|
|
129
|
+
local_path = repo.open(snap, "cfg.json") # one file
|
|
130
|
+
repo.checkout(snap, Path("./out")) # the whole tree
|
|
131
|
+
|
|
132
|
+
# move a mutable pointer to an existing version (promote / roll back)
|
|
133
|
+
repo.point(coord, "stable", version, expected=None, actor="bob", reason="passed eval")
|
|
134
|
+
assert repo.head(coord, Alias("stable")) == version
|
|
135
|
+
|
|
136
|
+
# provenance is on the event, not the shared manifest
|
|
137
|
+
for entry in repo.list_log(coord): # who published/promoted each tip, and why
|
|
138
|
+
print(entry.version, entry.actor, entry.reason)
|
|
139
|
+
for move in repo.list_pointer_history(coord): # the pointer-move audit trail
|
|
140
|
+
print(move.name, move.from_version, "->", move.to_version, move.actor)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### A shared, cloud-backed repository
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from sartre import open_cloud
|
|
147
|
+
|
|
148
|
+
repo = open_cloud(
|
|
149
|
+
"postgresql://user:pw@host/db", # Postgres manifest plane (needs the `postgres` extra)
|
|
150
|
+
"s3://my-bucket/artifacts", # any fsspec blob URL (needs `s3`/`gcs` as appropriate)
|
|
151
|
+
cache_dir="/var/cache/sartre", # optional local read-through cache
|
|
152
|
+
)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The API is identical; only the backends differ. `AsyncRepository` wraps a
|
|
156
|
+
`Repository` with awaitable equivalents.
|
|
157
|
+
|
|
158
|
+
## What you get
|
|
159
|
+
|
|
160
|
+
- **Content-addressed & deduplicated** — a version is its manifest hash; identical
|
|
161
|
+
files are stored once and promote across environments with no copy.
|
|
162
|
+
- **Change provenance** — every commit and every pointer move records `actor` +
|
|
163
|
+
`reason`; the pointer-move history answers "who changed prod, from what, and why."
|
|
164
|
+
- **Streaming** — publish and fetch never buffer a whole blob in memory.
|
|
165
|
+
- **Safe concurrency** — pointer moves are compare-and-swap; publishes hold a
|
|
166
|
+
TTL lease so a concurrent garbage collector never reclaims in-flight blobs
|
|
167
|
+
(the GC/lease protocol is verified in TLA+).
|
|
168
|
+
- **Garbage collection** — mark-and-sweep with retention policies
|
|
169
|
+
(`keep_last_n`, `keep_within`, a blob grace period).
|
|
170
|
+
|
|
171
|
+
See [`binary-artifact-repo-design.md`](binary-artifact-repo-design.md) for the
|
|
172
|
+
full design memo.
|
|
173
|
+
|
|
174
|
+
## Development
|
|
175
|
+
|
|
176
|
+
This project uses:
|
|
177
|
+
|
|
178
|
+
- **uv** — Python environment & packaging (`uv sync`, `uv run pytest`)
|
|
179
|
+
- **jj** (colocated with git) — version control
|
|
180
|
+
- **nix** (`shell.nix` + `direnv`) — reproducible dev shell
|
|
181
|
+
- **OpenSpec** — spec-driven change workflow (`openspec/`, `/opsx:*` skills)
|
|
182
|
+
- **TLA+** — protocol model checking (`tla-*` skills, `tla-verifier` agent)
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
nix-shell # or: direnv allow
|
|
186
|
+
uv sync # create .venv and install dev tooling
|
|
187
|
+
uv run pytest # run tests
|
|
188
|
+
uv run ruff check # lint
|
|
189
|
+
uv run pyright # type-check
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Layout
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
src/sartre/ library source (registry backends, stores, repository, CLI)
|
|
196
|
+
tests/ tests (unit, property-based, differential, e2e)
|
|
197
|
+
openspec/ spec-driven change proposals & living specs
|
|
198
|
+
binary-artifact-repo-design.md design memo
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
Licensed under the [Apache License 2.0](LICENSE) — permissive, commercial-use
|
|
204
|
+
friendly, with an explicit patent grant. See [`NOTICE`](NOTICE).
|
sartre-0.1.0/README.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# sartre
|
|
2
|
+
|
|
3
|
+
**S**imple **ART**ifact **RE**pository — a generic, content-addressed
|
|
4
|
+
**versioned binary artifact repository** for Python.
|
|
5
|
+
|
|
6
|
+
> "Hell is other people's artifact repositories" — Jean-Paul Sartre
|
|
7
|
+
|
|
8
|
+
Publish a tree of files as an immutable, content-addressed **version**; move
|
|
9
|
+
mutable **pointers** (`head`, or named aliases like `stable`/`prod`) at it; fetch
|
|
10
|
+
any version back — lazily, verified, and deduplicated by content hash. Every
|
|
11
|
+
change records **who** made it and **why**.
|
|
12
|
+
|
|
13
|
+
Two cleanly separated planes:
|
|
14
|
+
|
|
15
|
+
- **Manifest plane** (`Registry`) — a transactional metadata store mapping
|
|
16
|
+
`(name, env, version, path) → content_hash`, plus mutable pointers
|
|
17
|
+
(`Head`/`Alias`/`Pin`) that resolve to immutable versions. Backed by SQLite
|
|
18
|
+
(local) or Postgres (shared).
|
|
19
|
+
- **Blob plane** (`Store`) — a dumb content-addressed object store holding
|
|
20
|
+
immutable bytes keyed by their own hash, over any [fsspec](https://filesystem-spec.readthedocs.io/)
|
|
21
|
+
filesystem (local disk, S3, GCS, …). Dedup is structural; GC is mark-and-sweep.
|
|
22
|
+
|
|
23
|
+
A `Version` is the hash of its manifest entries, so identical content is stored
|
|
24
|
+
once and promotes across environments for free. Reads never materialize a whole
|
|
25
|
+
blob into memory, so multi-hundred-megabyte artifacts stream.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install sartre # library core (fsspec only)
|
|
31
|
+
pip install "sartre[cli]" # + the `sartre` command line
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
| Extra | Pulls in | For |
|
|
35
|
+
| ---------- | ---------------------------- | ------------------------------------- |
|
|
36
|
+
| `cli` | `typer` | the `sartre` command-line tool |
|
|
37
|
+
| `postgres` | `psycopg` | a shared Postgres manifest plane |
|
|
38
|
+
| `s3` | `boto3`, `s3fs` | S3 blob storage |
|
|
39
|
+
| `gcs` | `gcsfs` | Google Cloud Storage blob storage |
|
|
40
|
+
|
|
41
|
+
Requires Python 3.12+. The package ships type information (PEP 561 `py.typed`).
|
|
42
|
+
|
|
43
|
+
## Quickstart — command line
|
|
44
|
+
|
|
45
|
+
A local repository is just a directory (`registry.db` + `blobs/`):
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# publish a directory as a new version, attributing who and why
|
|
49
|
+
sartre --repo ./repo publish models/prod ./checkpoint --as alice -m "initial train"
|
|
50
|
+
# → sha256:554b7a…
|
|
51
|
+
|
|
52
|
+
# ...change the files, publish again — a new version, head advances
|
|
53
|
+
sartre --repo ./repo publish models/prod ./checkpoint --as alice -m "retrain on Q3"
|
|
54
|
+
|
|
55
|
+
# promote a specific version to a named pointer (compare-and-swap safe)
|
|
56
|
+
sartre --repo ./repo point models/prod:stable sha256:554b7a… --as bob -m "passed eval"
|
|
57
|
+
|
|
58
|
+
sartre --repo ./repo show models/prod # version, author, reason, entries
|
|
59
|
+
sartre --repo ./repo log models/prod # commit history with author + reason
|
|
60
|
+
sartre --repo ./repo history models/prod # who moved which pointer, from → to, why
|
|
61
|
+
sartre --repo ./repo ls models/prod:stable # list a version's files (no download)
|
|
62
|
+
sartre --repo ./repo cat models/prod cfg.json # stream one file (verified) to stdout
|
|
63
|
+
sartre --repo ./repo checkout models/prod ./out # materialize the whole tree
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Reference grammar: `name/env` (head) · `name/env:alias` · `name/env@sha256:…` (pin).
|
|
67
|
+
Add `--json` to any command for machine-readable output. `head`/`ls` are bare for
|
|
68
|
+
scripting. Point a command at a shared repo with `--registry <dsn> --blobs <url>`,
|
|
69
|
+
`$SARTRE_REPO`, or a profile in `~/.config/sartre/config.toml`.
|
|
70
|
+
|
|
71
|
+
## Quickstart — library
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from pathlib import Path
|
|
75
|
+
from sartre import open_local, Coordinate, Alias
|
|
76
|
+
|
|
77
|
+
repo = open_local("./repo") # SQLite + local blobs; reopen to recover
|
|
78
|
+
coord = Coordinate("models", "prod")
|
|
79
|
+
|
|
80
|
+
# publish a mapping of logical path -> bytes (or Path); returns the version id
|
|
81
|
+
version = repo.publish(
|
|
82
|
+
coord,
|
|
83
|
+
{"w/model.bin": b"...weights...", "cfg.json": b"{}"},
|
|
84
|
+
actor="alice",
|
|
85
|
+
reason="initial train",
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# resolve a pointer to an immutable snapshot (manifest only — no blob bytes yet)
|
|
89
|
+
snap = repo.resolve(coord) # head by default
|
|
90
|
+
print(snap.version, [e.path for e in snap.entries])
|
|
91
|
+
|
|
92
|
+
# materialize bytes lazily, verified and content-cached
|
|
93
|
+
local_path = repo.open(snap, "cfg.json") # one file
|
|
94
|
+
repo.checkout(snap, Path("./out")) # the whole tree
|
|
95
|
+
|
|
96
|
+
# move a mutable pointer to an existing version (promote / roll back)
|
|
97
|
+
repo.point(coord, "stable", version, expected=None, actor="bob", reason="passed eval")
|
|
98
|
+
assert repo.head(coord, Alias("stable")) == version
|
|
99
|
+
|
|
100
|
+
# provenance is on the event, not the shared manifest
|
|
101
|
+
for entry in repo.list_log(coord): # who published/promoted each tip, and why
|
|
102
|
+
print(entry.version, entry.actor, entry.reason)
|
|
103
|
+
for move in repo.list_pointer_history(coord): # the pointer-move audit trail
|
|
104
|
+
print(move.name, move.from_version, "->", move.to_version, move.actor)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### A shared, cloud-backed repository
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from sartre import open_cloud
|
|
111
|
+
|
|
112
|
+
repo = open_cloud(
|
|
113
|
+
"postgresql://user:pw@host/db", # Postgres manifest plane (needs the `postgres` extra)
|
|
114
|
+
"s3://my-bucket/artifacts", # any fsspec blob URL (needs `s3`/`gcs` as appropriate)
|
|
115
|
+
cache_dir="/var/cache/sartre", # optional local read-through cache
|
|
116
|
+
)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The API is identical; only the backends differ. `AsyncRepository` wraps a
|
|
120
|
+
`Repository` with awaitable equivalents.
|
|
121
|
+
|
|
122
|
+
## What you get
|
|
123
|
+
|
|
124
|
+
- **Content-addressed & deduplicated** — a version is its manifest hash; identical
|
|
125
|
+
files are stored once and promote across environments with no copy.
|
|
126
|
+
- **Change provenance** — every commit and every pointer move records `actor` +
|
|
127
|
+
`reason`; the pointer-move history answers "who changed prod, from what, and why."
|
|
128
|
+
- **Streaming** — publish and fetch never buffer a whole blob in memory.
|
|
129
|
+
- **Safe concurrency** — pointer moves are compare-and-swap; publishes hold a
|
|
130
|
+
TTL lease so a concurrent garbage collector never reclaims in-flight blobs
|
|
131
|
+
(the GC/lease protocol is verified in TLA+).
|
|
132
|
+
- **Garbage collection** — mark-and-sweep with retention policies
|
|
133
|
+
(`keep_last_n`, `keep_within`, a blob grace period).
|
|
134
|
+
|
|
135
|
+
See [`binary-artifact-repo-design.md`](binary-artifact-repo-design.md) for the
|
|
136
|
+
full design memo.
|
|
137
|
+
|
|
138
|
+
## Development
|
|
139
|
+
|
|
140
|
+
This project uses:
|
|
141
|
+
|
|
142
|
+
- **uv** — Python environment & packaging (`uv sync`, `uv run pytest`)
|
|
143
|
+
- **jj** (colocated with git) — version control
|
|
144
|
+
- **nix** (`shell.nix` + `direnv`) — reproducible dev shell
|
|
145
|
+
- **OpenSpec** — spec-driven change workflow (`openspec/`, `/opsx:*` skills)
|
|
146
|
+
- **TLA+** — protocol model checking (`tla-*` skills, `tla-verifier` agent)
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
nix-shell # or: direnv allow
|
|
150
|
+
uv sync # create .venv and install dev tooling
|
|
151
|
+
uv run pytest # run tests
|
|
152
|
+
uv run ruff check # lint
|
|
153
|
+
uv run pyright # type-check
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Layout
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
src/sartre/ library source (registry backends, stores, repository, CLI)
|
|
160
|
+
tests/ tests (unit, property-based, differential, e2e)
|
|
161
|
+
openspec/ spec-driven change proposals & living specs
|
|
162
|
+
binary-artifact-repo-design.md design memo
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
Licensed under the [Apache License 2.0](LICENSE) — permissive, commercial-use
|
|
168
|
+
friendly, with an explicit patent grant. See [`NOTICE`](NOTICE).
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "sartre"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Sartre: Simple ARTifact REpository — a content-addressed versioned binary artifact repository (manifest plane + blob plane)."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
license-files = [
|
|
8
|
+
"LICENSE",
|
|
9
|
+
"NOTICE",
|
|
10
|
+
]
|
|
11
|
+
keywords = [
|
|
12
|
+
"artifact-repository",
|
|
13
|
+
"content-addressed",
|
|
14
|
+
"versioning",
|
|
15
|
+
"blob-store",
|
|
16
|
+
"model-registry",
|
|
17
|
+
"data-versioning",
|
|
18
|
+
"fsspec",
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 3 - Alpha",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Topic :: Software Development :: Version Control",
|
|
28
|
+
"Topic :: System :: Archiving",
|
|
29
|
+
"Topic :: Database",
|
|
30
|
+
"Typing :: Typed",
|
|
31
|
+
]
|
|
32
|
+
requires-python = ">=3.12"
|
|
33
|
+
dependencies = ["fsspec>=2024.0"]
|
|
34
|
+
|
|
35
|
+
[[project.authors]]
|
|
36
|
+
name = "Vic Putz"
|
|
37
|
+
email = "vputz@protonmail.com"
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
s3 = [
|
|
41
|
+
"boto3>=1.34",
|
|
42
|
+
"s3fs>=2024.0",
|
|
43
|
+
]
|
|
44
|
+
gcs = ["gcsfs>=2024.0"]
|
|
45
|
+
postgres = ["psycopg[binary]>=3.1"]
|
|
46
|
+
cli = ["typer>=0.12"]
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
Homepage = "https://github.com/vputz/sartre"
|
|
50
|
+
Repository = "https://github.com/vputz/sartre"
|
|
51
|
+
Issues = "https://github.com/vputz/sartre/issues"
|
|
52
|
+
|
|
53
|
+
[project.scripts]
|
|
54
|
+
sartre = "sartre.cli:main"
|
|
55
|
+
|
|
56
|
+
[build-system]
|
|
57
|
+
requires = ["uv_build>=0.11.17,<0.12.0"]
|
|
58
|
+
build-backend = "uv_build"
|
|
59
|
+
|
|
60
|
+
[dependency-groups]
|
|
61
|
+
dev = [
|
|
62
|
+
"pytest>=8.3",
|
|
63
|
+
"pytest-cov>=6.0",
|
|
64
|
+
"ruff>=0.8",
|
|
65
|
+
"pyright>=1.1.390",
|
|
66
|
+
"hypothesis>=6.100",
|
|
67
|
+
"psycopg[binary]>=3.1",
|
|
68
|
+
"moto[s3,server]>=5.0",
|
|
69
|
+
"s3fs>=2024.0",
|
|
70
|
+
"typer>=0.12",
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
[tool.pytest.ini_options]
|
|
74
|
+
addopts = "--import-mode=importlib"
|
|
75
|
+
testpaths = ["tests"]
|
|
76
|
+
|
|
77
|
+
[tool.ruff]
|
|
78
|
+
target-version = "py312"
|
|
79
|
+
line-length = 100
|
|
80
|
+
|
|
81
|
+
[tool.ruff.lint]
|
|
82
|
+
select = [
|
|
83
|
+
"E",
|
|
84
|
+
"F",
|
|
85
|
+
"I",
|
|
86
|
+
"UP",
|
|
87
|
+
"B",
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
[tool.ruff.lint.per-file-ignores]
|
|
91
|
+
"src/sartre/cli/app.py" = ["B008"]
|
|
92
|
+
|
|
93
|
+
[tool.pyright]
|
|
94
|
+
include = [
|
|
95
|
+
"src",
|
|
96
|
+
"tests",
|
|
97
|
+
]
|
|
98
|
+
pythonVersion = "3.12"
|
|
99
|
+
typeCheckingMode = "standard"
|