document¶
The mechanics every deeperfly document shares (ADR-0059).
A document (a run config, a manifest, a calibration file) is TOML parsed strictly into a
Table: its keys are the fields, nothing is coerced beyond
TOML's own types (an array is a tuple, an int widens to a float), and an unknown
key, a wrong type or a missing key fails at load as [table].key. Loading also
refuses a commented-out header that live keys follow and a format_version this
deeperfly does not read. A run config is copied verbatim, never re-emitted.
ConfigError ¶
Named
dataclass
¶
Marks a path key that also takes names: names() are not paths.
Metadata of the key's annotation, Annotated[Path, ..., Named(names)]. A value
among the names is left as typed where a path would be made absolute
(overrides).
Source code in src/deeperfly/document.py
Table ¶
Bases: BaseModel
A document table: frozen, closed to unknown keys, and strict about types.
Subclasses declare their keys as fields. A rule that spans fields is a
model_validator(mode="after") raising ValueError, which
parse reports as [table]: the message; a rule
on one key is a validator of that key, reported as [table].key: the message.
Fields listed in _reserved are not keys at all -- where the document is,
not something it declares -- and are refused when a file names them.
Source code in src/deeperfly/document.py
at ¶
A key's dotted path as the file writes it: [data].split, bare at the root.
check_commented_headers ¶
Refuse a commented-out table header that uncommented keys follow.
# [smoothing] looks like the way to switch a stage off, but TOML binds the keys
below it to the previous table (ADR-0028).
Source code in src/deeperfly/document.py
check_format_version ¶
check_format_version(
data: Mapping,
kind: str,
expected: int = DOCUMENT_FORMAT_VERSION,
hint: str = "",
) -> None
Refuse a document written for another version of the schema.
Read before anything else, so another version's file is reported as such rather
than as an unknown key; a document that declares none is version 1. kind names
the document in the error and hint is appended to it.
Source code in src/deeperfly/document.py
format_errors ¶
The first problem a ValidationError reports, as [table].key: ....
An unknown key lists the table's own keys; missing keys of one table are named together; a rule's own message is passed through under its table, or at its key; a type error says what was expected and what was given.
Source code in src/deeperfly/document.py
load_document ¶
Parse a config file, linted, with the directory it lives in.
Every relative path in it resolves against that directory (ADR-0085), so it travels with the document.
Source code in src/deeperfly/document.py
match_names ¶
The names a selector claims, in names order; empty patterns mean all.
A list unions its matches. An entry with a glob character must match at least one
name and one without must be a name, since either miss is a typo; where names
the selector in the error.
Source code in src/deeperfly/document.py
overrides ¶
The --set KEY=VALUE items of a command, as values by dotted key.
A value is read as TOML (80, true, [0, 180, 0]), and a list may drop its
brackets (0,180,0); none restores the key's default (DEFAULT); a key
that takes only text takes the value verbatim; and a relative path is relative to
the current directory, not to the document. cls is the document the keys belong
to, which types them; an unknown key is left for validation to name.
Raises:
| Type | Description |
|---|---|
ConfigError
|
If an item is not |
Source code in src/deeperfly/document.py
parse ¶
Build a table from a parsed TOML mapping, strictly.
path is the table's dotted path in the document ("render.outputs.pose2d"),
which errors are named by.
Raises:
| Type | Description |
|---|---|
ConfigError
|
If |
Source code in src/deeperfly/document.py
table ¶
under_document ¶
A document path resolved against root when it is relative.
root is the document's own directory (ADR-0085). The join is normalized without
following symlinks, so a .. is taken as typed and the path a run prints is the
one the user would type; a manifest's paths take .. as the filesystem does
instead (under_folder).
Source code in src/deeperfly/document.py
with_keys ¶
A copy of a parsed document with values set by dotted key.
A DEFAULT value drops the key. A table the document lacks is created, and a
key that is not a table where the path needs one is replaced by one, which
validation then reports.
Source code in src/deeperfly/document.py
write_keys ¶
A document's text with values set by dotted key, as with_keys sets them.
Only the keys' lines change, so comments and layout survive: a key is rewritten where it stands, or added under its table's header, and a table the document lacks is appended. A document the edit cannot place (a table written inline or with dotted keys) is re-emitted instead, without its comments.