Design note · recipes and registries

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.

pipekit 9e86a56 geotoolz 640670c geostack 343d60e

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.

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.

Current state · verified in code

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.

DEFINE RUN PERSIST A recipe is data op.state = {module, class, config} · dumps · loads · loads_sandboxed pipeline_hash(op, weights) = sha256(stable_json(state) ‖ 0x00 ‖ weights) 5 Cache(inner, store) key = sha256(input ‖ pipeline_hash) hits · misses TrainingLoop dataset.content_hash() hash of type and config Inference a geoops pipeline → products (L2 page) 4 save · load reads store load record Cache stores MemoryStore DirectoryStore one pickle per key 2 Datasets CachedDataset → Zarr DVCDatasetVersioning files, by path 3 Model registry Local · S3 (fsspec) operator.json · weights.bin metadata.json · _tags/ 1 Run records TrainingArtifact InferenceArtifact JSON files
Each store is right on its own, but they share no identity and no transaction: a model, the data it was trained on, the cache it filled and the products it made are found by four different kinds of path. Amber numbers mark the gaps below.

The pieces, and where each one lives

ComponentPackageWhat it doesRead in
Operator.statepipekit-ops{module, class, config}, nested for Sequential and Graph; from_state rebuilds it._base/operator.py:248
dumps, loads, loads_sandboxedpipekit-opsThe state as JSON and back; the sandboxed loader builds only allowlisted classes. Operators holding closures (forbid_in_yaml) refuse to load.serial.py
pipeline_hashpipekit-opssha256(stable_json(op.state) ‖ 0x00 ‖ weights): the id the registries, Cache and run records share.hashing.py:95
Cache, Store, store_scopepipekit-opsMemoisation 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, S3ModelRegistrypipekit-experimentOperators 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
JaxModelOppipekit-jaxRound-trips trained weights through a ModelRegistry as one blob, from JSON config alone.model_op.py
TrainingDataset.content_hashpipekit-trainDefaults to a hash of the class name and config; datasets with external state are told to override it.dataset.py:145
CachedDatasetpipekit-trainWrites the first epoch into a fixed-shape Zarr store, keyed on the source's content_hash, locally or through fsspec.dataset.py:461
DVCDatasetVersioningpipekit-experimentWraps the DVC CLI: add, pull, push, hash on files.adapters/dvc.py
TrainingArtifact, InferenceArtifactpipekit-experimentJSON records pinning a pipeline, its dataset and model hashes, backend info and the lockfile.artifacts.py

Five verified gaps

Revised target

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.

DEFINE RUN PERSIST REPO A recipe is data op.state = {module, class, config} · dumps · loads · loads_sandboxed pipeline_hash(op, weights) = sha256(stable_json(state) ‖ 0x00 ‖ weights) + RecipeStamp: hash · registry · versions · lockfile hash G Cache(inner, store) key = sha256(input ‖ pipeline_hash) hits · misses + store="scenes" → repo I TrainingLoop dataset.content_hash() hash of type and config + and the snapshot id J Inference a geoops pipeline → products (L2 page) + stamps its recipe on each G save · load reads store load record Cache stores MemoryStore DirectoryStore one pickle per key + IcechunkStore I Datasets CachedDataset → Zarr DVCDatasetVersioning files, by path + read at a snapshot J Model registry Local · S3 (fsspec) operator.json · weights.bin metadata.json · _tags/ + IcechunkModelRegistry H Run records TrainingArtifact InferenceArtifact JSON files + next to their model H each write one commit Icechunk repos cache entries · models · training sets · run records, each named by a snapshot id
Data and code now share one kind of identity. A product record (product catalog, F) names its inputs by snapshot and its recipe by pipeline_hash; the model behind that hash, the data it was trained on and the cache it filled are each a snapshot too.
pipekit geotoolz 1verified gap Hworkstream

What each workstream adds

SymbolDestinationReasonCloses
RecipeStamp, stamppipekit-experimentHash, registry URI, package versions and lockfile hash, written into every product row; the full InferenceArtifact stays in the registry.G · gaps 4, 5
IcechunkModelRegistrypipekit-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
IcechunkStoregeocloud, 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
SnapshotDatasetpipekit-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
G · recipes

Recipes are versioned like data

The repo and the recipe registry are the same pattern on two kinds of thing.

ConceptData (Icechunk repo)Recipes (pipekit registry)
Contentarrays and meta/ rowsop.state JSON, plus optional weights
Identitysnapshot idpipeline_hash
Human nametag (mf-v0.3-2026-06)tag (mf-v0.3)
Storea repo on object storageLocalModelRegistry, S3ModelRegistry; Icechunk with H
Restoreopen the repo at a snapshotregistry.load(hash), or loads on the JSON
Catalogued inproduct 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.

RecommendedKeep 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.
AlternativeFold versions into the id, a recipe-and-environment hash. One id says everything, but every patch release mints a new id for an unchanged recipe, and old registry entries stop matching.
# 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.

H · model registry

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,)
I · cache store

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.

J · training data

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)
RecommendedIcechunk snapshots for array training data, read through SnapshotDataset; DVC stays for the files that are not arrays (label exports, configs, notebooks).
AlternativeDVC for everything. One tool, but it versions whole files through git, so a new month of scenes re-hashes files instead of adding chunks.

Testing gates

Each workstream merges only when its gate passes.

GateWorkstreamPasses when
G1 ReproduceGLoading 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 idGpipeline_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 ParityHThe registry test suite passes unchanged on all three backends, and the same operator stores under the same hash on each.
H2 Atomic storeHA store that raises after operator.json leaves the branch at its old snapshot, and load of the hash raises KeyError.
I1 Cache parityIOver one run, hits, misses and outputs are identical with DirectoryStore and IcechunkStore; a GeoArray read back has an equal Grid.
I2 RestartIA new process bound to the same repo and branch hits every entry the first process saved.
J1 Pinned dataJcontent_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

Sources