Skip to content

Python (tet-py) ​

tet-py is the official Python package for Tetration. Install from PyPI, import tet, and use the same query engine and .tet layout as the Rust crate and tet CLI.

Current line

tet-py 0.8.3 pins crates.io tetration 0.8.3. pip install tet-py.

Naming ​

RoleValue
PyPI / GitHubtet-py
Importimport tet
Native extensiontet._native (PyO3 / maturin, abi3 cp311+)

Bindings are PyO3 → tetration rlib, not the C ABI. For Julia / R / Go, see FFI. Pin map: Version alignment.

What you get ​

  • Open a .tet, .tet.d package, or s3:// URI
  • Same JSON/TOML queries as the CLI; NumPy sinks (ram / spill / sidecar)
  • Write with TetWriter / write_dataset; convert / export via extras ([h5], [netcdf], [zarr], [parquet], [export])
  • Package helpers: ingest, publish, pack
  • Job files: tet.run_job

Details are in the sections below — not a per-release changelog.

Sections ​

When to use each sink ​

SinkOutputTypical use
ramnumpy.ndarray in processNotebooks, arrays that fit memory budget
spillRow-major .bin beside sourceLarge transforms; reload with .to_numpy()
sidecarOne-chunk .tet beside sourceKeep transformed data as a mmap-friendly .tet (re-query, share, append pipeline)

Sidecar is transform-only (engine writes a derived .tet; open with side.open(f) or tet.open). Spill is raw bytes; sidecar is a full catalog file. Prefer sidecar for transform provenance; TetWriter for general authoring (details).

Convert / export: tet.convert / tet.export (+ extras). Same importers as the CLI without Python deps — Install, CLI convert & export.

Minimal example ​

python
import tet

with tet.open("data.tet") as f:
    print(tet.__version__, tet.core_version())
    print(f.mean("temperature"))
    r = f.mean("temperature", preview=32)   # QueryResult: scalar + capped preview
    arr = f.read_numpy("temperature")
    z = f.transform.to_numpy.zscore("temperature")
    side = f.transform.to_sidecar.zscore("temperature", path="temperature.zscore.tet")
    arr = side.to_numpy(f)

Packages ​

python
import tet
from tet import write_dataset

write_dataset("part.tet", "values", arr)
tet.ingest("demo.tet.d", "part.tet", create=True)
tet.publish("demo.tet.d", ["part"])
with tet.open("demo.tet.d") as f:
    f.mean("values")
tet.pack("demo.tet.d", "demo.tet")
# tet.pack("demo.tet.d", "demo.tet", remove_package=True)  # after verified copy

tet.open on a .tet.d directory follows CURRENT and mmaps that generation's packed.tet. tet.pack copies that sealed image to a standalone .tet; pass remove_package=True to delete the package only after verify (close pinned readers first). See CLI packages for the on-disk layout (tet gc / tet publish --abort are CLI-only today).

S3-compatible store ​

python
from tet import S3Store, write_dataset

write_dataset("part.tet", "values", arr)
store = S3Store.connect(
    endpoint="http://127.0.0.1:9000",
    bucket="tetration-test",
    access_key_id="tetration",
    secret_access_key="tetration-secret",
    prefix="demo",
)
store.ingest("part.tet", session_id="s0", part_id="values")
store.publish(["values"])
pinned = store.open("current")   # pin; later publish does not retarget
assert pinned.generation == 1

Credentials: S3Store.connect(...) args, or TETRATION_S3_* for tet.open("s3://…") / tet.convert("s3://…").

PathBehavior
tet.open("s3://bucket/prefix")Pin + range-read (no full download)
store.open("current")Downloads packed.tet
tet.convert("s3://…/file.ext")Download one object, then local import
tet.convert("s3://…/store.zarr")Needs [zarr]; fetch chunks as needed

More: store-backed reads.