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 src

Quickstart

from src 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.0.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.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: talosdb-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 f6b67826a4433d9d561c643d332c3e9dd9439d2041cf7a4ec8754c20327976c5
MD5 ebd6477d7b457110bdb839d725a86ade
BLAKE2b-256 de50702d1239be266a316a77a9e0a5bb930c4fad626375d5ad44cc6fb6a391e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: talosdb-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72813555a54a40b11791e4b83a7a88afd07f56f2bfc0064c1ccefd3c9d67af2e
MD5 c5625a0876adc1a9fa63b27fdbc23548
BLAKE2b-256 5fafa0184f66b7100d872d0471d7f4585f53fa2a29d6664bc4646bb6b88825cf

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