pipekit recipe registries
pipekit already treats a pipeline as data: it serialises to JSON, hashes to an id, and lives in a registry with tags. This page checks how far that goes today, then puts pipekit's four storage seams (model registry, cache store, training data, product stamp) on Icechunk, so code and data are versioned the same way.
Summary
None of pipekit's operators change, and pipeline_hash keeps its meaning. What changes is where pipekit persists things, and what a product records about the code that made it.
- G.Products that name their recipe. pipekit stores operators by
pipeline_hash, but no product records which recipe made it, and the hash covers configuration, not code. A small stamp (hash, registry, package versions, lockfile hash) goes into every product row. - H.A model registry on Icechunk.
registry.storewrites up to four objects one after another, so a crash can leave half an entry. AnIcechunkModelRegistrymakes each store one commit. - I.A cache store on Icechunk.
Cachealready writes to any namedStore, and pipekit leaves carrier-specific stores to its sister packages. AnIcechunkStorekeeps array results as Zarr instead of pickles, and shares them across machines. - J.Training data pinned to a snapshot.
TrainingDataset.content_hashhashes the dataset's configuration, so it cannot tell two versions of the same files apart. A dataset read from a repo folds the snapshot id into its hash.
End state. pipekit-ops stays dependency-free; pipekit-experiment gains an Icechunk registry and the recipe stamp behind an [icechunk] extra; geocloud gains a carrier-aware Icechunk store; pipekit-train datasets can name a snapshot. A model, a cache entry, a training set and a product are each one commit with an immutable id.
Where pipekit persists things today
Three layers. At the top, what makes a pipeline a recipe. In the middle, the three places pipelines run. At the bottom, the four places their results and records land. Every store at the bottom is a separate system with its own write semantics.
The pieces, and where each one lives
| Component | Package | What it does | Read in |
|---|---|---|---|
Operator.state | pipekit-ops | {module, class, config}, nested for Sequential and Graph; from_state rebuilds it. | _base/operator.py:248 |
dumps, loads, loads_sandboxed | pipekit-ops | The state as JSON and back; the sandboxed loader builds only allowlisted classes. Operators holding closures (forbid_in_yaml) refuse to load. | serial.py |
pipeline_hash | pipekit-ops | sha256(stable_json(op.state) ‖ 0x00 ‖ weights): the id the registries, Cache and run records share. | hashing.py:95 |
Cache, Store, store_scope | pipekit-ops | Memoisation keyed by input and pipeline_hash(inner) into a named store. A store is three methods over 64-hex keys; carrier-specific stores are left to sister packages. | cache.py, store.py |
LocalModelRegistry, S3ModelRegistry | pipekit-experiment | Operators and weights under their hash, with tags; load checks the content against the hash. Both share _ModelRegistryBase, which needs six storage primitives. | registry.py:87 |
JaxModelOp | pipekit-jax | Round-trips trained weights through a ModelRegistry as one blob, from JSON config alone. | model_op.py |
TrainingDataset.content_hash | pipekit-train | Defaults to a hash of the class name and config; datasets with external state are told to override it. | dataset.py:145 |
CachedDataset | pipekit-train | Writes the first epoch into a fixed-shape Zarr store, keyed on the source's content_hash, locally or through fsspec. | dataset.py:461 |
DVCDatasetVersioning | pipekit-experiment | Wraps the DVC CLI: add, pull, push, hash on files. | adapters/dvc.py |
TrainingArtifact, InferenceArtifact | pipekit-experiment | JSON records pinning a pipeline, its dataset and model hashes, backend info and the lockfile. | artifacts.py |
Five verified gaps
- 1
A registry store is several writes.
storewritesoperator.json, thenweights.bin, thenmetadata.json, then the tag file.LocalModelRegistrymakes each file atomic, not the set, andS3ModelRegistrysays it is only as atomic as its backing store. - 2
No array-aware cache store.
DirectoryStorepickles one file per key, andstore.pyleaves Zarr, COG and object-store stores to the sister packages; none exists in geotoolz yet. - 3
A dataset hash names its config, not its data. The default
content_hashcannot tell two versions of the same files apart, soTrainingArtifact.dataset_hashdoes not pin the data unless a subclass folds a version in. DVC can, but per file and through git. - 4
Products do not name their recipe. Nothing writes a
pipeline_hashnext to a product, so "which code made this map" has no lookup. - 5
The hash covers config, not code.
op.statehas no package version, so the sameMatchedFilterconfig hashes alike under two geoops releases. Versions are kept only in an artifact'sbackend_infoanddeps_lock.
The same seams, on Icechunk
Every box and line from the current diagram is still here. Blue text marks what each box gains, with its workstream letter. The new band at the bottom is the repo that the four stores now write into, each write one commit.
pipeline_hash; the model behind that hash, the data it was trained on and the cache it filled are each a snapshot too.What each workstream adds
| Symbol | Destination | Reason | Closes |
|---|---|---|---|
RecipeStamp, stamp | pipekit-experiment | Hash, registry URI, package versions and lockfile hash, written into every product row; the full InferenceArtifact stays in the registry. | G · gaps 4, 5 |
IcechunkModelRegistry | pipekit-experiment, extra [icechunk] | The six primitives of _ModelRegistryBase over one writable session, so store is one commit. Same layout and hashes as the other two. | H · gap 1 |
IcechunkStore | geocloud, extra [icechunk] | A Store that writes carriers as Zarr groups (CF spatial_ref, L2 page D) and anything else as bytes. geocloud already owns object storage, as store.py asks. | I · gap 2 |
SnapshotDataset | pipekit-train, extra [icechunk] | A TrainingDataset read at a snapshot, whose content_hash folds the snapshot id in; CachedDataset can target a repo. | J · gap 3 |
Recipes are versioned like data
The repo and the recipe registry are the same pattern on two kinds of thing.
| Concept | Data (Icechunk repo) | Recipes (pipekit registry) |
|---|---|---|
| Content | arrays and meta/ rows | op.state JSON, plus optional weights |
| Identity | snapshot id | pipeline_hash |
| Human name | tag (mf-v0.3-2026-06) | tag (mf-v0.3) |
| Store | a repo on object storage | LocalModelRegistry, S3ModelRegistry; Icechunk with H |
| Restore | open the repo at a snapshot | registry.load(hash), or loads on the JSON |
| Catalogued in | product catalog (F) | registry.list(tags=…); the same catalog if you want one search |
A product is a recipe applied to inputs
Write α = R(x) for a product α made by recipe R from inputs x. Provenance is complete when the record names all three, each by an immutable id:
inputs x derived_from links → source items product catalog, F scenes at repo@snapshot L2 page, A │ recipe R pipeline_hash → registry.load(hash) today package versions + lockfile hash G │ product α products/mf/<id> at repo@snapshot L2 page, B one product-catalog record naming x and R F + G
With all three, a product can be rebuilt and checked: load R by hash, open x at its snapshot, run, and compare with α. That is gate G1.
The one subtlety: config is not code
pipeline_hash covers op.state, the configuration. Two geoops releases with different MatchedFilter code but the same config share a hash. Changing the hash to include versions would move every id already in a registry, so keep the hash and record the versions beside it.
pipeline_hash as the recipe id. Stamp each product with the hash, the versions of the packages it imported and a hash of the lockfile; keep the full InferenceArtifact in the registry next to the recipe.# pipekit_experiment/_src/stamp.py
"""What a product records about the recipe that made it."""
import dataclasses
from importlib import metadata
import pipekit_ops
import pipekit_ops.hashing
# Shapes: P packages pinned
@dataclasses.dataclass(frozen=True)
class RecipeStamp:
"""The recipe behind a product: its id, where it lives, what ran it.
Args:
pipeline_hash: The recipe id, pipekit_ops.pipeline_hash(op).
registry_uri: The registry that holds the recipe.
versions: Package name to installed version, for the packages it uses.
lock_hash: sha256 of the lockfile the run used.
"""
pipeline_hash: str
registry_uri: str
versions: dict[str, str]
lock_hash: str
# proposed (G)
def stamp(
op: pipekit_ops.Operator,
*,
registry_uri: str,
packages: tuple[str, ...],
lockfile: str,
) -> RecipeStamp:
"""Build the stamp a transaction writes into every product row."""
# h = sha256(stable_json(op.state) ‖ 0x00)
# today (pipekit-ops)
recipe_hash = pipekit_ops.pipeline_hash(op) # → 64 hex
# not pinned (importlib)
versions = {name: metadata.version(name) for name in packages} # → P
# h_lock = sha256(lockfile)
# today (pipekit-ops)
lock_hash = pipekit_ops.hashing.sha256_hex(lockfile) # → 64 hex
return RecipeStamp(recipe_hash, registry_uri, versions, lock_hash)
In the product catalog the stamp becomes a few properties beside the lineage links: pipekit:pipeline_hash, pipekit:registry, pipekit:lock_hash, and processing:software for the versions. In a PostGIS table, pipeline_hash earns its own indexed column, so "everything this recipe made" is one query.
A model registry where a store is one commit
_ModelRegistryBase keeps all the user-facing logic (hashing, verify-on-load, tag merging) and asks a backend for six primitives: _exists, _read_text, _write_text, _read_bytes, _write_bytes, _children, plus _where for messages. An Icechunk backend implements those against one writable session and wraps store and tag in a commit, so a crash leaves no half entry and every model version is a snapshot.
models.icechunk/ ├── <hash>/operator.json the state, as the other backends write it ├── <hash>/weights.bin optional blob (JaxModelOp.serialize_weights) ├── <hash>/metadata.json tags merged across stores └── _tags/<name> the hash a name points at
# pipekit_experiment/_src/icechunk_registry.py
"""A model registry whose every store and tag is one Icechunk commit."""
import contextlib
from collections.abc import Iterator
import icechunk
from pipekit_experiment.registry import _ModelRegistryBase
# Shapes: B bytes of weights
class IcechunkModelRegistry(_ModelRegistryBase):
"""Operators and weights in an Icechunk repo, one commit per store.
Args:
repo: The repository that holds the models.
branch: The branch stores commit to.
"""
def __init__(self, repo: icechunk.Repository, *, branch: str = "main") -> None:
self.repo = repo
self.branch = branch
self._session = None
@contextlib.contextmanager
def _transaction(self, message: str) -> Iterator[None]:
# not pinned (icechunk)
self._session = self.repo.writable_session(self.branch)
try:
yield
# not pinned (icechunk)
self._session.commit(message)
finally:
self._session = None
def store(self, model_op, *, name=None, tags=None, weights=None) -> str:
# proposed (H)
with self._transaction(f"store {name or 'model'}"):
# today (pipekit-experiment)
return super().store(model_op, name=name, tags=tags, weights=weights)
def _write_bytes(self, data: bytes, *parts: str) -> None:
# proposed (H): one uint8 array per object, in the open session
write_object(self._session.store, "/".join(parts), data) # → (B,)
A cache that is shared, typed and versioned
Cache(op, store="scenes") names a store, and store_scope binds the name to a real store around the call, so where results go is a deployment choice outside the pipeline's config and its hash. An Icechunk store fits that seam without touching pipekit-ops, which stays free of third-party dependencies.
# geocloud/_src/icechunk_store.py
"""A pipekit Store in an Icechunk repo: carriers as Zarr, the rest as bytes."""
from typing import Any
import icechunk
# Shapes: K keys written before a commit
class IcechunkStore:
"""Cache entries under cache/<key>/, committed in batches.
Args:
repo: The repository that holds the cache.
branch: The branch entries commit to.
every: Commit after this many saves; the rest commit on close.
"""
def __init__(
self,
repo: icechunk.Repository,
*,
branch: str,
every: int = 64,
) -> None:
...
def __contains__(self, key: str) -> bool: ...
def load(self, key: str) -> Any: ...
def save(self, key: str, value: Any) -> None:
# proposed (I): a GeoArray becomes a Zarr group with CF spatial_ref
...
def close(self) -> str: ...
# a pipeline, unchanged, with its cache bound to a repo
import geocloud.icechunk
import pipekit_ops
# Shapes: S scenes; C bands; H × W pixels
# proposed (I)
scene_cache = geocloud.icechunk.IcechunkStore(repo, branch="cache")
# today (pipekit-ops)
cached_filter = pipekit_ops.Cache(matched_filter, store="scenes")
# today (pipekit-ops)
with pipekit_ops.store_scope(scenes=scene_cache):
for scene in scenes: # (S,)
# α̂ = tᵀ Σ⁻¹ (y − μ) / (tᵀ Σ⁻¹ t)
enhancement = cached_filter(scene) # → (1, H, W)
# proposed (I)
cache_snapshot = scene_cache.close() # → id
Two things to keep in mind. A commit per save would be slow, so the store batches commits and closes with one. And a byte entry is still a pickle: load cache entries only from repos you trust, as with DirectoryStore today.
Training data pinned to a snapshot
TrainingDataset.content_hash is what CachedDataset keys on and what TrainingArtifact.dataset_hash records. Its docstring already asks datasets with external state to fold that state in; a dataset read from a repo folds in the snapshot id, so the hash changes when the data does.
# pipekit_train/_src/snapshot_dataset.py
"""A TrainingDataset read from an Icechunk repo at one snapshot."""
import pipekit_train
import pipekit_train.dataset
class SnapshotDataset(pipekit_train.TrainingDataset):
"""Samples read from repo@snapshot; the snapshot is part of its identity.
Args:
uri: Where the repository lives.
snapshot: The snapshot every sample is read from.
"""
def content_hash(self) -> str:
# h = sha256(type ‖ config ‖ snapshot)
config = {**self.get_config(), "snapshot": self.snapshot}
# today (pipekit-train)
return pipekit_train.dataset.hash_config(type(self).__qualname__, config)
SnapshotDataset; DVC stays for the files that are not arrays (label exports, configs, notebooks).Testing gates
Each workstream merges only when its gate passes.
| Gate | Workstream | Passes when |
|---|---|---|
| G1 Reproduce | G | Loading the recipe by pipeline_hash and the inputs at their snapshot, under the stamped lockfile, and running again gives arrays bit-identical to the product. |
| G2 Stable id | G | pipeline_hash(loads(dumps(op))) == pipeline_hash(op) for every operator in the recipe, and every product row carries a hash that registry.load resolves. |
| H1 Parity | H | The registry test suite passes unchanged on all three backends, and the same operator stores under the same hash on each. |
| H2 Atomic store | H | A store that raises after operator.json leaves the branch at its old snapshot, and load of the hash raises KeyError. |
| I1 Cache parity | I | Over one run, hits, misses and outputs are identical with DirectoryStore and IcechunkStore; a GeoArray read back has an equal Grid. |
| I2 Restart | I | A new process bound to the same repo and branch hits every entry the first process saved. |
| J1 Pinned data | J | content_hash changes when the snapshot or the config changes, and only then. |
Sequencing and risks
The stamp first, since it needs no new dependency and closes the provenance loop the product catalog opens. Then the registry, the smallest change with the clearest win.
G recipe stamp
│
◆ G1 · G2
│
H Icechunk model registry
│
◆ H1 · H2
│
J snapshot datasets ┃ I Icechunk cache store (parallel)
│
◆ J1 · I1 · I2
- !
Overriding
storeleans on a private base._ModelRegistryBaseis underscored. Fallback: give it a public hook, a_transactioncontext that defaults to doing nothing, so each backend opts in. - !
Commit cost. A commit per cache save or per small model is slow on object storage. Fallback: batch commits in the store, and keep
DirectoryStorefor hot local caches. - !
Two kinds of tag. Registry tags (
_tags/<name>) move freely; Icechunk tags are meant to be stable. Fallback: registry tags stay data inside the repo, and Icechunk tags mark releases only. - !
Pickles in a shared repo. A shared cache spreads pickles further than a local directory. Fallback: carriers always go as Zarr, and byte entries load only from repos on an allowlist.
Sources
- pipekit at
9e86a56:pipekit_ops/serial.py,hashing.py,cache.py,store.py;pipekit_experiment/registry.py,artifacts.py,adapters/dvc.py;pipekit_train/dataset.py;pipekit_jax/model_op.py - geotoolz at
640670c:geoops/matched_filter/_src/operators.py(MatchedFilter.get_config) - Level 2 collections in GeoStack and GeoStack product catalog, the companion pages