API Reference
Decorator
stet._decorator.once(func=None, *, store='_stet_store.csv', key=None)
Decorator that skips already-completed experiment runs.
Tracks which parameter combinations have been executed and skips them on subsequent calls. The function's return value is not saved; only whether the combination has been run.
Can be used in three styles:
Style 1 - zero config::
@once
def run_experiment(alpha, beta):
...
Style 2 - specify store::
@once(store='_stet_store.csv')
def run_experiment(alpha, beta):
...
Style 3 - full control::
@once(store='_stet_store.csv', key=['alpha', 'beta'])
def run_experiment(alpha, beta, n_steps):
...
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any] | None
|
The function to decorate (when used without parentheses). |
None
|
store
|
str | Path
|
Path to the store file. Backend is inferred from extension:
|
'_stet_store.csv'
|
key
|
list[str] | None
|
Parameter names that uniquely identify a run. If omitted, all parameters are used. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The decorated function (or a decorator if called with arguments). |
Example
Source code in src/stet/_decorator.py
Utility functions
stet._utils.status(store_path=_DEFAULT_STORE)
Print a summary of completed experiments in a store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store_path
|
str | Path
|
Path to the store file (any supported extension).
Defaults to |
_DEFAULT_STORE
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the store file does not exist. |
Example
Source code in src/stet/_utils.py
stet._utils.reset(store_path=_DEFAULT_STORE, key_dict=None)
Remove entries from a store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store_path
|
str | Path
|
Path to the store file. Defaults to |
_DEFAULT_STORE
|
key_dict
|
dict[str, Any] | None
|
If provided, remove only this specific key combination. If None, clear the entire store (prompts for confirmation in interactive mode). |
None
|
Example
Source code in src/stet/_utils.py
Backends
stet.backends._base.BaseBackend
Bases: ABC
Abstract base class defining the backend interface.
All backends must implement :meth:has, :meth:record,
:meth:load, :meth:remove, and :meth:clear.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the store file. |
required |
Source code in src/stet/backends/_base.py
clear()
abstractmethod
has(key_dict)
abstractmethod
Check if a key combination exists in the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
Parameter names and values to look up. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if this combination has been recorded, False otherwise. |
Source code in src/stet/backends/_base.py
load()
abstractmethod
Return all stored records.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of dicts, each representing one recorded experiment run. |
record(key_dict)
abstractmethod
Write a key combination to the store.
Adds _stet_timestamp with the current UTC time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
Parameter names and values to record. |
required |
remove(key_dict)
abstractmethod
Remove a specific key combination from the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
The exact key combination to remove. |
required |
stet.backends._csv.CsvBackend
Bases: BaseBackend
Store experiment records in a CSV file using pandas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the |
required |
Example
Source code in src/stet/backends/_csv.py
clear()
has(key_dict)
Check if key combination exists in the CSV store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
Parameter names and values to look up. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if this combination has been recorded, False otherwise. |
Source code in src/stet/backends/_csv.py
load()
Return all records from the CSV store.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of dicts, each representing one recorded experiment run. |
Source code in src/stet/backends/_csv.py
record(key_dict)
Append a key combination to the CSV store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
Parameter names and values to record. |
required |
Source code in src/stet/backends/_csv.py
remove(key_dict)
Remove a specific key combination from the CSV store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
The exact key combination to remove. |
required |
Source code in src/stet/backends/_csv.py
stet.backends._json.JsonBackend
Bases: BaseBackend
Store experiment records in a JSON file.
Uses Python's built-in :mod:json. No extra dependencies required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the |
required |
Example
Source code in src/stet/backends/_json.py
clear()
has(key_dict)
Check if key combination exists in the JSON store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
Parameter names and values to look up. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if this combination has been recorded, False otherwise. |
Source code in src/stet/backends/_json.py
load()
Return all records from the JSON store.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of dicts, each representing one recorded experiment run. |
record(key_dict)
Append a key combination to the JSON store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
Parameter names and values to record. |
required |
Source code in src/stet/backends/_json.py
remove(key_dict)
Remove a specific key combination from the JSON store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
The exact key combination to remove. |
required |
Source code in src/stet/backends/_json.py
stet.backends._sqlite.SqliteBackend
Bases: BaseBackend
Store experiment records in a SQLite database.
Uses Python's built-in :mod:sqlite3. No extra dependencies required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the |
required |
Example
Source code in src/stet/backends/_sqlite.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
clear()
Remove all records from the SQLite store.
has(key_dict)
Check if key combination exists in the SQLite store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
Parameter names and values to look up. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if this combination has been recorded, False otherwise. |
Source code in src/stet/backends/_sqlite.py
load()
Return all records from the SQLite store.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of dicts, each representing one recorded experiment run. |
Source code in src/stet/backends/_sqlite.py
record(key_dict)
Insert a key combination into the SQLite store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
Parameter names and values to record. |
required |
Source code in src/stet/backends/_sqlite.py
remove(key_dict)
Remove a specific key combination from the SQLite store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
The exact key combination to remove. |
required |
Source code in src/stet/backends/_sqlite.py
stet.backends._parquet.ParquetBackend
Bases: BaseBackend
Store experiment records in a Parquet file using pandas and pyarrow.
Requires the parquet extra: uv add stet[parquet].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the |
required |
Example
Source code in src/stet/backends/_parquet.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
clear()
has(key_dict)
Check if key combination exists in the Parquet store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
Parameter names and values to look up. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if this combination has been recorded, False otherwise. |
Source code in src/stet/backends/_parquet.py
load()
Return all records from the Parquet store.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of dicts, each representing one recorded experiment run. |
Source code in src/stet/backends/_parquet.py
record(key_dict)
Append a key combination to the Parquet store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
Parameter names and values to record. |
required |
Source code in src/stet/backends/_parquet.py
remove(key_dict)
Remove a specific key combination from the Parquet store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_dict
|
dict[str, Any]
|
The exact key combination to remove. |
required |