This release is a pre-release and may not be stable for production use.
sleap-roots-contracts
Shared result + provenance contract for the sleap-roots ↔ Bloom pipeline.
This is a small, dependency-light library — code-agnostic toward Bloom (no Bloom import, no
DB/network/filesystem I/O) — that defines the shape of a per-scan pipeline result and its
provenance (Pydantic v2 models), emits a versioned JSON Schema artifact, and ships a
trait-definitions registry. The Python producers (sleap-roots-predict, sleap-roots-traits)
import it; Bloom consumes the emitted schema.
It also defines the analysis-input contract — the canonical shape of the wide trait
table that crosses the sleap-roots-analyze ↔ Bloom boundary.
validate_analysis_input(df, *, strict=False) structurally validates that table against
fixed canonical role names (genotype + optional sample_id / replicate /
image_path) plus an open set of opaque numeric trait columns, returning a structured
ValidationResult. It operates on a pandas DataFrame, so pandas is an optional install
extra — pip install sleap-roots-contracts[pandas] — while the runtime core stays
pydantic + pyyaml. Canonical example tables ship in the package
(sleap_roots_contracts.examples.load_analysis_input_example(...)) so consumers can load a
validating frame straight from the released wheel.
It also defines the model-selection contract — ModelCard, the Python-side shape shared
by sleap-roots-training (which writes a production model's selection metadata as wandb
artifact metadata at promotion) and sleap-roots-predict (which reads cards to choose a model
per root type and calls to_model_ref(runtime_sleap_nn_version)). Unlike the other two, it is
a producer↔producer contract that never crosses the Bloom boundary, so it is not emitted to
the JSON Schema.
Since 0.1.0a4 it also ships the param-resolution oracle —
resolve_params(metadata, overrides=None) -> ResolvedParams maps a single Bloom
cyl_scans_extended scan-metadata row to the {species, mode, age} params that select a
ModelCard. It is a pure producer-side function (not emitted to the JSON Schema), and it is
the single source of truth for that mapping: its resolved values feed param_hash →
idempotency_key, so a second copy in a consumer would silently break first-writer-wins
idempotency. sleap-roots-predict and bloomctl both import it. It reads Bloom's column names
(species_name, plant_age_days) as dict keys — a deliberate, documented soft coupling,
hoisted into the module constants SPECIES_NAME_FIELD / PLANT_AGE_DAYS_FIELD.
It is sub-project #1 of the sleap-roots ↔ Bloom integration program. Design and plan:
docs/01-contract-library-design.md and docs/02-contract-library-plan.md.
Develop
uv sync
uv run pytest -v
uv run black --check src tests && uv run ruff check src tests
Key ideas
- Pydantic is canonical;
schema/*.jsonis generated and drift-guarded in CI. - Trait values are long-format rows (no jsonb); provenance is a jsonb blob on the source.
- Hashes (
param_hash,idempotency_key) are producer-side only; Bloom treats them as opaque strings. - Distributed via PyPI (no Docker image — this is a library).
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sleap_roots_contracts-0.1.0a4.tar.gz.
File metadata
- Download URL: sleap_roots_contracts-0.1.0a4.tar.gz
- Upload date:
- Size: 22.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95074adc9ec97875fa17b8bffaaa7f78afc46d32b3816d6100bafd6df963793c
|
|
| MD5 |
23d213bdb82e2ab9b885c1c288d148bd
|
|
| BLAKE2b-256 |
5df67ca8cb8f5fac7b1e95e45d0e8edccee7d1f1308a1511981bd5db2ebc70d4
|
File details
Details for the file sleap_roots_contracts-0.1.0a4-py3-none-any.whl.
File metadata
- Download URL: sleap_roots_contracts-0.1.0a4-py3-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cb2edcc5485e4e4faabaa8a72947377ac1a6579acd7360fa0cd709af7d8c5b8
|
|
| MD5 |
7dfa132528fd5e2e2628c4017de7b2b3
|
|
| BLAKE2b-256 |
b531176b8ab34f1efb7f1f51f97ca1a9458719741ae4d92c28e72bdcaed08c3d
|