Index¶
An optional SQLite index of a store, for questions across calculations.
The index is a cache: the store's files are the truth, and Index.rebuild remakes the
index from them. Index.update instead reads the journal lines it has not seen and
re-reads from the store every key they name, so updating and rebuilding end with the
same index (a journal line only says which key changed; the rows always come from the
store).
Tables:
runs: one row per run:key,run,time(UTC, ISO 8601),program,version(as the output reports it),calctype,method,basis,formula,success,error_kind,wall_time(s),identities(JSON),withdrawn,preferred(the runStore.getreturns without identities),input(the input as JSON, files left out), and the environment it ran in, as its output reports it:host,cpu_model,devices(JSON list) andlibc.carries:key,run,carry(its id),identities(JSON),evidence(JSON),time: one row per run carried.tags:key,tag.meta:key,run,name,value(strings and numbers as they are; lists and objects as JSON).
Query JSON columns with SQLite's JSON functions:
json_extract(identities, '$.tblite') = '0.8.0', json_extract(input, '$.keywords.maxiter').
qcstore.Index
¶
Index(store: Store, path: Path)
A store's SQLite index; Store.index opens one, up to date.
Each method opens its own connection, so an index may be used from several threads and processes at once (on a local disk: SQLite's locks need one).
Attributes:
| Name | Type | Description |
|---|---|---|
store |
The store indexed. |
|
path |
The SQLite file. |
Source code in src/qcstore/index.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
query
¶
query(
*,
tag: str | None = None,
identities: Mapping[str, str] | None = None,
**columns: Any,
) -> list[dict[str, Any]]
Runs whose columns equal the values given, oldest first within each key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str | None
|
Only calculations with this tag. |
None
|
identities
|
Mapping[str, str] | None
|
Only runs valid under these numerics, produced by them or
carried to them: |
None
|
**columns
|
Any
|
Values of the |
{}
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
One dict per run, with |
list[dict[str, Any]]
|
from JSON. |
Raises:
| Type | Description |
|---|---|
ValueError
|
An unknown column, or a program name holding |
Source code in src/qcstore/index.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
rebuild
¶
rebuild() -> None
Remake the index from every run in the store.
Source code in src/qcstore/index.py
130 131 132 133 134 135 136 137 138 139 140 141 142 | |
sql
¶
sql(
text: str,
params: Sequence[Any] | Mapping[str, Any] = (),
) -> list[dict[str, Any]]
Run a read-only SQL query; return one dict per row, by column name.
Example
How many calculations per molecule:
index.sql(
"SELECT formula, COUNT(DISTINCT key) AS n FROM runs "
"GROUP BY formula ORDER BY n DESC"
)
Source code in src/qcstore/index.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
update
¶
update() -> None
Bring the index up to date: re-read every key the new journal lines name.
Source code in src/qcstore/index.py
118 119 120 121 122 123 124 125 126 127 128 | |