visualdynamics.core.run_log_extract¶
run_log_extract
¶
A run log brought into a project: one test, frozen at a stated entry.
A report holds references to project objects, never data that can move
under it, and a run log keeps growing while the test runs. So a log is
not referenced from a project; it is brought in as a snapshot, the way
Photos brings image files in. take reads one test of a .vdlog up
to a stated entry and keeps the lines of the file that test's views
read, exactly as written: the log's header, every entry of the test's
chain and of the chain between tests up to that entry, and the few
entries written elsewhere that answer something in the test (the next
test's opening, which closes it to runs; a cause, path, restart or
deviation that names one of its entries; a disposition of one of its
anomalies), each with its corrections.
RunLogExtract reads that snapshot as RunLogModel reads a log, so
its views (runs, interruptions, credited duration, findings, files,
chronology, holds, owed lists) are what the model gave for the test at
that entry, and nothing the file gains afterwards changes them. The
extract keeps the test's head hash, which the report's data index can
carry beside the log's other files. RunLogExtract.status compares
the live file with the snapshot: when the file has grown it says how
many newer entries the log holds, and a missing or changed file is
said in words, never raised.
Refusals. take refuses a file that is not a run log, a test the
log does not hold at the stated entry, an entry the log does not hold,
a chain of the test (or between tests) that does not verify, an entry
before the cut that the log cannot read, and, when no entry is stated,
a last line still torn (an entry being written). A line that is not an
entry at all (the fragment a crash leaves, ended by the next writer) is
skipped as the log itself skips it, and named in problems, since the
chain checks across it.
Drafts. The text an extract offers a report's author sections
(draft_chronology, draft_findings) is a Draft, marked as drafted:
it is offered, never placed, and the section stays owed until the
author accepts or edits it. Only the fact of a deviation or anomaly is
offered; its cause, effect and approval or disposition are the
author's. A log with nothing of a kind offers nothing for it rather
than "none", since an empty log cannot tell "nothing happened" from
"nobody wrote it down".
Classes:
| Name | Description |
|---|---|
LogStatus |
What the live log file says against an extract: its state (one of |
Draft |
Text the run log offers one of a report's author sections. |
RunLogExtract |
One test of a run log, frozen at a stated entry, held in a project. |
Functions:
| Name | Description |
|---|---|
held |
The run log extracts among |
take |
One test of the run log at |
stored_path |
The log's path as a project file stores it: relative to the |
resolved_path |
A stored log path made absolute against the project file it was |
Classes¶
LogStatus
dataclass
¶
What the live log file says against an extract: its state (one of
STATES), how many entries it holds after the extract's last entry
(newer) and how many of those are of the extract's test
(newer_in_test), and the state in words.
Attributes:
| Name | Type | Description |
|---|---|---|
badge |
str
|
The short words a badge shows: '' when the extract is |
Draft
dataclass
¶
Text the run log offers one of a report's author sections.
section is the skeleton section it is offered to, text the draft
in the report's Markdown ('' when the log has nothing to offer),
source which log, test and entry it was drafted from, notes what
the author should know that the text does not say, and mark what
it is shown with until the author accepts or edits it. A draft never
fills a section: it is offered beside it, and the section stays owed
until it is accepted. False when there is no text.
RunLogExtract
¶
RunLogExtract(text: str, *, path: str, test: int, upto: int, taken: datetime | str, log_size: int, after: int = 0, after_in_test: int = 0, problems: Sequence[str] = ())
One test of a run log, frozen at a stated entry, held in a project.
Made by take (or Project.attach_run_log), and saved in the
project file whole, so it reads the same wherever the project is
opened, with or without the log beside it. Its views are the
RunLogModel views of its test, read from the snapshot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The snapshot: the log's header line and the lines of the entries kept, as JSON Lines. |
required |
path
|
str
|
Where the log was, absolute (or as stored, when the project file it was resolved against is not known). |
required |
test
|
int
|
The test. |
required |
upto
|
int
|
The id of the last entry of the log the extract was taken to. |
required |
taken
|
datetime or str
|
When it was taken, with its zone (ISO 8601 text as stored). |
required |
log_size
|
int
|
The log file's size in bytes when it was taken. |
required |
after
|
int
|
How many entries the file held after |
0
|
after_in_test
|
int
|
How many entries the file held after |
0
|
problems
|
sequence of str
|
The lines of the log before |
()
|
Raises:
| Type | Description |
|---|---|
RunLogError
|
When |
Methods:
| Name | Description |
|---|---|
verify |
Check the snapshot's chains (the test's and the one between |
runs |
The test's runs ( |
interruptions |
The test's aborts, trips and scheduled stops, with the cause, |
credited |
The time credited on each axis against the duration and its |
findings |
The test's deviations and anomalies by number, with the |
open_anomalies |
The test's anomalies with no disposition, with their owners. |
files |
Every file the test's entries name, by SHA-256 |
chronology |
The test's entries in the order of their events, each with its |
holds |
The test's holds still unanswered at the extract's last |
owed |
The test's owed lists with a line still owed at the extract's |
late |
The test's entries written down late. |
status |
The live log against the extract. |
cited |
Which log, test and entry the extract holds, as a report cites |
draft_chronology |
The test's chronology from the log, as draft text for the |
interruption_lines |
The test's interruptions as a Markdown table: the entry, its |
credit_lines |
The time credited on each axis of the test against the |
draft_findings |
The test's deviations and anomalies from the log, as draft text |
Attributes:
| Name | Type | Description |
|---|---|---|
log_id |
str
|
The log's id, from its header: the same log wherever it is. |
log_title |
str
|
The log's title (the article or program it is kept for). |
head |
str
|
The head of the test's chain at the extract's last entry: the |
info |
Test
|
The test as the snapshot holds it: kind, state, header, axes, |
kind |
str
|
The test's kind ( |
title |
str
|
The test's title, from its header. |
state |
str
|
The test's state at the extract's last entry: 'open', 'closed |
header |
TestHeader
|
The test's header as it stood at the extract's last entry. |
entries |
tuple[Entry, ...]
|
The test's entries, corrected, in the order written. |
Source code in src/visualdynamics/core/run_log_extract.py
Attributes¶
head
property
¶
The head of the test's chain at the extract's last entry: the
hash of the test's last entry by then. A report's data index
carries it, so the record outside the log anchors the record
inside it (RunLog.verify(heads=...)).
info
property
¶
info: Test
The test as the snapshot holds it: kind, state, header, axes, runs and entries.
state
property
¶
The test's state at the extract's last entry: 'open', 'closed to runs' or 'released'.
Methods:¶
verify
¶
verify() -> Verification
Check the snapshot's chains (the test's and the one between
tests), as RunLog.verify checks a log holding one test.
interruptions
¶
interruptions() -> list[Interruption]
The test's aborts, trips and scheduled stops, with the cause,
path and restart answering each (RunLogModel.interruptions).
credited
¶
credited() -> list[Credit]
The time credited on each axis against the duration and its
tolerance (RunLogModel.credited).
findings
¶
findings() -> list[Finding]
The test's deviations and anomalies by number, with the
dispositions against each (RunLogModel.findings).
chronology
¶
chronology() -> list[ChronologyRow]
The test's entries in the order of their events, each with its
time on the recorders' clock (RunLogModel.chronology).
status
¶
status(path: str | PathLike | None = None) -> LogStatus
The live log against the extract.
The file's length is compared first; it is read only when its length differs from the length when the extract was taken. It is then 'newer' when it holds entries after the extract's last entry (and they are counted), 'changed' when it is another log or no longer holds the test's head (cut short or edited since), 'unreadable' when it is no longer a run log this build reads, and 'missing' when there is no file. None of these is an error: the extract stands as it was taken.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or PathLike
|
Where to look for the log; the extract's own path when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
LogStatus
|
The state, the newer entries counted, and the state in words. |
Source code in src/visualdynamics/core/run_log_extract.py
cited
¶
cited(status: LogStatus | None = None) -> str
Which log, test and entry the extract holds, as a report cites it, with the badge in brackets when the live log holds newer entries, has changed, cannot be read or is not found: "the run log 'Article 7', test 1, to entry #12 (test head 3f2a...) [newer entries in the log]".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
LogStatus
|
The live log's state, when it has been asked already;
|
None
|
Returns:
| Type | Description |
|---|---|
str
|
The citation. |
Source code in src/visualdynamics/core/run_log_extract.py
draft_chronology
¶
draft_chronology() -> Draft
The test's chronology from the log, as draft text for the report's Chronology section: its runs in order with their axis, start, what each held, the counter at the stop and the outcome; its interruptions with the cause, path and restart logged; and the time credited on each axis.
Draft text only: it is offered beside the section and marked as
drafted (DRAFTED), and the section stays owed until the author
accepts or edits it. A test with no runs offers nothing.
Returns:
| Type | Description |
|---|---|
Draft
|
The draft for section 'chronology'. |
Source code in src/visualdynamics/core/run_log_extract.py
interruption_lines
¶
The test's interruptions as a Markdown table: the entry, its time (on the recorders' clock where a clock check comes before it), the stop, and the cause, path and restart the log records, each 'not logged' or 'none logged' until it is. No lines when the log holds no interruption of the test, never a line saying there was none.
Source code in src/visualdynamics/core/run_log_extract.py
credit_lines
¶
The time credited on each axis of the test against the duration and its tolerance, one Markdown list item per axis; no lines when the test has no run.
Source code in src/visualdynamics/core/run_log_extract.py
draft_findings
¶
draft_findings() -> Draft
The test's deviations and anomalies from the log, as draft text for the report's deviations section: each by number with its fact as typed at the console, an anomaly's owner, and whether a disposition is logged.
Only the fact is offered. The cause, the effect and the approval or disposition are the author's, and a log with no findings offers nothing, never "none": the author sets the section to None in one step when that is so.
Returns:
| Type | Description |
|---|---|
Draft
|
The draft for section 'deviations'. |
Source code in src/visualdynamics/core/run_log_extract.py
Functions:¶
held
¶
held(objects: Mapping[str, Any]) -> list[tuple[str, RunLogExtract]]
The run log extracts among objects (a project, or any mapping of
names to objects), as (name, extract), in their order. Empty when
there are none, so a report feature that reads a run log changes
nothing in a project without one.
Source code in src/visualdynamics/core/run_log_extract.py
take
¶
take(path: str | PathLike, test: int | None = None, upto: int | None = None, *, taken: datetime | None = None) -> RunLogExtract
One test of the run log at path, frozen at entry upto.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or PathLike
|
The |
required |
test
|
int
|
The test, by number. May be left out when the log holds one test. |
None
|
upto
|
int
|
The id of the last entry the extract holds, from anywhere in the log; the log's last entry when omitted. |
None
|
taken
|
datetime
|
When the extract was taken, with its zone; now when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
RunLogExtract
|
The snapshot. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
When there is no file at |
RunLogError
|
When the file is not a run log or holds no entries, the log has
no entry |
Source code in src/visualdynamics/core/run_log_extract.py
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 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
stored_path
¶
The log's path as a project file stores it: relative to the project file's folder, with forward slashes, when the log is in that folder or one beneath it, and absolute otherwise (or when the project file is not known).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The log's path. |
required |
project_file
|
str or None
|
The project file the path is stored in. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The path to store. |
Source code in src/visualdynamics/core/run_log_extract.py
resolved_path
¶
A stored log path made absolute against the project file it was stored in; an absolute path, or a relative one with no project file known, is returned as stored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stored
|
str
|
The path as the project file stores it. |
required |
project_file
|
str or None
|
The project file. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The path to look for the log at. |