Skip to main content

plystore

One storage interface for what ply runs write: records (JSON documents, or text) and append-only logs. A writer (plybench, plyagents, plybench_analysis, plyservice) gets a Store and never knows where its data goes; which backend holds what is configuration only.

  • MemoryStore: everything in memory, for tests and for runs that leave nothing behind.
  • FileStore: each record a file under a root folder, as plydata holds them today (same bytes, same layout).
  • RoutedStore: key prefixes routed to backends (plots/ to files, the rest elsewhere), with also_read stores that hold what was written before a switch.
  • PostgresStore (extra postgres): each record in typed tables, one schema per repository.

The client (plystore) has no dependencies. The PostgreSQL backend comes with plystore[postgres] (SQLAlchemy, psycopg, Alembic) and is loaded through the plystore.backends entry point only when a configuration names it.

plybench does not depend on plystore: it keeps its results through its own small store protocol, as files by default. With PLYBENCH_STORE=plystore it opens this package's configured store instead (open_store, through the plybench.stores entry point); plyagents and plybench_analysis write through plybench's store, so the same variable covers them.

Keys

A key names a record like a relative path, e.g. results/benchmarks/ttt_10/a_b/game_1.json. Its suffix says what it holds: .json a JSON value, .jsonl a log of JSON records (append, read_log), anything else text. Parts may not be empty, start with ., or end in .tmp or .lock (names the backends keep for themselves).

The interface

Call Does
put(key, value, replace=False) write a record; write-once unless replace (DocumentExists)
put_many({key: value}) several new records, all or none
get(key) the record, or None
get_many(keys) the records of those keys that exist, in one call
exists(key), keys(prefix) whether it is there; every key under a prefix, by whole parts, sorted
append(key, record), read_log(key) one record at the end of a log; the records in order
append_many(key, records) several records at the end of a log, all or none, in one call
delete(prefix) every record under a non-empty prefix (an admin action)

What PostgreSQL cannot hold (NaN, infinities, the NUL character, lone surrogates) is refused by every backend, so a run finds out at once, not after a switch.

Formats: records in typed tables

plystore follows the formats of the repositories that write; the repositories know nothing of it. formats/ describes each kind of record (a plybench game, matchup, training run, learner call list and LLM block log; a plyagents learner state and update; a plybench_analysis annotation, verdict, decision, judge response and failure, codebook; an experiment file) by its key pattern and a tree of nodes:

  • Column: one field into a typed column (str, int, float, bool, json, lists of str or int; shared for long texts that repeat, kept once in texts);
  • Flatten: the fields of a nested object into columns of the same row (ending.result → end_result);
  • Child: a list of objects, or a dict of objects one or more levels deep, into rows of another table;
  • Choice: the first of several shapes that takes the value whole (a memory of texts or a table of values).

A value goes into a column only if it has exactly the column's type; anything else (a null, another type, a field no node names) stays in the row's extra (jsonb). So every record rebuilds to itself, types included, and nothing is refused. A record no format matches is kept whole (unmapped). Tables are generated from the formats (postgres/schema.py), and so are the migrations.

plystore-check <data folder> splits and rebuilds every record of a folder without a database and reports what did not rebuild, what no store would take, and which fields have values outside the typed columns. ply's release checks it over plydata for plybench, plyagents and plybench_analysis (the plystore contracts in plytools).

PostgreSQL

One database, one schema per repository that ran the work (plybench, plyagents, plybench_analysis); every schema has every table, so one repository's data is dumped or dropped as a whole. Training runs from the plyagents checkout, so its plybench records are in the plyagents schema.

  • records: one row per key (its format and time); every root row references it ON DELETE CASCADE, and every child row its parent, so delete(prefix) removes everything under the prefix.
  • A format's root table: key, folder (records link by folder: a game's matchup is the metadata.json in its folder), saved, the columns, extra. Formats that keep history (codebooks, experiment files) mark a replaced row replaced instead of deleting it.
  • A child table: parent_id, position, part (when several nodes share it), its dict key columns.
  • A write is one transaction: a record with all its rows, or a put_many with all its records.

A writer refuses a schema whose migration is not the one its formats were made for. Administration (plystore-admin, URL from --url or PLYSTORE_DATABASE_URL):

  • migrate --schema plybench plyagents plybench_analysis: create and upgrade the schemas;
  • revision --message "...": generate the next migration after a format changed (in a scratch schema, rolled back);
  • roles --schema ...: group roles plystore_<schema>_write (rows of that schema only) and plystore_read; login roles are granted them by hand;
  • delete --schema plybench --prefix results/benchmarks/ttt [--yes]: list, then delete an experiment.

Locally: make up starts Postgres on 127.0.0.1:55432 (docker/compose.yml); make down stops it and keeps the volume.

Configuration

open_store(root) reads the file PLYSTORE_CONFIG names; without one every key is a file under root, as today.

[postgres]
schema = "plyagents"
url_env = "PLYSTORE_DATABASE_URL"

[[route]]
prefix = ""
store = "postgres"
also_read = ["files"]

[[route]]
prefix = "plots"
store = "files"

Commands

  • plystore-check <data folder>: read only; the round trip of every record through its format.
  • plystore-scan <data folder>: read only; what an import would move (by kind and folder), the files it skips, and the records no store would take.
  • plystore-copy <data folder> <config> --target-root <root>: copy every record into the configured store and read it back; never overwrites; a key with other content there is reported as a conflict; safe to run again.

Releases

make release VERSION=X.Y.Z (or ply's make release REPO=plystore VERSION=X.Y.Z) tags a GitHub Release; its workflow publishes to PyPI by trusted publishing (.github/workflows/publish.yml). Backups: scripts/backup.sh (one dump per schema), scripts/restore.sh and scripts/compare.sh; make backup-check dumps, restores into a new database, and compares every table.

Development

uv sync
make test           # without Postgres: the Postgres tests are skipped
make up && make test-postgres
make check-data DATA=../plydata/plybench
make demo           # files and Postgres side by side on one plydata folder (DEMO_ARGS=--keep to look around)
make lint

Metadata

Release files for plystore 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for plystore 0.1.0
File Size Uploaded Provenance Actions
plystore-0.1.0.tar.gz 84.9 kB With provenance Details for plystore-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for plystore 0.1.0
File Interpreter ABI Platform Actions
plystore-0.1.0-py3-none-any.whl Python 3 none any Details for plystore-0.1.0-py3-none-any.whl

Total release size: 131.3 kB

Release files / plystore-0.1.0.tar.gz

Download URL plystore-0.1.0.tar.gz
Size 84.9 kB
Tags Source
SHA-256 checksum
How to use checksums
643747b22b13d658d327fbb0007ad5cbee5577c23e83002308af0122c9ed38dc
BLAKE2b-256 checksum
How to use checksums
0f0d8aabdcec414da91d9ca38414cd716bd87ed874aca7b3776ac19b12a2b6e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / plystore-0.1.0-py3-none-any.whl

Download URL plystore-0.1.0-py3-none-any.whl
Size 46.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b5f846558270107e4fd3bcee0c3a963e59167afd81e2eba81398b743889ed300
BLAKE2b-256 checksum
How to use checksums
4ba4180ca5f4d3e2d2c6c36cc1c86d85c20036f80dd31fd0757be2350cba05d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for plystore 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for plystore-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page