Plättli is an opinionated dataformat for logging a series of metrics
Project description
Plättli
Minimal streaming writer for the Plättli metric format.
The format is very simple, and allows for efficient appending, reading and slicing.
It consists of one file per metric, which is just a raw homogeneous array,
plus a metrics manifest (plattli.json) that describes dtype and indices,
and a config.json with info about the run.
Install
pip install plattli
Requires Python 3.11+ (tested on 3.11-3.14).
CLI
A tool to convert jsonl (a common adhoc format) to plattli is provided, see
jsonl2plattli --help
By default it writes in-place as <run_dir>/metrics.plattli.
With --outdir, it writes <run_name>.plattli into the output tree.
API
from plattli import PlattliWriter
w = PlattliWriter("/experiments/123456", config={"lr": 3e-4, "depth": 32})
w.write(loss=1.2) # First write creates new metric, auto-guesses dtype (float32 here)
w.write(note="ok") # strings work too. Writes are non-blocking.
w.end_step() # Increments step by one. Makes sure previous writes are flushed.
w.write(loss=1.3) # Next write appends
# Not every metric needs to be written every step.
w.write(accuracy=0.73)
w.end_step()
# Data is written ASAP, so almost nothing is lost on crash/preemption.
del w
# If we specify a start step and destination exists,
# existing metrics will be truncated to that and we continue from there.
w = PlattliWriter("/experiments/123456", step=1, config={"lr": 3e-4, "depth": 32})
w.write(loss=1.1)
# You can also write json, btw.
w.write(prediction={"qid": "42096", "answer": "Yes"})
# When finishing cleanly, we can hindsight-optimize the data for faster consumption.
# This writes /experiments/123456/metrics.plattli and removes /experiments/123456/plattli.
w.finish()
Note: this library is meant to be called from a single thread.
write uses threads internally to be non-blocking as it's meant to be used on the critical path,
but calling end_step from a different thread would lead to silently inconsistent data.
PlattliWriter(outdir, step=0, write_threads=16, config="config.json")
- Prepares the writer to write under
outdir/plattli, creating the dir and writing the config there. - If
outdir/plattli/plattli.jsonalready exists, all metric files are truncated tostepso you can resume a run and overwrite later data safely. write_threads=0disables background writes.configis a dict written toconfig.json, or a string path (resolved relative tooutdir) to symlinkconfig.jsonto (default:"config.json").- If the target path does not exist, an empty config is written; pass
Noneto force an empty config.
write(**metrics)
- Appends each metric at the current step.
- Auto-dtype rules:
- array-like scalars -> use their dtype if supported
- bool ->
json - float ->
f32 - int ->
i64 - everything else ->
json
- Force a dtype by casting the value (for example:
write(dim=np.float32(128))). - Only scalar values are supported (including 0-d array-likes).
- Only standard dtypes are supported for now: no bf16, nvfp4, fp8; no complex/composite.
end_step()
- Increments step counter by one.
- Waits for all previous step writes to finish and checks for errors.
- This could also be made non-blocking with a bit more effort, but let's first keep things simple.
set_config(config)
- Replaces
config.jsonwith the provided json-dumpable config.
finish(optimize=True, zip=True)
- Flushes writes and updates
plattli.json. - If
optimize=True:- Tightens numeric dtypes (floats ->
f32, ints -> smallest fitting int/uint). - Converts monotonically spaced indices into
{start, stop, step}and removes the.indicesfile. - Writes
run_rows(max rows across metrics) into the manifest.
- Tightens numeric dtypes (floats ->
- If
zip=True, zips the run folder to<outdir>/metrics.plattli(stored, not compressed). - When zipping,
outdir/plattliis removed after the zip is written.
Data format
Each run directory contains a plattli/ folder, while the .plattli archive contains the same files at the top level:
run_dir/
plattli/
config.json
plattli.json
<metric>.indices
<metric>.<dtype> # or <metric>.json
metrics.plattli
Manifest (plattli.json)
JSON object keyed by metric name, plus metadata keys like run_rows and when_exported:
{
"loss": {"indices": "indices", "dtype": "f32"},
"note": {"indices": "indices", "dtype": "json"},
"run_rows": 1234,
"when_exported": "2026-01-03T12:34:56Z"
}
Fields:
indices:"indices"or{start, stop, step}.dtype: one off{32,64},{i,u}{8,16,32,64}, orjson.run_rows: optional max rows across all metrics (written onfinishonly).when_exported: timestamp updated on manifest writes.
Indices (<metric>.indices)
Raw little-endian uint32 array. Each entry is the step value for that metric
write. If optimize=True during finish(), the file may be removed and
replaced by {start, stop, step} in the manifest.
Config (config.json)
Arbitrary JSON object (dict), written when a config is provided.
Values (<metric>.<dtype>)
Raw little-endian typed array. One scalar is appended per write call.
JSON values (<metric>.json)
JSON array of values, still valid JSON, but written with newlines:
[
{"event":"start"},
{"event":"done"}
]
Metric names and subfolders
Metric names are used as file paths. A slash creates subfolders:
detail/thing0 -> detail/thing0.f32.
Project details
Release history Release notifications | RSS feed
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 plattli-0.3.0.tar.gz.
File metadata
- Download URL: plattli-0.3.0.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca08a430439e20a6d8d5ffe53fe818e309c1e7ea4c9b374f1434e6127d1be9db
|
|
| MD5 |
bbedea6c37925a35b984436eca6e42a8
|
|
| BLAKE2b-256 |
0c82292eef5500c612ef8bfa4744175cc54ffe9fd5b1b26dd535bf419712e802
|
Provenance
The following attestation bundles were made for plattli-0.3.0.tar.gz:
Publisher:
publish.yml on lucasb-eyer/plattli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plattli-0.3.0.tar.gz -
Subject digest:
ca08a430439e20a6d8d5ffe53fe818e309c1e7ea4c9b374f1434e6127d1be9db - Sigstore transparency entry: 832150469
- Sigstore integration time:
-
Permalink:
lucasb-eyer/plattli@d9758eba4a9cc0469cc3ee67e089297c2b754148 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/lucasb-eyer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d9758eba4a9cc0469cc3ee67e089297c2b754148 -
Trigger Event:
push
-
Statement type:
File details
Details for the file plattli-0.3.0-py3-none-any.whl.
File metadata
- Download URL: plattli-0.3.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
344e483eecce89d7d6459acf1c7795f6a87a4b6d75b97adb7880ef06e607be7c
|
|
| MD5 |
02b0f7a296090246adcd56af676f11f2
|
|
| BLAKE2b-256 |
fcddfe5113acf7b6ecb962d0d3e5723905e0d3bb97b72ffdd6138ff73f1a4ee3
|
Provenance
The following attestation bundles were made for plattli-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on lucasb-eyer/plattli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plattli-0.3.0-py3-none-any.whl -
Subject digest:
344e483eecce89d7d6459acf1c7795f6a87a4b6d75b97adb7880ef06e607be7c - Sigstore transparency entry: 832150477
- Sigstore integration time:
-
Permalink:
lucasb-eyer/plattli@d9758eba4a9cc0469cc3ee67e089297c2b754148 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/lucasb-eyer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d9758eba4a9cc0469cc3ee67e089297c2b754148 -
Trigger Event:
push
-
Statement type: