graflo.link.records¶
What a producer states about entities, before anything is known about which they are.
A producer that holds only some properties of an entity states a
:class:PartialRecord: a type and the properties it holds. It rarely holds a
full key, so a record is not a vertex yet. A :class:RecordGraph holds one
source's records and the relations stated between them, keyed by local refs.
Each record, stated property and relation may carry evidence: whatever the
producer keeps about where it read it. graflo stores and returns it, and never
interprets it.
Resolution (:mod:graflo.link.resolve) maps records to entities: it gives each
record it can identify an identity (:class:Resolved) and stages the rest
with the reason (:class:StagedRecord). A relation waits for its staged
endpoints (:class:HeldRelation). Nothing staged is written to the graph. A
relation between two records states two entities, so one whose endpoints
resolve to the same entity is never written (:class:DroppedRelation).
Candidate gathering (:mod:graflo.link.candidates) lists the entities a staged
record may be; something else -- a pick, a rule, a person -- decides.
Attributes¶
CandidateLane = Literal['alternate', 'exact', 'key', 'normalized', 'alias', 'compatible', 'relation', 'metadata', 'context']
module-attribute
¶
DropReason = Literal['same_entity']
module-attribute
¶
ResolvedBy = Literal['key', 'alternate', 'minted']
module-attribute
¶
StageReason = Literal['partial_key', 'no_key', 'unmatched', 'ambiguous', 'owned_unmatched', 'keyless_reference', 'hidden']
module-attribute
¶
Classes¶
AttributeCheck
¶
Bases: ConfigBaseModel
A stated property of the record against the candidate's stored value.
The stored value itself is never carried.
Source code in graflo/link/records.py
Attributes¶
exclusive = Field(description='Whether a difference on the field is a ``conflict``.')
class-attribute
instance-attribute
¶
field
instance-attribute
¶
level = Field(description='``exact``, ``compatible`` (one is a less specific form of the other), ``differs`` (not evidence against), ``conflict`` (evidence against: an exclusive field) or ``unknown`` (nothing stored to compare with). See :mod:`graflo.architecture.schema.compare`.')
class-attribute
instance-attribute
¶
CandidateHit
¶
Bases: ConfigBaseModel
One way an entity was found for a staged record.
Each lane carries its own fields and no others: relation the relation
and the anchor, metadata a role, context its anchor (a record's ref,
or the role subject) and the level of its label, every other lane what
matched, and alias and compatible also how many entities that reached.
Source code in graflo/link/records.py
Attributes¶
anchor = Field(default=None, description='``relation`` lane: ref of the resolved record it is linked to.')
class-attribute
instance-attribute
¶
lane = Field(description="How it was found. ``alternate``: one of the entities a stated secondary identity matched. ``exact``, ``key``, ``normalized``, ``alias``, ``compatible``: a lookup over the record's stated labels and the caller's lookup text. ``relation``: linked by a stated relation to a resolved record of the same source. ``metadata``: named by the source's metadata, added by the caller. ``context``: a neighbour of the record's type, one hop from an entity the source resolved by key or a subject it is known to concern.")
class-attribute
instance-attribute
¶
level = Field(default=None, description="``context`` lane: the record's stated label against the entity's.")
class-attribute
instance-attribute
¶
matched = Field(default=None, description='The words or values of the record it was found by.')
class-attribute
instance-attribute
¶
relation = Field(default=None, description='``relation`` lane: the relation followed.')
class-attribute
instance-attribute
¶
role = Field(default=None, description='``metadata`` lane: a role the caller assigns; ``context``: ``subject``.')
class-attribute
instance-attribute
¶
targets = Field(default=None, description="``alias`` lane: how many entities the alias reached in the reader's view; ``compatible`` lane: how many entities of the type hold the matched form.")
class-attribute
instance-attribute
¶
DroppedRelation
¶
Bases: ConfigBaseModel
A relation resolution never writes, and why.
Source code in graflo/link/records.py
Attributes¶
reason = Field(description='``same_entity``: its two records resolved to one entity (same type and identity); a relation between two records states two entities, so it is not written as a self-loop.')
class-attribute
instance-attribute
¶
relation
instance-attribute
¶
source_id
instance-attribute
¶
EntityCandidate
¶
Bases: ConfigBaseModel
An entity a staged record may be. A candidate never closes a record.
Source code in graflo/link/records.py
Attributes¶
attributes = Field(default_factory=list, description="The record's other comparable stated properties against the candidate's stored values. A key in conflict never appears: it leaves the candidate out.")
class-attribute
instance-attribute
¶
key = Field(description='Its identity fields and values.')
class-attribute
instance-attribute
¶
label = Field(default=None, description='Its label, if it has one.')
class-attribute
instance-attribute
¶
lanes = Field(min_length=1, description='Every way it was found, best first.')
class-attribute
instance-attribute
¶
support = Field(default_factory=SupportFeatures, description='The features that identify it, read by ``support()``.')
class-attribute
instance-attribute
¶
vertex_type
instance-attribute
¶
HeldRelation
¶
Bases: ConfigBaseModel
A relation waiting for staged endpoints.
Source code in graflo/link/records.py
KnownSubject
¶
Bases: ConfigBaseModel
An entity a source is known to concern, from its metadata, not its text.
Source code in graflo/link/records.py
PartialRecord
¶
Bases: ConfigBaseModel
An entity a source states: its type and the properties it holds.
Source code in graflo/link/records.py
Attributes¶
evidence = Field(default=None, description=_EVIDENCE)
class-attribute
instance-attribute
¶
may_create = Field(description='The record may create its entity when absent, rather than only reference one assumed to exist. Decides only whether a type that takes no key from the data is minted.')
class-attribute
instance-attribute
¶
props = Field(default_factory=dict)
class-attribute
instance-attribute
¶
ref = Field(description='Local id, unique within its graph.')
class-attribute
instance-attribute
¶
type = Field(description='Vertex type.')
class-attribute
instance-attribute
¶
Methods:¶
RecordGraph
¶
Bases: ConfigBaseModel
One source's records and the relations between them.
Source code in graflo/link/records.py
Attributes¶
records = Field(default_factory=list)
class-attribute
instance-attribute
¶
reference_time = None
class-attribute
instance-attribute
¶
relations = Field(default_factory=list)
class-attribute
instance-attribute
¶
schema_ref = Field(description='``<schema name>@<version>`` read against.')
class-attribute
instance-attribute
¶
source_id
instance-attribute
¶
RecordRelation
¶
Bases: ConfigBaseModel
An edge a source states between two records.
Source code in graflo/link/records.py
Attributes¶
edge_id
instance-attribute
¶
evidence = Field(default=None, description=_EVIDENCE)
class-attribute
instance-attribute
¶
props = Field(default_factory=dict)
class-attribute
instance-attribute
¶
source = Field(description='Ref of the source record.')
class-attribute
instance-attribute
¶
target = Field(description='Ref of the target record.')
class-attribute
instance-attribute
¶
Methods:¶
Resolution
¶
Bases: ConfigBaseModel
The outcome of resolving record graphs.
Source code in graflo/link/records.py
Attributes¶
dropped = Field(default_factory=list, description='Relations between resolved records that are never written.')
class-attribute
instance-attribute
¶
graphs = Field(default_factory=list)
class-attribute
instance-attribute
¶
resolved = Field(default_factory=list)
class-attribute
instance-attribute
¶
staged = Field(default_factory=Staged)
class-attribute
instance-attribute
¶
Methods:¶
identity_of(source_id, ref)
¶
Identity of record ref of source_id, when resolved.
Source code in graflo/link/records.py
Resolved
¶
Bases: ConfigBaseModel
A record identified as one entity.
Source code in graflo/link/records.py
Attributes¶
alternate = Field(default=None, description='Secondary identity the lookup used.')
class-attribute
instance-attribute
¶
by = Field(description='``key``: the record states a complete primary key. ``alternate``: a complete secondary identity found exactly one entity. ``minted``: a keyless entity the record may create.')
class-attribute
instance-attribute
¶
found_in = Field(default=None, description='Where a lookup found the entity: another record or the graph.')
class-attribute
instance-attribute
¶
identity
instance-attribute
¶
link_only = Field(default=False, description="Found in the graph outside what the write may change (the resolution's ``writable`` filter): the record links, never writes.")
class-attribute
instance-attribute
¶
owned = Field(default=False, description='The type is ingested by a connector: the record links, never writes.')
class-attribute
instance-attribute
¶
ref
instance-attribute
¶
source_id
instance-attribute
¶
type
instance-attribute
¶
Staged
¶
Bases: ConfigBaseModel
Everything resolution could not write yet.
Source code in graflo/link/records.py
StagedCandidates
¶
Bases: ConfigBaseModel
The candidates of one staged record, best first.
Source code in graflo/link/records.py
Attributes¶
candidates = Field(default_factory=list)
class-attribute
instance-attribute
¶
reason
instance-attribute
¶
record
instance-attribute
¶
source_id
instance-attribute
¶
truncated = Field(default=False, description='More were found than the cap let through.')
class-attribute
instance-attribute
¶
StagedRecord
¶
Bases: ConfigBaseModel
A record not identified yet, and why.
Source code in graflo/link/records.py
Attributes¶
matches = Field(default=0, description='Entities a lookup found.')
class-attribute
instance-attribute
¶
reason = Field(description="``partial_key``: some key fields stated, no key complete. ``no_key``: no key field stated. ``unmatched``: a secondary identity found nothing. ``ambiguous``: it found several entities. ``owned_unmatched``: a connector-owned entity the graph does not hold yet. ``keyless_reference``: a keyless type the record only references. ``hidden``: its key names an entity the resolution's guard hides, and its write would not add to the guarded fields, so it is neither written nor linked.")
class-attribute
instance-attribute
¶
record
instance-attribute
¶
source_id
instance-attribute
¶
StatedProp
¶
SupportFeatures
¶
Bases: ConfigBaseModel
What identifies a candidate, as :func:graflo.link.candidates.support reads it.