hertzforge.core.run_log_events¶
run_log_events
¶
A recorded run's events, offered to the run log.
The control service logs every event of a run it records: its states,
levels, alarms, trips, pulses and plays, the operator's actions, how it
ended (log.jsonl in the run folder, kept in the project's
RunRecord). The run log (core.run_log) is the log keeper's own
record of the floor, in its own format (.hflog). Every one of the
service's events can be an entry of that log, of any kind the service
has, but none is written there by itself: an entry in the run log is
the log keeper's, so each event is offered (offer) as a proposed
entry, and the keeper accepts it (accept), which writes it at the
time the controller logged it, or leaves it, which leaves no trace.
A log already in the run log's own format beside the run (a .hflog
in the run folder) is not offered again: it is the log, and is read
directly (read_beside).
Each proposal says which event it came from: the run's identity and the event's place in the service's log, written into the entry's text, so a second acceptance of the same event is refused and a reader of the log can trace the entry back to the run.
Classes:
| Name | Description |
|---|---|
RunLogError |
A run log, or an entry for one, that cannot be read or written |
RunEventsError |
An event that cannot be offered or accepted; the message names |
Proposal |
A run's event proposed as a run log entry. |
Functions:
| Name | Description |
|---|---|
offer |
Every event of a recorded run as a proposed run log entry, in the |
accept |
Write a proposed event into the log, at the time the controller |
read_beside |
The run logs already in the run log's own format in a run folder |
offered_or_read |
How a run's events reach the run log: ('read', logs) when its |
Classes¶
RunLogError
¶
Bases: ValueError
A run log, or an entry for one, that cannot be read or written one way; the message names the cause.
RunEventsError
¶
Bases: ValueError
An event that cannot be offered or accepted; the message names it.
Proposal
dataclass
¶
Proposal(kind: str, fields: Mapping[str, Any], text: str, event_time: datetime | None, marker: str, source: Mapping[str, Any] = dict())
A run's event proposed as a run log entry.
kind and fields are the entry's, event_time when the
controller logged it, with its zone (None when the record has no
time for it; the keeper then gives one), text the entry's words,
ending with marker, which names the run and the event. source
is the service's own entry as recorded.
Functions:¶
offer
¶
offer(record: Any) -> list[Proposal]
Every event of a recorded run as a proposed run log entry, in the order the service logged them, and how the run ended as a proposed 'run stopped' entry. Nothing is written.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
RunRecord
|
The run's record. |
required |
Returns:
| Type | Description |
|---|---|
list of Proposal
|
|
accept
¶
accept(log: RunLog, proposal: Proposal, *, author: str, test: int | None = None, axis: str | None = None, run: int | None = None, event_time: datetime | None = None) -> Entry
Write a proposed event into the log, at the time the controller logged it, as the keeper confirms it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log
|
RunLog
|
The log, open for writing. |
required |
proposal
|
Proposal
|
The event. |
required |
author
|
str
|
The log keeper's initials. |
required |
test
|
int
|
The test and run it belongs to, by number. |
None
|
run
|
int
|
The test and run it belongs to, by number. |
None
|
axis
|
str
|
The axis it belongs to. |
None
|
event_time
|
datetime
|
When it happened, for an event the record has no time for, or to correct it; the controller's time otherwise. |
None
|
Returns:
| Type | Description |
|---|---|
Entry
|
The entry written. |
Raises:
| Type | Description |
|---|---|
RunEventsError
|
When the log already holds this event (its marker), or the event has no time and none is given. |
RunLogError
|
For anything the log refuses ( |
read_beside
¶
read_beside(folder: str | PathLike) -> list[RunLog]
The run logs already in the run log's own format in a run folder
(.hflog files), read as they are; empty when there is none, and the
run's events are then offered (offer).
offered_or_read
¶
How a run's events reach the run log: ('read', logs) when its folder holds a log in the run log's own format, else ('offered', proposals) for the keeper to confirm. Never written silently.