datadouble 0.0.3__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.
- datadouble/__init__.py +10 -0
- datadouble/announce.py +380 -0
- datadouble/anonymize.py +165 -0
- datadouble/api.py +1159 -0
- datadouble/boundary.py +47 -0
- datadouble/catalog.py +677 -0
- datadouble/channels.py +62 -0
- datadouble/ci.py +1357 -0
- datadouble/cli.py +940 -0
- datadouble/closure.py +712 -0
- datadouble/engine.py +435 -0
- datadouble/files.py +78 -0
- datadouble/images.py +265 -0
- datadouble/jailer.py +403 -0
- datadouble/names.py +114 -0
- datadouble/notify.py +262 -0
- datadouble/objects.py +195 -0
- datadouble/outcome.py +27 -0
- datadouble/pii.py +109 -0
- datadouble/planner.py +1492 -0
- datadouble/programs.py +68 -0
- datadouble/promote.py +190 -0
- datadouble/prune.py +258 -0
- datadouble/py.typed +0 -0
- datadouble/redaction.py +131 -0
- datadouble/registry.py +128 -0
- datadouble/replicate.py +562 -0
- datadouble/resolve.py +201 -0
- datadouble/run.py +1075 -0
- datadouble/runtime.py +154 -0
- datadouble/secrets.py +57 -0
- datadouble/settings.py +81 -0
- datadouble/signing.py +98 -0
- datadouble/spec.py +1590 -0
- datadouble/staging.py +346 -0
- datadouble/storage.py +222 -0
- datadouble/strict.py +498 -0
- datadouble/subset.py +406 -0
- datadouble/verify.py +171 -0
- datadouble/versions.py +25 -0
- datadouble-0.0.3.dist-info/METADATA +36 -0
- datadouble-0.0.3.dist-info/RECORD +45 -0
- datadouble-0.0.3.dist-info/WHEEL +4 -0
- datadouble-0.0.3.dist-info/entry_points.txt +12 -0
- datadouble-0.0.3.dist-info/licenses/LICENSE +21 -0
datadouble/channels.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Copyright (c) 2026- Tight Line LLC
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""Channels: named, movable pointers to an image's generations.
|
|
5
|
+
|
|
6
|
+
A channel lives in a store next to the images it points at, as
|
|
7
|
+
``<spec>/<group>/<engine>-<version>/channels/<name>.json``. ``promote``
|
|
8
|
+
advances one in the export store, ``fetch`` one in staging, and ``activate``
|
|
9
|
+
moves one back. Each channel keeps the generations it pointed at before, newest
|
|
10
|
+
first, so a rollback knows where it came from.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import datetime as dt
|
|
14
|
+
from collections.abc import Callable
|
|
15
|
+
|
|
16
|
+
from pydantic import AwareDatetime, BaseModel, ConfigDict
|
|
17
|
+
|
|
18
|
+
from datadouble.names import Generation, check_name
|
|
19
|
+
from datadouble.storage import Store
|
|
20
|
+
|
|
21
|
+
_HISTORY = 20
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Channel(BaseModel):
|
|
25
|
+
"""Where a channel points, and where it pointed before."""
|
|
26
|
+
|
|
27
|
+
model_config = ConfigDict(strict=True, frozen=True, extra="forbid")
|
|
28
|
+
|
|
29
|
+
name: str
|
|
30
|
+
generation: Generation
|
|
31
|
+
updated_at: AwareDatetime
|
|
32
|
+
previous: tuple[Generation, ...] = ()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def channel_key(prefix: str, name: str) -> str:
|
|
36
|
+
"""The store key of a channel under an image line's prefix."""
|
|
37
|
+
return f"{prefix}/channels/{check_name('channel', name)}.json"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def read_channel(store: Store, prefix: str, name: str) -> Channel | None:
|
|
41
|
+
"""A channel, or None if it has never been set."""
|
|
42
|
+
data = store.get_bytes(channel_key(prefix, name))
|
|
43
|
+
return None if data is None else Channel.model_validate_json(data)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def point_channel(
|
|
47
|
+
store: Store,
|
|
48
|
+
prefix: str,
|
|
49
|
+
name: str,
|
|
50
|
+
generation: Generation,
|
|
51
|
+
clock: Callable[[], dt.datetime] = lambda: dt.datetime.now(tz=dt.UTC),
|
|
52
|
+
) -> Channel:
|
|
53
|
+
"""Point a channel at ``generation``, remembering where it pointed before."""
|
|
54
|
+
current = read_channel(store, prefix, name)
|
|
55
|
+
previous: tuple[Generation, ...] = ()
|
|
56
|
+
if current is not None and current.generation != generation:
|
|
57
|
+
previous = (current.generation, *current.previous)[:_HISTORY]
|
|
58
|
+
elif current is not None:
|
|
59
|
+
previous = current.previous
|
|
60
|
+
channel = Channel(name=name, generation=generation, updated_at=clock(), previous=previous)
|
|
61
|
+
store.put_bytes(channel_key(prefix, name), channel.model_dump_json(indent=2).encode())
|
|
62
|
+
return channel
|