graphrecords.plugins#
Plugin authoring surface for the graphrecords library.
Module Attributes
A type alias for a change a plugin hook may return. |
|
A type alias for the changes a plugin hook may return. |
Classes
|
The payload of a change adding edges. |
|
The payload of a change adding edges in a group. |
|
The payload of a change adding edges to a group. |
|
The payload of a change adding a group. |
|
The payload of a change adding nodes. |
|
The payload of a change adding nodes in a group. |
|
The payload of a change adding nodes to a group. |
|
The payload of a change clearing the GraphRecord. |
|
A batch of edges carried by a change payload. |
An iterator over the edges of a batch. |
|
The payload of a change freezing the schema. |
|
|
A batch of nodes carried by a change payload. |
An iterator over the nodes of a batch. |
|
|
Base class for GraphRecord plugins. |
|
The payload of a change removing edge attributes. |
|
The payload of a change removing edges. |
|
The payload of a change removing edges from a group. |
|
The payload of a change removing groups. |
|
The payload of a change removing node attributes. |
|
The payload of a change removing nodes. |
|
The payload of a change removing nodes from a group. |
|
The payload of a change replacing edge attributes. |
|
The payload of a change replacing node attributes. |
|
The payload of a change setting edge attributes. |
|
The payload of a change setting node attributes. |
|
The payload of a change setting the schema. |
The payload of a change unfreezing the schema. |
- class AddEdgesInGroup(batch, group_index)[source]#
Bases:
objectThe payload of a change adding edges in a group.
- property group_index: str | int#
The group the edges are added in.
- Returns:
GroupIndex – The group the edges are added in.
- class AddEdgesToGroup(edge_indices, group_index)[source]#
Bases:
objectThe payload of a change adding edges to a group.
- property edge_indices: List[EdgeIndex]#
The edges that are added.
- Returns:
List[EdgeIndex] – The edges that are added.
- property group_index: str | int#
The group the edges join.
- Returns:
GroupIndex – The group the edges join.
- class AddGroup(group_index)[source]#
Bases:
objectThe payload of a change adding a group.
- property group_index: str | int#
The group that is added.
- Returns:
GroupIndex – The group that is added.
- class AddNodesInGroup(batch, group_index)[source]#
Bases:
objectThe payload of a change adding nodes in a group.
- property group_index: str | int#
The group the nodes are added in.
- Returns:
GroupIndex – The group the nodes are added in.
- class AddNodesToGroup(node_indices, group_index)[source]#
Bases:
objectThe payload of a change adding nodes to a group.
- property group_index: str | int#
The group the nodes join.
- Returns:
GroupIndex – The group the nodes join.
- property node_indices: List[str | int]#
The nodes that are added.
- Returns:
List[NodeIndex] – The nodes that are added.
- Change#
A type alias for a change a plugin hook may return.
alias of
AddNodes|AddNodesInGroup|AddEdges|AddEdgesInGroup|RemoveNodes|RemoveEdges|SetNodeAttributes|ReplaceNodeAttributes|RemoveNodeAttributes|SetEdgeAttributes|ReplaceEdgeAttributes|RemoveEdgeAttributes|AddGroup|RemoveGroups|AddNodesToGroup|RemoveNodesFromGroup|AddEdgesToGroup|RemoveEdgesFromGroup|SetSchema|FreezeSchema|UnfreezeSchema|Clear
- Changes#
A type alias for the changes a plugin hook may return.
alias of
AddNodes|AddNodesInGroup|AddEdges|AddEdgesInGroup|RemoveNodes|RemoveEdges|SetNodeAttributes|ReplaceNodeAttributes|RemoveNodeAttributes|SetEdgeAttributes|ReplaceEdgeAttributes|RemoveEdgeAttributes|AddGroup|RemoveGroups|AddNodesToGroup|RemoveNodesFromGroup|AddEdgesToGroup|RemoveEdgesFromGroup|SetSchema|FreezeSchema|UnfreezeSchema|Clear|List[AddNodes|AddNodesInGroup|AddEdges|AddEdgesInGroup|RemoveNodes|RemoveEdges|SetNodeAttributes|ReplaceNodeAttributes|RemoveNodeAttributes|SetEdgeAttributes|ReplaceEdgeAttributes|RemoveEdgeAttributes|AddGroup|RemoveGroups|AddNodesToGroup|RemoveNodesFromGroup|AddEdgesToGroup|RemoveEdgesFromGroup|SetSchema|FreezeSchema|UnfreezeSchema|Clear]
- class EdgeBatch(edges)[source]#
Bases:
objectA batch of edges carried by a change payload.
- __iter__()[source]#
Iterates over the edges of the batch.
- Return type:
- Returns:
EdgeBatchIterator – An iterator over the edges.
- __len__()[source]#
Counts the edges of the batch.
- Return type:
int- Returns:
int – The number of edges.
- attribute_values(attribute_name)[source]#
Collects the value of one attribute across the edges that carry it.
- Parameters:
attribute_name (AttributeName) – The name of the attribute to read.
- Return type:
List[Tuple[Union[str,int],Union[str,int],Union[str,int,float,bool,datetime,timedelta,None]]]- Returns:
List[Tuple[NodeIndex, NodeIndex, Value]] –
- The source node index, target
node index and value of every edge that carries the attribute.
- class EdgeBatchIterator[source]#
Bases:
objectAn iterator over the edges of a batch.
- __iter__()[source]#
Returns the iterator itself.
- Return type:
- Returns:
EdgeBatchIterator – The iterator itself.
- __next__()[source]#
Returns the next edge of the batch.
- Return type:
Tuple[Union[str,int],Union[str,int],Dict[Union[str,int],Union[str,int,float,bool,datetime,timedelta,None]]]- Returns:
Tuple[NodeIndex, NodeIndex, Attributes] –
- The source node index, target
node index and attributes of the edge.
- class NodeBatch(nodes)[source]#
Bases:
objectA batch of nodes carried by a change payload.
- __iter__()[source]#
Iterates over the nodes of the batch.
- Return type:
- Returns:
NodeBatchIterator – An iterator over the nodes.
- __len__()[source]#
Counts the nodes of the batch.
- Return type:
int- Returns:
int – The number of nodes.
- attribute_values(attribute_name)[source]#
Collects the value of one attribute across the nodes that carry it.
- Parameters:
attribute_name (AttributeName) – The name of the attribute to read.
- Return type:
List[Tuple[Union[str,int],Union[str,int,float,bool,datetime,timedelta,None]]]- Returns:
List[Tuple[NodeIndex, Value]] –
- The index and value of every node that
carries the attribute.
- class NodeBatchIterator[source]#
Bases:
objectAn iterator over the nodes of a batch.
- class Plugin[source]#
Bases:
objectBase class for GraphRecord plugins.
Every hook is optional: a GraphRecord calls a hook only when the plugin defines it. A
pre_hook returns what the GraphRecord applies in place of the change it received:Nonekeeps that change, a change or a list of changes replaces it, and an empty list drops it.initializeandfinalizereturn changes the same way, but receive no change, soNonemeans no changes. Apost_hook observes the GraphRecords before and after the applied changes together with the change that was applied and must returnNone. The two GraphRecords bracket every change applied in the call, not only the change the hook received. The hooks are declared for type checkers only, which keeps a plugin free of the hooks it does not implement and keeps a GraphRecord from building payloads nobody reads.
- class RemoveEdgeAttributes(edge_indices, attribute_names)[source]#
Bases:
objectThe payload of a change removing edge attributes.
- property attribute_names: List[str | int]#
The names of the removed attributes.
- Returns:
List[AttributeName] – The names of the removed attributes.
- class RemoveEdgesFromGroup(edge_indices, group_index)[source]#
Bases:
objectThe payload of a change removing edges from a group.
- property edge_indices: List[EdgeIndex]#
The edges that are removed.
- Returns:
List[EdgeIndex] – The edges that are removed.
- property group_index: str | int#
The group the edges leave.
- Returns:
GroupIndex – The group the edges leave.
- class RemoveGroups(group_indices)[source]#
Bases:
objectThe payload of a change removing groups.
- property group_indices: List[str | int]#
The groups that are removed.
- Returns:
List[GroupIndex] – The groups that are removed.
- class RemoveNodeAttributes(node_indices, attribute_names)[source]#
Bases:
objectThe payload of a change removing node attributes.
- property attribute_names: List[str | int]#
The names of the removed attributes.
- Returns:
List[AttributeName] – The names of the removed attributes.
- property node_indices: List[str | int]#
The nodes the attributes are removed from.
- Returns:
List[NodeIndex] – The nodes the attributes are removed from.
- class RemoveNodes(node_indices)[source]#
Bases:
objectThe payload of a change removing nodes.
- property node_indices: List[str | int]#
The nodes that are removed.
- Returns:
List[NodeIndex] – The nodes that are removed.
- class RemoveNodesFromGroup(node_indices, group_index)[source]#
Bases:
objectThe payload of a change removing nodes from a group.
- property group_index: str | int#
The group the nodes leave.
- Returns:
GroupIndex – The group the nodes leave.
- property node_indices: List[str | int]#
The nodes that are removed.
- Returns:
List[NodeIndex] – The nodes that are removed.
- class ReplaceEdgeAttributes(edge_indices, attributes)[source]#
Bases:
objectThe payload of a change replacing edge attributes.
- property attributes: Dict[str | int, str | int | float | bool | datetime | timedelta | None]#
The attributes the edges end up with.
- Returns:
Attributes – The attributes the edges end up with.
- class ReplaceNodeAttributes(node_indices, attributes)[source]#
Bases:
objectThe payload of a change replacing node attributes.
- property attributes: Dict[str | int, str | int | float | bool | datetime | timedelta | None]#
The attributes the nodes end up with.
- Returns:
Attributes – The attributes the nodes end up with.
- property node_indices: List[str | int]#
The nodes the attributes are replaced on.
- Returns:
List[NodeIndex] – The nodes the attributes are replaced on.
- class SetEdgeAttributes(edge_indices, attributes)[source]#
Bases:
objectThe payload of a change setting edge attributes.
- property attributes: Dict[str | int, str | int | float | bool | datetime | timedelta | None]#
The attributes that are set.
- Returns:
Attributes – The attributes that are set.
- class SetNodeAttributes(node_indices, attributes)[source]#
Bases:
objectThe payload of a change setting node attributes.
- property attributes: Dict[str | int, str | int | float | bool | datetime | timedelta | None]#
The attributes that are set.
- Returns:
Attributes – The attributes that are set.
- property node_indices: List[str | int]#
The nodes the attributes are set on.
- Returns:
List[NodeIndex] – The nodes the attributes are set on.