Skip to main content

Lightweight experiment storage library for scientific simulations.

Project description

talosdb

Lightweight experiment storage library for scientific simulations. Named after Talos I station.

Installation

pip install talosdb

Quickstart

from talosdb import TalosDB
from itertools import product

db = TalosDB("~/science/results")
exp = db.experiment("vc_sweep_2025")

A_grid = [0.5, 1.0, 1.5]
beta_grid = [1.0, 2.0]

for A, beta in product(A_grid, beta_grid):
    result = simulate(A, beta)  # numpy array
    with exp.run({"A": A, "beta": beta}) as run:
        run.save(result)
        run.save_params({"gamma": 0.1, "T": 300})  # extra constants
        run.save_plot(my_plot_fn, result)

File layout

db_root/
└── vc_sweep_2025/
    ├── experiment.json          # metadata: name, creation date
    ├── A=0.5_beta=1.0/
    │   ├── data.dat             # human-readable TSV (numpy array)
    │   ├── params.json          # all parameters (name + extra)
    │   └── plot.png             # if save_plot() was called
    └── A=1.0_beta=2.0/
        ├── data.dat
        └── params.json

API reference

TalosDB

db = TalosDB("path/to/db")        # creates root folder if absent
db.experiment("name")              # create / open experiment
db.experiment()                    # name = datetime stamp
db.list_experiments()              # → list[str]
db.delete_experiment("name", confirm=True)

Experiment

exp = db.experiment("my_exp")

# Create / open a run
run  = exp.run({"A": 0.5, "beta": 1.0})
# or as context manager (marks failed.json on exception):
with exp.run({"A": 0.5, "beta": 1.0}) as run:
    ...

# Load
run  = exp.load({"A": 0.5, "beta": 1.0})   # exact match
runs = exp.query({"beta": 1.0})             # subset match → list[Run]
runs = exp.all_runs()                        # every run

Run

run.save(result)                            # numpy array → data.dat
run.save_params({"gamma": 0.1, "T": 300})  # extra params → params.json
run.save_plot(plot_fn, result)              # calls plot_fn(result, path)

result = run.load_data()                    # → np.ndarray
params = run.load_params()                  # → dict
run.is_failed()                             # → bool
run.load_failure()                          # → dict with error info

plot_fn contract

def my_plot_fn(result, save_path):
    fig, ax = plt.subplots()
    ax.plot(result[:, 0], result[:, 1])
    fig.savefig(save_path)
    plt.close(fig)

talosdb does not import matplotlib — rendering is entirely the caller's responsibility.

.dat format

Arrays are stored as human-readable TSV with a small header:

# shape: 100 2
# dtype: float64
0.0	0.001
0.1	0.043
...

3D+ arrays are split into labelled 2D slices:

# shape: 2 3 4
# dtype: float64
# slice [0]
1.0	2.0	3.0	4.0
5.0	6.0	7.0	8.0
9.0	10.0	11.0	12.0

# slice [1]
...

The shape header ensures exact reconstruction on load regardless of dimensionality.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

talosdb-0.1.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

talosdb-0.1.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file talosdb-0.1.1.tar.gz.

File metadata

  • Download URL: talosdb-0.1.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for talosdb-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0d2ba9407cd31df6bd3b3bdec3b2c783e719cfc2e45aef9d57bbd0d778aa8116
MD5 89efed1e885581a9dc8371885bec43b8
BLAKE2b-256 1796465752e49418ff2eaea8b6fb1cfdd9a0efd7075d0937ed99414de24218bd

See more details on using hashes here.

File details

Details for the file talosdb-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: talosdb-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for talosdb-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15b894d53e2836161be6d03ca7682c2047335fe4a0f18b23027b929f42ee1942
MD5 e19624290b5898d83e81fa0039b4035c
BLAKE2b-256 a2b6f148f1eaf49dcb02853f54b3cd84d79981ac9b975949ab24561963041574

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page