Skip to main content

Structured scientific logging using Logbook

Project description

notata

tests PyPI

notata is a minimal library for structured filesystem logging of scientific runs.

One Logbook -> one run directory: parameters, arrays, plots, artifacts, metadata, timestamped log. Explicit. Reproducible. Grep‑friendly.

Installation

pip install notata

Quick Start

Context Manager

from notata import Logbook
import numpy as np

with Logbook("oscillator_dt1e-3", params={"omega": 2.0, "dt": 1e-3, "steps": 10_000}) as log:
    omega = 2.0
    dt = 1e-3
    steps = 10_000
    x, v = 1.0, 0.0

    xs = np.empty(steps)
    vs = np.empty(steps)
    E  = np.empty(steps)

    for n in range(steps):
        a = -omega**2 * x
        x += v*dt + 0.5*a*dt*dt
        a_new = -omega**2 * x
        v += 0.5*(a + a_new)*dt
        xs[n], vs[n] = x, v
        E[n] = 0.5*(v**2 + (omega*x)**2)
        if (n+1) % 2000 == 0:
            log.info(f"step={n+1} x={x:.4f} v={v:.4f} E={E[n]:.6f}")

    log.save_arrays("trajectory", x=xs, v=vs)
    log.save_numpy("energy", E)
    log.save_json("final_state", {"x": float(x), "v": float(v), "E": float(E[-1])})

Manual Lifecycle

from notata import Logbook
import numpy as np

log = Logbook("heat_manual", params={"Nx": 64, "Ny": 64, "kappa": 0.01, "steps": 500})
Nx = Ny = 64
kappa = 0.01
dx = 1.0
dt = 0.2 * dx*dx / kappa

X, Y = np.meshgrid(np.linspace(-1,1,Nx), np.linspace(-1,1,Ny), indexing="ij")
T = np.exp(-6*(X**2 + Y**2))

snap_every = 100
for step in range(500):
    lap = (np.roll(T,1,0)+np.roll(T,-1,0)+np.roll(T,1,1)+np.roll(T,-1,1)-4*T)
    T += kappa * dt * lap
    if (step+1) % snap_every == 0:
        log.save_numpy(f"T_step{step+1}", T, category="data/intermediate")
        log.info(f"step={step+1} maxT={T.max():.4f}")
log.save_json("final_stats", {"max": float(T.max()), "mean": float(T.mean())})
log.mark_complete()

Failure capture

from notata import Logbook
import numpy as np

log = Logbook("unstable_run", params={"dt": 0.5})
try:
    dt = 0.5  # too large for stability
    x, v, w = 1.0, 0.0, 5.0
    for step in range(1000):
        a = -w**2 * x
        v += a * dt
        x += v * dt
        if not np.isfinite(x):
            raise RuntimeError("Diverged")
    log.mark_complete()
except Exception as e:
    log.mark_failed(str(e))

Output format

Data is stored as following:

log_<run_id>/
  log.txt
  metadata.json
  params.yaml
  data/
  plots/
  artifacts/

where the files follow:

Path / Pattern Purpose / Format
log.txt Plain text log; lines: [YYYY-MM-DDTHH:MM:SS] LEVEL message
metadata.json Run metadata: status, start_time, optional end_time, runtime_sec, optional failure_reason, run_id
params.yaml / params.json Parameter snapshot (latest saved form)
data/*.npz Array archives; single array → key data; multi-array save → keys = argument names
data/**/ Additional numeric outputs (via category="data/...")
`plots/*.png pdf
artifacts/*.txt Text artifacts (save_text)
artifacts/*.json JSON artifacts (save_json)
artifacts/*.pkl Pickled objects (save_pickle)
artifacts/* (other) Raw bytes (save_bytes)
artifacts/**/ Nested artifact categories (e.g. category="artifacts/logs")

Citation

You don't have to, but if you use notata in your research and need to reference it, please cite it as follows:

@software{notata_2025,
  author  = {Albert Alonso},
  title   = {notata: Structured Filesystem Logging for Scientific Runs},
  url     = {https://github.com/alonfnt/notata},
  version = {0.1.0},
  year    = {2025}
}

License

MIT License

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

notata-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

notata-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: notata-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for notata-0.1.0.tar.gz
Algorithm Hash digest
SHA256 89f97bf73fb327c0be96ada0bedf1451c38363891a82cc9250bc76a7556c0cb6
MD5 b29df1bd058a8767dc459349f978daec
BLAKE2b-256 0f5484084416136c0d9964b5284a65d68c52b3e56409663caff3b5f7d8573c4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for notata-0.1.0.tar.gz:

Publisher: publish-pypi.yml on alonfnt/notata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: notata-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for notata-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4eebbed144fdeefac0055a59c60c18a39268e7dc3668a8e5cdea826f717d4f6e
MD5 64fa4959c2fe93abff14ef0814070cb0
BLAKE2b-256 24f3afb9fcad6718eee20c3b506a5603b9e264a05c5a03af1418e476da494bb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for notata-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on alonfnt/notata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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