graflo.link.assertions¶
Statements stored as the provenance aspect's Assertion vertices, and read back.
One Assertion is one :class:~graflo.link.statements.Statement, one triple
(rdf:Statement):
Assertion -subject-> <Type>: the entity the statement is about;predicate: the property or the relation stated;- for a property,
value: the stated value as text, read back as the property's declared type; for a relation,Assertion -object-> <Type>: the target; polarity,modality,valid_from/valid_to,granularity,quote,span_start/span_endandbasis, as on the statement;Assertion -wasDerivedFrom-> SourceRecord: the record it was read from, whosewritten_atis when it was said.
Whether a statement states a property or a relation follows from whether it has
an object edge; the entity's type, from its subject edge.
:func:statement_container writes statements in this shape and
:func:read_statements reads them back, about one entity or all of them;
:func:graph_time is the newest time a record was written.
Attributes¶
ENDS = (vocab.SUBJECT, vocab.OBJECT)
module-attribute
¶
The relations an Assertion names its subject and its object by.
__all__ = ['ENDS', 'Evidence', 'assertion_doc', 'graph_time', 'read_statements', 'stated_types', 'statement_container', 'stored_edges']
module-attribute
¶
Classes¶
Evidence
¶
Bases: ConfigBaseModel
Statements read from a graph, with the records they were read from.
Source code in graflo/link/assertions.py
Attributes¶
records = Field(default_factory=dict, description='``SourceRecord`` documents by ``source_record_id``.')
class-attribute
instance-attribute
¶
reserved = Field(default_factory=dict, description='Per statement id, the reserved fields its ``Assertion`` carries, such as the access zones it was written in.')
class-attribute
instance-attribute
¶
statements = Field(default_factory=list)
class-attribute
instance-attribute
¶
Functions:¶
assertion_doc(statement)
¶
The Assertion document for one statement, without its edges.
Source code in graflo/link/assertions.py
graph_time(conn, schema, *, guard=None, timeout_s=None)
¶
The graph's own time: the newest SourceRecord.written_at guard admits.
When a record was written is the world's clock; when it was read
(retrieved_at) is the reader's, so a replayed or historical world
resolves at its own time. None when no record has a time.
Source code in graflo/link/assertions.py
read_statements(conn, schema, *, about=None, guard=None, thread_field=None, limit=1000, timeout_s=None)
¶
The statements stored in conn, with the records they were read from.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
Connection
|
An open connection. |
required |
schema
|
Schema
|
The graph's logical schema, lifted with |
required |
about
|
tuple[str, Mapping[str, Any]] | None
|
|
None
|
guard
|
FilterExpression | None
|
A trusted read guard, as :meth: |
None
|
thread_field
|
str | None
|
The |
None
|
limit
|
int
|
At most this many edges per traversal step of an about read. |
1000
|
timeout_s
|
float | None
|
Seconds each traversal of an about read may run. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Evidence |
Evidence
|
each statement with its quote, record id, said time and |
Evidence
|
thread, the records, and the reserved fields of each assertion. |
Source code in graflo/link/assertions.py
stated_types(schema)
¶
The types schema lets a statement be about: each Assertion -subject-> target.
Source code in graflo/link/assertions.py
statement_container(schema, statements)
¶
The Assertion documents and their edges for statements, ready to write.
Each statement gives one Assertion, its subject edge, its object
edge for a relation, and its wasDerivedFrom edge when it names a record.
A statement given twice is written once.
Raises:
| Type | Description |
|---|---|
ValueError
|
schema has no |
Source code in graflo/link/assertions.py
stored_edges(conn, schema, edge, *, guard=None)
¶
Every stored edge as (source, target) identity documents, in logical names.