Skip to main content

Persistent memoization by parameter identity for experiment scripts

Project description

stet

A Python library for making parameter sweeps safely resumable.

Stet is a Latin proofreading instruction meaning "let it stand" - written beside a correction that should be ignored. When stet sees a parameter combination it has already run, it does the same: leave it, it's done.

When a long-running experiment script is re-run, whether after a crash, a time limit, or deliberately to extend a sweep, stet automatically skips any parameter combinations that have already been completed.

import stet

@stet.once(store='markov_runs.csv', key=['alpha', 'n_states', 'seed'])
def solve_markov(alpha, n_states, seed, n_iter=10_000):
    # expensive computation
    ...

for alpha in alphas:
    for n_states in [10, 50, 100]:
        for seed in range(20):
            solve_markov(alpha=alpha, n_states=n_states, seed=seed)

On restart, any already-completed (alpha, n_states, seed) combinations are skipped:

[once] Skipping solve_markov(alpha=0.01, n_states=10, seed=0)
[once] Skipping solve_markov(alpha=0.01, n_states=10, seed=1)
...

Installation

uv add stet
# or: python -m pip install stet

With Parquet support:

uv add stet[parquet]
# or: python -m pip install stet[parquet]

Usage

Zero config: uses _stet_store.csv in the current directory, all parameters as the key:

@stet.once
def run_experiment(alpha, seed):
    ...

Named store: backend selected from file extension (.csv, .json, .sqlite, .parquet):

@stet.once(store='runs.sqlite')
def run_experiment(alpha, seed):
    ...

Key subset: only alpha and seed determine whether a run is skipped; n_iter is ignored:

@stet.once(store='runs.csv', key=['alpha', 'seed'])
def run_experiment(alpha, seed, n_iter=1000):
    ...

Utilities

stet.status()            # print a summary of completed runs
stet.reset()             # clear the store
stet.reset(key_dict={'alpha': '0.1', 'seed': '42'})  # remove one entry

Storage backends

Extension Backend Notes
.csv pandas CSV Default. Human-readable.
.json stdlib json No extra dependencies.
.sqlite stdlib sqlite3 Best for large stores and parallel workers.
.parquet pandas + pyarrow Requires stet[parquet].

Documentation

Full documentation including how-to guides, API reference, and explanation of design decisions: docs.

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

stet-0.0.2.tar.gz (144.7 kB view details)

Uploaded Source

Built Distribution

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

stet-0.0.2-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file stet-0.0.2.tar.gz.

File metadata

  • Download URL: stet-0.0.2.tar.gz
  • Upload date:
  • Size: 144.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stet-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0263000b9ddeb61d18b00b8a22677d0321ada154349d731934a18016f0c2ae2b
MD5 24eeb7133a401e2573fd02a2da5520f3
BLAKE2b-256 9fc26c293359f203f9d0db69d8311c2af67fc00c8078185fa0a5f5fef8c1cc10

See more details on using hashes here.

Provenance

The following attestation bundles were made for stet-0.0.2.tar.gz:

Publisher: publish.yml on drvinceknight/stet

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

File details

Details for the file stet-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: stet-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stet-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 24d3bd62c01b6616afc661ca21c40b80733114d5fe4e0dbe7824d714e6a176f4
MD5 4a5c29d19525600ec42388933c926a3d
BLAKE2b-256 2ff7961d16c777b2c341fefbfda55224ef656aa26b1d0976a97c3aa88b8f4543

See more details on using hashes here.

Provenance

The following attestation bundles were made for stet-0.0.2-py3-none-any.whl:

Publisher: publish.yml on drvinceknight/stet

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